Documentation ¶
Index ¶
- Variables
- func BytesFromOpcode(op Op) ([]byte, error)
- func IntFromOpcode(op Op) (int64, error)
- func ParseStackArray(event *state.ContainedNotificationEvent) ([]stackitem.Item, error)
- func StringFromOpcode(op Op) (string, error)
- func UnexpectedArgNumErr(method string) error
- func UnexpectedOpcode(method string, op opcode.Opcode) error
- func WrongNumberOfParameters(exp, act int) error
- type BlockCounter
- type BlockHandler
- type Event
- type Handler
- type Listener
- type ListenerParams
- type NotaryEvent
- type NotaryHandlerInfo
- type NotaryParser
- type NotaryParserInfo
- type NotaryPreparator
- type NotaryType
- type NotificationHandlerInfo
- type NotificationParser
- type NotificationParserInfo
- type Op
- type Preparator
- type PreparatorPrm
- type Type
Constants ¶
This section is empty.
Variables ¶
var ( // ErrTXAlreadyHandled is returned if received TX has already been signed. ErrTXAlreadyHandled = errors.New("received main tx has already been handled") // ErrMainTXExpired is returned if received fallback TX is already valid. ErrMainTXExpired = errors.New("received main tx has expired") )
Functions ¶
func BytesFromOpcode ¶ added in v0.25.0
BytesFromOpcode tries to retrieve bytes from Op.
func IntFromOpcode ¶ added in v0.25.0
IntFromOpcode tries to retrieve int from Op.
func ParseStackArray ¶ added in v0.27.0
func ParseStackArray(event *state.ContainedNotificationEvent) ([]stackitem.Item, error)
ParseStackArray parses stack array from raw notification event received from neo-go RPC node.
func StringFromOpcode ¶ added in v0.26.0
StringFromOpcode tries to retrieve string from Op.
func UnexpectedArgNumErr ¶ added in v0.25.0
UnexpectedArgNumErr returns error when notary parsers get unexpected amount of argument in contract call.
func UnexpectedOpcode ¶ added in v0.25.0
UnexpectedOpcode returns error when notary parsers get unexpected opcode in contract call.
func WrongNumberOfParameters ¶
WrongNumberOfParameters returns an error about wrong number of smart contract parameters.
Types ¶
type BlockCounter ¶ added in v0.25.0
BlockCounter must return block count of the network from which notary requests are received.
type BlockHandler ¶ added in v0.15.0
BlockHandler is a chain block processing function.
type Event ¶
type Event interface {
MorphEvent()
}
Event is an interface that is provided by Neo:Morph event structures.
type Handler ¶
type Handler func(Event)
Handler is an Event processing function.
func WorkerPoolHandler ¶ added in v0.19.0
WorkerPoolHandler sets closure over worker pool w with passed handler h.
type Listener ¶
type Listener interface { // Listen must start the event listener. // // Must listen to events with the parser installed. Listen(context.Context) // ListenWithError must start the event listener. // // Must listen to events with the parser installed. // // Must send error to channel if subscriber channel has been closed or // it could not be started. ListenWithError(context.Context, chan<- error) // SetNotificationParser must set the parser of particular contract event. // // Parser of each event must be set once. All parsers must be set before Listen call. // // Must ignore nil parsers and all calls after listener has been started. SetNotificationParser(NotificationParserInfo) // RegisterNotificationHandler must register the event handler for particular notification event of contract. // // The specified handler must be called after each capture and parsing of the event. // // Must ignore nil handlers. RegisterNotificationHandler(NotificationHandlerInfo) // EnableNotarySupport enables notary request listening. Passed hash is // notary mainTX signer. In practise, it means that listener will subscribe // for only notary requests that are going to be paid with passed hash. // // Must not be called after Listen or ListenWithError. EnableNotarySupport(util.Uint160, client.AlphabetKeys, BlockCounter) // SetNotaryParser must set the parser of particular notary request event. // // Parser of each event must be set once. All parsers must be set before Listen call. // // Must ignore nil parsers and all calls after listener has been started. // // Has no effect if EnableNotarySupport was not called before Listen or ListenWithError. SetNotaryParser(NotaryParserInfo) // RegisterNotaryHandler must register the event handler for particular notification event of contract. // // The specified handler must be called after each capture and parsing of the event. // // Must ignore nil handlers. // // Has no effect if EnableNotarySupport was not called before Listen or ListenWithError. RegisterNotaryHandler(NotaryHandlerInfo) // RegisterBlockHandler must register chain block handler. // // The specified handler must be called after each capture and parsing of the new block from chain. // // Must ignore nil handlers. RegisterBlockHandler(BlockHandler) // Stop must stop the event listener. Stop() }
Listener is an interface of smart contract notification event listener.
func NewListener ¶
func NewListener(p ListenerParams) (Listener, error)
NewListener create the notification event listener instance and returns Listener interface.
type ListenerParams ¶
type ListenerParams struct { Logger *zap.Logger Subscriber subscriber.Subscriber WorkerPoolCapacity int }
ListenerParams is a group of parameters for Listener constructor.
type NotaryEvent ¶ added in v0.25.0
type NotaryEvent interface { ScriptHash() util.Uint160 Type() NotaryType Params() []Op Raw() *payload.P2PNotaryRequest }
NotaryEvent is an interface that is provided by Neo:Morph notary event structures.
type NotaryHandlerInfo ¶ added in v0.25.0
type NotaryHandlerInfo struct {
// contains filtered or unexported fields
}
NotaryHandlerInfo is a structure that groups the parameters of the handler of particular notary event.
func (NotaryHandlerInfo) Handler ¶ added in v0.25.0
func (nhi NotaryHandlerInfo) Handler() Handler
Handler returns an event handler.
func (*NotaryHandlerInfo) SetHandler ¶ added in v0.25.0
func (nhi *NotaryHandlerInfo) SetHandler(v Handler)
SetHandler is an event handler setter.
type NotaryParser ¶ added in v0.25.0
type NotaryParser func(NotaryEvent) (Event, error)
NotaryParser is a function that constructs Event from the NotaryEvent event.
type NotaryParserInfo ¶ added in v0.25.0
type NotaryParserInfo struct {
// contains filtered or unexported fields
}
NotaryParserInfo is a structure that groups the parameters of particular notary request event parser.
func (*NotaryParserInfo) SetParser ¶ added in v0.25.0
func (n *NotaryParserInfo) SetParser(p NotaryParser)
type NotaryPreparator ¶ added in v0.25.0
type NotaryPreparator interface {
Prepare(*payload.P2PNotaryRequest) (NotaryEvent, error)
}
NotaryPreparator constructs NotaryEvent from the NotaryRequest event.
type NotaryType ¶ added in v0.25.0
type NotaryType string
NotaryType is a notary event enumeration type.
func NotaryTypeFromBytes ¶ added in v0.25.0
func NotaryTypeFromBytes(data []byte) NotaryType
NotaryTypeFromBytes converts bytes slice to NotaryType.
func NotaryTypeFromString ¶ added in v0.25.0
func NotaryTypeFromString(str string) NotaryType
NotaryTypeFromString converts string to NotaryType.
func (NotaryType) Equal ¶ added in v0.25.0
func (t NotaryType) Equal(t2 NotaryType) bool
Equal compares two NotaryType values and returns true if they are equal.
func (NotaryType) String ¶ added in v0.25.0
func (t NotaryType) String() string
String returns casted to string NotaryType.
type NotificationHandlerInfo ¶ added in v0.25.0
type NotificationHandlerInfo struct {
// contains filtered or unexported fields
}
NotificationHandlerInfo is a structure that groups the parameters of the handler of particular contract event.
func (NotificationHandlerInfo) Handler ¶ added in v0.25.0
func (s NotificationHandlerInfo) Handler() Handler
Handler returns an event handler.
func (*NotificationHandlerInfo) SetHandler ¶ added in v0.25.0
func (s *NotificationHandlerInfo) SetHandler(v Handler)
SetHandler is an event handler setter.
type NotificationParser ¶ added in v0.25.0
type NotificationParser func(*state.ContainedNotificationEvent) (Event, error)
NotificationParser is a function that constructs Event from the StackItem list.
type NotificationParserInfo ¶ added in v0.25.0
type NotificationParserInfo struct {
// contains filtered or unexported fields
}
NotificationParserInfo is a structure that groups the parameters of particular contract notification event parser.
func (*NotificationParserInfo) SetParser ¶ added in v0.25.0
func (s *NotificationParserInfo) SetParser(v NotificationParser)
SetParser is an event parser setter.
func (*NotificationParserInfo) SetType ¶ added in v0.25.0
func (s *NotificationParserInfo) SetType(v Type)
SetType is an event type setter.
type Op ¶ added in v0.25.0
type Op struct {
// contains filtered or unexported fields
}
Op is wrapper over Neo VM's opcode and its parameter.
type Preparator ¶ added in v0.25.0
type Preparator struct {
// contains filtered or unexported fields
}
Preparator implements NotaryPreparator interface.
func (Preparator) Prepare ¶ added in v0.25.0
func (p Preparator) Prepare(nr *payload.P2PNotaryRequest) (NotaryEvent, error)
Prepare converts raw notary requests to NotaryEvent.
Returns ErrTXAlreadyHandled if transaction shouldn't be parsed and handled. It is not "error case". Every handled transaction is expected to be received one more time from the Notary service but already signed. This happens since every notary call is a new notary request in fact.
type PreparatorPrm ¶ added in v0.25.0
type PreparatorPrm struct { AlphaKeys client.AlphabetKeys // BlockCount must return block count of the network // from which notary requests are received. BlockCounter BlockCounter }
PreparatorPrm groups the required parameters of the Preparator constructor.