Skip to content

Commit

Permalink
add RPC API to query pool's version
Browse files Browse the repository at this point in the history
  • Loading branch information
swordlet committed May 17, 2024
1 parent f41b7aa commit 9aef144
Show file tree
Hide file tree
Showing 4 changed files with 23 additions and 0 deletions.
16 changes: 16 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
```
1 change: 1 addition & 0 deletions main.go
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
1 change: 1 addition & 0 deletions pool/pool.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import (
"sync"
)

const Version = "0.1.0"
const PoolKey = "" // it can make pool boot/reboot without interfering.

type StorageConfig struct {
Expand Down
5 changes: 5 additions & 0 deletions stratum/api.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down Expand Up @@ -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)
}

0 comments on commit 9aef144

Please sign in to comment.