mirror of
https://github.com/nspcc-dev/neo-go.git
synced 2024-12-18 05:44:43 +00:00
7331127556
Signed-off-by: Evgenii Stratonikov <evgeniy@nspcc.ru>
26 lines
560 B
Go
26 lines
560 B
Go
package rpc
|
|
|
|
type (
|
|
// Params represents the JSON-RPC params.
|
|
Params []Param
|
|
)
|
|
|
|
// Value returns the param struct for the given
|
|
// index if it exists.
|
|
func (p Params) Value(index int) (*Param, bool) {
|
|
if len(p) > index {
|
|
return &p[index], true
|
|
}
|
|
|
|
return nil, false
|
|
}
|
|
|
|
// ValueWithType returns the param struct at the given index if it
|
|
// exists and matches the given type.
|
|
func (p Params) ValueWithType(index int, valType paramType) (*Param, bool) {
|
|
if val, ok := p.Value(index); ok && val.Type == valType {
|
|
return val, true
|
|
}
|
|
|
|
return nil, false
|
|
}
|