diff --git a/pkg/rpc/client/rpc.go b/pkg/rpc/client/rpc.go index bb0655f9d..1792d6ce5 100644 --- a/pkg/rpc/client/rpc.go +++ b/pkg/rpc/client/rpc.go @@ -374,6 +374,18 @@ func (c *Client) GetRawTransactionVerbose(hash util.Uint256) (*result.Transactio return resp, nil } +// GetStateHeight returns current validated and local node state height. +func (c *Client) GetStateHeight() (*result.StateHeight, error) { + var ( + params = request.NewRawParams() + resp = new(result.StateHeight) + ) + if err := c.performRequest("getstateheight", params, resp); err != nil { + return nil, err + } + return resp, nil +} + // GetStorageByID returns the stored value, according to the contract ID and the stored key. func (c *Client) GetStorageByID(id int32, key []byte) ([]byte, error) { return c.getStorage(request.NewRawParams(id, base64.StdEncoding.EncodeToString(key))) diff --git a/pkg/rpc/client/rpc_test.go b/pkg/rpc/client/rpc_test.go index 55fff2543..097543292 100644 --- a/pkg/rpc/client/rpc_test.go +++ b/pkg/rpc/client/rpc_test.go @@ -680,6 +680,21 @@ var rpcClientTestCases = map[string][]rpcClientTestCase{ }, }, }, + "getstateheight": { + { + name: "positive", + invoke: func(c *Client) (interface{}, error) { + return c.GetStateHeight() + }, + serverResponse: `{"jsonrpc":"2.0","id":1,"result":{"localrootindex":11646,"validatedrootindex":11645}}`, + result: func(c *Client) interface{} { + return &result.StateHeight{ + Local: 11646, + Validated: 11645, + } + }, + }, + }, "getstorage": { { name: "by hash, positive",