rpc: move all top*FromStack
client functions to a separate file
Some of them are shared between multiple RPC client APIs, so let's keep them in a separate place for better maintainability.
This commit is contained in:
parent
30e7d9a8b0
commit
347f7ed576
4 changed files with 77 additions and 70 deletions
|
@ -6,7 +6,6 @@ import (
|
|||
"github.com/nspcc-dev/neo-go/pkg/core/native/nativenames"
|
||||
"github.com/nspcc-dev/neo-go/pkg/smartcontract"
|
||||
"github.com/nspcc-dev/neo-go/pkg/util"
|
||||
"github.com/nspcc-dev/neo-go/pkg/vm/stackitem"
|
||||
)
|
||||
|
||||
// GetFeePerByte invokes `getFeePerByte` method on a native Policy contract.
|
||||
|
@ -80,13 +79,3 @@ func (c *Client) IsBlocked(hash util.Uint160) (bool, error) {
|
|||
}
|
||||
return topBoolFromStack(result.Stack)
|
||||
}
|
||||
|
||||
// topBoolFromStack returns the top boolean value from stack
|
||||
func topBoolFromStack(st []stackitem.Item) (bool, error) {
|
||||
index := len(st) - 1 // top stack element is last in the array
|
||||
result, ok := st[index].Value().(bool)
|
||||
if !ok {
|
||||
return false, fmt.Errorf("invalid stack item type: %s", st[index].Type())
|
||||
}
|
||||
return result, nil
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue