mirror of
https://github.com/nspcc-dev/neo-go.git
synced 2025-01-05 19:35:48 +00:00
rpc/client: support getstateheight
RPC
This commit is contained in:
parent
b4b0ae0f51
commit
d8dddabc86
2 changed files with 26 additions and 0 deletions
|
@ -620,6 +620,21 @@ var rpcClientTestCases = map[string][]rpcClientTestCase{
|
|||
},
|
||||
},
|
||||
},
|
||||
"getstateheight": {
|
||||
{
|
||||
name: "positive",
|
||||
invoke: func(c *Client) (interface{}, error) {
|
||||
return c.GetStateHeight()
|
||||
},
|
||||
serverResponse: `{"id":1,"jsonrpc":"2.0","result":{"blockHeight":208,"stateHeight":200}}`,
|
||||
result: func(c *Client) interface{} {
|
||||
return &result.StateHeight{
|
||||
BlockHeight: 208,
|
||||
StateHeight: 200,
|
||||
}
|
||||
},
|
||||
},
|
||||
},
|
||||
"getstateroot": {
|
||||
{
|
||||
name: "positive",
|
||||
|
|
|
@ -3,6 +3,7 @@ package client
|
|||
import (
|
||||
"github.com/nspcc-dev/neo-go/pkg/core/state"
|
||||
"github.com/nspcc-dev/neo-go/pkg/rpc/request"
|
||||
"github.com/nspcc-dev/neo-go/pkg/rpc/response/result"
|
||||
"github.com/nspcc-dev/neo-go/pkg/util"
|
||||
)
|
||||
|
||||
|
@ -24,3 +25,13 @@ func (c *Client) getStateRoot(p request.RawParams) (*state.MPTRootState, error)
|
|||
}
|
||||
return &resp, nil
|
||||
}
|
||||
|
||||
// GetStateHeight returns current block and state height.
|
||||
func (c *Client) GetStateHeight() (*result.StateHeight, error) {
|
||||
resp := new(result.StateHeight)
|
||||
err := c.performRequest("getstateheight", request.NewRawParams(), resp)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return resp, nil
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue