mirror of
https://github.com/nspcc-dev/neo-go.git
synced 2024-12-25 13:56:35 +00:00
35f952e44f
Forward-ported from 2.x with some updates.
25 lines
525 B
Go
25 lines
525 B
Go
package request
|
|
|
|
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 {
|
|
if len(p) > index {
|
|
return &p[index]
|
|
}
|
|
|
|
return nil
|
|
}
|
|
|
|
// 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 {
|
|
if val := p.Value(index); val != nil && val.Type == valType {
|
|
return val
|
|
}
|
|
return nil
|
|
}
|