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 ExpiredTXError
- 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") )
Functions ¶
func BytesFromOpcode ¶
BytesFromOpcode tries to retrieve bytes from Op.
func IntFromOpcode ¶
IntFromOpcode tries to retrieve int from Op.
func ParseStackArray ¶
func ParseStackArray(event *state.ContainedNotificationEvent) ([]stackitem.Item, error)
ParseStackArray parses stack array from raw notification event received from neo-go RPC node.
func StringFromOpcode ¶
StringFromOpcode tries to retrieve string from Op.
func UnexpectedArgNumErr ¶
UnexpectedArgNumErr returns error when notary parsers get unexpected amount of argument in contract call.
func UnexpectedOpcode ¶
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 ¶
BlockCounter must return block count of the network from which notary requests are received.
type BlockHandler ¶
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 ExpiredTXError ¶ added in v0.37.0
ExpiredTXError is returned if received fallback TX is already valid.
func (*ExpiredTXError) Error ¶ added in v0.37.0
func (e *ExpiredTXError) Error() string
type Handler ¶
Handler is an Event processing function.
func WorkerPoolHandler ¶
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 *logger.Logger Subscriber subscriber.Subscriber WorkerPoolCapacity int }
ListenerParams is a group of parameters for Listener constructor.
type NotaryEvent ¶
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 ¶
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 ¶
func (nhi NotaryHandlerInfo) Handler() Handler
Handler returns an event handler.
func (*NotaryHandlerInfo) SetHandler ¶
func (nhi *NotaryHandlerInfo) SetHandler(v Handler)
SetHandler is an event handler setter.
type NotaryParser ¶
type NotaryParser func(NotaryEvent) (Event, error)
NotaryParser is a function that constructs Event from the NotaryEvent event.
type NotaryParserInfo ¶
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 ¶
func (n *NotaryParserInfo) SetParser(p NotaryParser)
type NotaryPreparator ¶
type NotaryPreparator interface {
Prepare(*payload.P2PNotaryRequest) (NotaryEvent, error)
}
NotaryPreparator constructs NotaryEvent from the NotaryRequest event.
type NotaryType ¶
type NotaryType string
NotaryType is a notary event enumeration type.
func NotaryTypeFromBytes ¶
func NotaryTypeFromBytes(data []byte) NotaryType
NotaryTypeFromBytes converts bytes slice to NotaryType.
func NotaryTypeFromString ¶
func NotaryTypeFromString(str string) NotaryType
NotaryTypeFromString converts string to NotaryType.
func (NotaryType) Equal ¶
func (t NotaryType) Equal(t2 NotaryType) bool
Equal compares two NotaryType values and returns true if they are equal.
func (NotaryType) String ¶
func (t NotaryType) String() string
String returns casted to string NotaryType.
type NotificationHandlerInfo ¶
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 ¶
func (s NotificationHandlerInfo) Handler() Handler
Handler returns an event handler.
func (*NotificationHandlerInfo) SetHandler ¶
func (s *NotificationHandlerInfo) SetHandler(v Handler)
SetHandler is an event handler setter.
type NotificationParser ¶
type NotificationParser func(*state.ContainedNotificationEvent) (Event, error)
NotificationParser is a function that constructs Event from the StackItem list.
type NotificationParserInfo ¶
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 ¶
func (s *NotificationParserInfo) SetParser(v NotificationParser)
SetParser is an event parser setter.
func (*NotificationParserInfo) SetType ¶
func (s *NotificationParserInfo) SetType(v Type)
SetType is an event type setter.
type Op ¶
type Op struct {
// contains filtered or unexported fields
}
Op is wrapper over Neo VM's opcode and its parameter.
type Preparator ¶
type Preparator struct {
// contains filtered or unexported fields
}
Preparator implements NotaryPreparator interface.
func (Preparator) Prepare ¶
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 ¶
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.