feat: add commit hash and method in debug rpc endpoint

This commit is contained in:
Richard Ramos 2022-05-05 14:12:11 -04:00
parent 30527b9a80
commit 281e932c56
3 changed files with 18 additions and 2 deletions

View File

@ -29,12 +29,17 @@ else
GOBIN_SHARED_LIB_CGO_LDFLAGS := CGO_LDFLAGS="-Wl,-soname,libgowaku.so.0" GOBIN_SHARED_LIB_CGO_LDFLAGS := CGO_LDFLAGS="-Wl,-soname,libgowaku.so.0"
endif 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 all: build
deps: lint-install deps: lint-install
build: build:
go build -o build/waku waku.go go build $(BUILD_FLAGS) -o build/waku waku.go
vendor: vendor:
go mod tidy go mod tidy
@ -114,6 +119,6 @@ endif
mobile-android: mobile-android:
gomobile init && \ 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:" @echo "Android library built:"
@ls -la ./build/lib/*.aar ./build/lib/*.jar @ls -la ./build/lib/*.aar ./build/lib/*.jar

4
waku/v2/node/const.go Normal file
View File

@ -0,0 +1,4 @@
package node
// GitCommit is a commit hash.
var GitCommit string

View File

@ -21,3 +21,10 @@ func (d *DebugService) GetV1Info(r *http.Request, args *InfoArgs, reply *InfoRep
reply.Version = "2.0" reply.Version = "2.0"
return nil return nil
} }
type VersionResponse string
func (d *DebugService) GetV1Version(r *http.Request, args *InfoArgs, reply *VersionResponse) error {
*reply = VersionResponse(node.GitCommit)
return nil
}