rpc: add support of getstateroot to RPC client

This commit is contained in:
Anna Shaleva 2022-01-17 11:59:13 +03:00
parent 4cc5957c3a
commit 83b4c6734f
3 changed files with 60 additions and 0 deletions

View file

@ -471,6 +471,24 @@ func (c *Client) FindStates(stateroot util.Uint256, historicalContractHash util.
return resp, nil
}
// GetStateRootByHeight returns state root for the specified height.
func (c *Client) GetStateRootByHeight(height uint32) (*state.MPTRoot, error) {
return c.getStateRoot(request.NewRawParams(height))
}
// GetStateRootByBlockHash returns state root for block with specified hash.
func (c *Client) GetStateRootByBlockHash(hash util.Uint256) (*state.MPTRoot, error) {
return c.getStateRoot(request.NewRawParams(hash))
}
func (c *Client) getStateRoot(params request.RawParams) (*state.MPTRoot, error) {
var resp = new(state.MPTRoot)
if err := c.performRequest("getstateroot", params, resp); err != nil {
return nil, err
}
return resp, nil
}
// GetStateHeight returns current validated and local node state height.
func (c *Client) GetStateHeight() (*result.StateHeight, error) {
var (