forked from TrueCloudLab/neoneo-go
rpc: refactor findstates
client wrapper
1. Use empty `prefix` instead of nil `preifx` in order to avoid RPC server exceptions. 2. Allow to omit `start` parameter` if `maxCount` is not specified. 3. Use empty `start` instead of nil `start` to avoid RPC server exceptions.
This commit is contained in:
parent
e3c0a1635f
commit
b98fab6b38
1 changed files with 10 additions and 1 deletions
|
@ -458,10 +458,19 @@ func (c *Client) GetState(stateroot util.Uint256, historicalContractHash util.Ui
|
||||||
// If `maxCount` specified, then maximum number of items to be returned equals to `maxCount`.
|
// If `maxCount` specified, then maximum number of items to be returned equals to `maxCount`.
|
||||||
func (c *Client) FindStates(stateroot util.Uint256, historicalContractHash util.Uint160, historicalPrefix []byte,
|
func (c *Client) FindStates(stateroot util.Uint256, historicalContractHash util.Uint160, historicalPrefix []byte,
|
||||||
start []byte, maxCount *int) (result.FindStates, error) {
|
start []byte, maxCount *int) (result.FindStates, error) {
|
||||||
|
if historicalPrefix == nil {
|
||||||
|
historicalPrefix = []byte{}
|
||||||
|
}
|
||||||
var (
|
var (
|
||||||
params = request.NewRawParams(stateroot.StringLE(), historicalContractHash.StringLE(), historicalPrefix, start)
|
params = request.NewRawParams(stateroot.StringLE(), historicalContractHash.StringLE(), historicalPrefix)
|
||||||
resp result.FindStates
|
resp result.FindStates
|
||||||
)
|
)
|
||||||
|
if start == nil && maxCount != nil {
|
||||||
|
start = []byte{}
|
||||||
|
}
|
||||||
|
if start != nil {
|
||||||
|
params.Values = append(params.Values, start)
|
||||||
|
}
|
||||||
if maxCount != nil {
|
if maxCount != nil {
|
||||||
params.Values = append(params.Values, *maxCount)
|
params.Values = append(params.Values, *maxCount)
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue