rpc: make a separate handler for every RPC
Move getbestblockhash, getblockcount, getconnectioncount RPC.
This commit is contained in:
parent
969ed6e6e1
commit
6e801d33f0
1 changed files with 15 additions and 3 deletions
|
@ -160,13 +160,13 @@ func (s *Server) methodHandler(w http.ResponseWriter, req *request.In, reqParams
|
||||||
results, resultsErr = s.getApplicationLog(reqParams)
|
results, resultsErr = s.getApplicationLog(reqParams)
|
||||||
|
|
||||||
case "getbestblockhash":
|
case "getbestblockhash":
|
||||||
results = "0x" + s.chain.CurrentBlockHash().StringLE()
|
results, resultsErr = s.getBestBlockHash(reqParams)
|
||||||
|
|
||||||
case "getblock":
|
case "getblock":
|
||||||
results, resultsErr = s.getBlock(reqParams)
|
results, resultsErr = s.getBlock(reqParams)
|
||||||
|
|
||||||
case "getblockcount":
|
case "getblockcount":
|
||||||
results = s.chain.BlockHeight() + 1
|
results, resultsErr = s.getBlockCount(reqParams)
|
||||||
|
|
||||||
case "getblockhash":
|
case "getblockhash":
|
||||||
results, resultsErr = s.getBlockHash(reqParams)
|
results, resultsErr = s.getBlockHash(reqParams)
|
||||||
|
@ -181,7 +181,7 @@ func (s *Server) methodHandler(w http.ResponseWriter, req *request.In, reqParams
|
||||||
results, resultsErr = s.getClaimable(reqParams)
|
results, resultsErr = s.getClaimable(reqParams)
|
||||||
|
|
||||||
case "getconnectioncount":
|
case "getconnectioncount":
|
||||||
results = s.coreServer.PeerCount()
|
results, resultsErr = s.getConnectionCount(reqParams)
|
||||||
|
|
||||||
case "getnep5balances":
|
case "getnep5balances":
|
||||||
results, resultsErr = s.getNEP5Balances(reqParams)
|
results, resultsErr = s.getNEP5Balances(reqParams)
|
||||||
|
@ -257,6 +257,18 @@ func (s *Server) methodHandler(w http.ResponseWriter, req *request.In, reqParams
|
||||||
s.WriteResponse(req, w, results)
|
s.WriteResponse(req, w, results)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (s *Server) getBestBlockHash(_ request.Params) (interface{}, error) {
|
||||||
|
return "0x" + s.chain.CurrentBlockHash().StringLE(), nil
|
||||||
|
}
|
||||||
|
|
||||||
|
func (s *Server) getBlockCount(_ request.Params) (interface{}, error) {
|
||||||
|
return s.chain.BlockHeight() + 1, nil
|
||||||
|
}
|
||||||
|
|
||||||
|
func (s *Server) getConnectionCount(_ request.Params) (interface{}, error) {
|
||||||
|
return s.coreServer.PeerCount(), nil
|
||||||
|
}
|
||||||
|
|
||||||
func (s *Server) getBlock(reqParams request.Params) (interface{}, error) {
|
func (s *Server) getBlock(reqParams request.Params) (interface{}, error) {
|
||||||
var hash util.Uint256
|
var hash util.Uint256
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue