From 9aef14437a5f77c165e5067ddff147cbe40694e1 Mon Sep 17 00:00:00 2001 From: swordlet Date: Fri, 17 May 2024 22:50:10 +0800 Subject: [PATCH] add RPC API to query pool's version --- README.md | 16 ++++++++++++++++ main.go | 1 + pool/pool.go | 1 + stratum/api.go | 5 +++++ 4 files changed, 23 insertions(+) diff --git a/README.md b/README.md index f5221af..52548db 100644 --- a/README.md +++ b/README.md @@ -263,4 +263,20 @@ json { }, "id": 1 } +``` + +### xdag_poolVersion +#### request +``` +curl http://127.0.0.1:8082/api -s -X POST -H "Content-Type: application/json" --data +'{"jsonrpc":"2.0","method":"xdag_poolVersion","params":[""],"id":1}' +``` + +#### response +``` +json { + "jsonrpc": "2.0", + "result": "0.1.0", + "id": 1 +} ``` \ No newline at end of file diff --git a/main.go b/main.go index 5f3f668..bce9339 100644 --- a/main.go +++ b/main.go @@ -126,6 +126,7 @@ func startFrontend(cfg *pool.Config, s *stratum.StratumServer) { apiServer.Add("xdag_minerAccount", s.XdagMinerAccount) apiServer.Add("xdag_minerHashrate", s.XdagMinerHashrate) apiServer.Add("xdag_poolHashrate", s.XdagPoolHashrate) + apiServer.Add("xdag_poolVersion", s.XdagPoolVersion) err := apiServer.Run(cfg.Frontend.Listen) if err != nil { diff --git a/pool/pool.go b/pool/pool.go index ed75aa6..11f0564 100644 --- a/pool/pool.go +++ b/pool/pool.go @@ -5,6 +5,7 @@ import ( "sync" ) +const Version = "0.1.0" const PoolKey = "" // it can make pool boot/reboot without interfering. type StorageConfig struct { diff --git a/stratum/api.go b/stratum/api.go index 5b62c8d..7df1118 100644 --- a/stratum/api.go +++ b/stratum/api.go @@ -11,6 +11,7 @@ import ( "time" "github.com/XDagger/xdagpool/jrpc" + "github.com/XDagger/xdagpool/pool" "github.com/XDagger/xdagpool/util" "github.com/XDagger/xdagpool/ws" "github.com/gorilla/mux" @@ -1031,3 +1032,7 @@ func (s *StratumServer) XdagPoolHashrate(id uint64, params json.RawMessage) jrpc TotalOnline: totalOnline, }, nil) } + +func (s *StratumServer) XdagPoolVersion(id uint64, params json.RawMessage) jrpc.Response { + return jrpc.EncodeResponse(id, pool.Version, nil) +}