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" 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);