From 77cf47f9610b758fa38421b2ebf750f77a8cab9c Mon Sep 17 00:00:00 2001 From: edtubbs Date: Mon, 4 Nov 2024 13:58:32 -0600 Subject: [PATCH 1/2] ci: updated runner to macos-13 --- .github/workflows/ci.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index c0fd0e444..f39380e22 100755 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -81,7 +81,7 @@ jobs: goal: install - name: x86_64-macos host: x86_64-apple-darwin15 - os: macos-12 + os: macos-13 run-tests: true dep-opts: "SPEED=slow V=1" config-opts: "--enable-static --disable-shared --enable-test-passwd" From 2a46b704979449645ac893597e630126f48eba22 Mon Sep 17 00:00:00 2001 From: edtubbs Date: Wed, 4 Dec 2024 16:15:35 -0600 Subject: [PATCH 2/2] rest: added getTimestamp endpoint --- src/rest.c | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/src/rest.c b/src/rest.c index 75cc7ae91..1fa5d446d 100644 --- a/src/rest.c +++ b/src/rest.c @@ -33,6 +33,7 @@ #include #include +#define TIMESTAMP_MAX_LEN 32 /** * This function is called when an http request is received @@ -207,6 +208,13 @@ void dogecoin_http_request_cb(struct evhttp_request *req, void *arg) { } else if (strcmp(path, "/getChaintip") == 0) { dogecoin_blockindex* tip = client->headers_db->getchaintip(client->headers_db_ctx); evbuffer_add_printf(evb, "Chain tip: %d\n", tip->height); + } else if (strcmp(path, "/getTimestamp") == 0) { + dogecoin_blockindex* tip = client->headers_db->getchaintip(client->headers_db_ctx); + char s[TIMESTAMP_MAX_LEN]; + time_t t = tip->header.timestamp; + struct tm *p = localtime(&t); + strftime(s, sizeof(s), "%F %T", p); + evbuffer_add_printf(evb, "%s\n", s); } else { evhttp_send_error(req, HTTP_NOTFOUND, "Not Found"); evbuffer_free(evb);