From 281e932c56615b8c78b4d03d5e868b7d22e85dc6 Mon Sep 17 00:00:00 2001 From: Richard Ramos Date: Thu, 5 May 2022 14:12:11 -0400 Subject: [PATCH] feat: add commit hash and method in debug rpc endpoint --- Makefile | 9 +++++++-- waku/v2/node/const.go | 4 ++++ waku/v2/rpc/debug.go | 7 +++++++ 3 files changed, 18 insertions(+), 2 deletions(-) create mode 100644 waku/v2/node/const.go diff --git a/Makefile b/Makefile index 862cb8d4..1d083296 100644 --- a/Makefile +++ b/Makefile @@ -29,12 +29,17 @@ else GOBIN_SHARED_LIB_CGO_LDFLAGS := CGO_LDFLAGS="-Wl,-soname,libgowaku.so.0" endif +GIT_COMMIT = $(shell git rev-parse --short HEAD) + +BUILD_FLAGS ?= $(shell echo "-ldflags='\ + -X github.com/status-im/go-waku/waku/v2/node.GitCommit=$(GIT_COMMIT)'") + all: build deps: lint-install build: - go build -o build/waku waku.go + go build $(BUILD_FLAGS) -o build/waku waku.go vendor: go mod tidy @@ -114,6 +119,6 @@ endif mobile-android: gomobile init && \ - gomobile bind -target=android -ldflags="-s -w" -o ./build/lib/gowaku.aar ./mobile + gomobile bind -target=android -ldflags="-s -w" $(BUILD_FLAGS) -o ./build/lib/gowaku.aar ./mobile @echo "Android library built:" @ls -la ./build/lib/*.aar ./build/lib/*.jar \ No newline at end of file diff --git a/waku/v2/node/const.go b/waku/v2/node/const.go new file mode 100644 index 00000000..0d02b3a4 --- /dev/null +++ b/waku/v2/node/const.go @@ -0,0 +1,4 @@ +package node + +// GitCommit is a commit hash. +var GitCommit string diff --git a/waku/v2/rpc/debug.go b/waku/v2/rpc/debug.go index 4b9beca5..7edeb2d7 100644 --- a/waku/v2/rpc/debug.go +++ b/waku/v2/rpc/debug.go @@ -21,3 +21,10 @@ func (d *DebugService) GetV1Info(r *http.Request, args *InfoArgs, reply *InfoRep reply.Version = "2.0" return nil } + +type VersionResponse string + +func (d *DebugService) GetV1Version(r *http.Request, args *InfoArgs, reply *VersionResponse) error { + *reply = VersionResponse(node.GitCommit) + return nil +}