forked from TrueCloudLab/frostfs-node
Add Inner Ring code
This commit is contained in:
parent
dadfd90dcd
commit
b7b5079934
400 changed files with 11420 additions and 8690 deletions
53
pkg/morph/event/parser.go
Normal file
53
pkg/morph/event/parser.go
Normal file
|
@ -0,0 +1,53 @@
|
|||
package event
|
||||
|
||||
import (
|
||||
"github.com/nspcc-dev/neo-go/pkg/smartcontract"
|
||||
"github.com/pkg/errors"
|
||||
)
|
||||
|
||||
// Parser is a function that constructs Event
|
||||
// from the StackItem list.
|
||||
type Parser func([]smartcontract.Parameter) (Event, error)
|
||||
|
||||
// ParserInfo is a structure that groups
|
||||
// the parameters of particular contract
|
||||
// notification event parser.
|
||||
type ParserInfo struct {
|
||||
scriptHashWithType
|
||||
|
||||
p Parser
|
||||
}
|
||||
|
||||
type wrongPrmNumber struct {
|
||||
exp, act int
|
||||
}
|
||||
|
||||
// WrongNumberOfParameters returns an error about wrong number of smart contract parameters.
|
||||
func WrongNumberOfParameters(exp, act int) error {
|
||||
return &wrongPrmNumber{
|
||||
exp: exp,
|
||||
act: act,
|
||||
}
|
||||
}
|
||||
|
||||
func (s wrongPrmNumber) Error() string {
|
||||
return errors.Errorf("wrong parameter count: expected %d, has %d", s.exp, s.act).Error()
|
||||
}
|
||||
|
||||
// SetParser is an event parser setter.
|
||||
func (s *ParserInfo) SetParser(v Parser) {
|
||||
s.p = v
|
||||
}
|
||||
|
||||
func (s ParserInfo) parser() Parser {
|
||||
return s.p
|
||||
}
|
||||
|
||||
// SetType is an event type setter.
|
||||
func (s *ParserInfo) SetType(v Type) {
|
||||
s.typ = v
|
||||
}
|
||||
|
||||
func (s ParserInfo) getType() Type {
|
||||
return s.typ
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue