event

package
v0.38.1 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Sep 18, 2023 License: GPL-3.0 Imports: 28 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
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")

	// ErrUnknownEvent is returned if main transaction is not expected.
	ErrUnknownEvent = errors.New("received notary request is not allowed")
)

Functions

func BytesFromOpcode added in v0.25.0

func BytesFromOpcode(op Op) ([]byte, error)

BytesFromOpcode tries to retrieve bytes from Op.

func IntFromOpcode added in v0.25.0

func IntFromOpcode(op Op) (int64, error)

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

func StringFromOpcode(op Op) (string, error)

StringFromOpcode tries to retrieve string from Op.

func UnexpectedArgNumErr added in v0.25.0

func UnexpectedArgNumErr(method string) error

UnexpectedArgNumErr returns error when notary parsers get unexpected amount of argument in contract call.

func UnexpectedOpcode added in v0.25.0

func UnexpectedOpcode(method string, op opcode.Opcode) error

UnexpectedOpcode returns error when notary parsers get unexpected opcode in contract call.

func WrongNumberOfParameters

func WrongNumberOfParameters(exp, act int) error

WrongNumberOfParameters returns an error about wrong number of smart contract parameters.

Types

type BlockCounter added in v0.25.0

type BlockCounter interface {
	BlockCount() (res uint32, err error)
}

BlockCounter must return block count of the network from which notary requests are received.

type BlockHandler added in v0.15.0

type BlockHandler func(*block.Block)

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

func WorkerPoolHandler(w util2.WorkerPool, h Handler, log *zap.Logger) Handler

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 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

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.

func (Op) Code added in v0.25.0

func (o Op) Code() opcode.Opcode

Code returns Neo VM opcode.

func (Op) Param added in v0.25.0

func (o Op) Param() []byte

Param returns parameter of wrapped Neo VM opcode.

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.

type Type

type Type string

Type is a notification event enumeration type.

func TypeFromBytes

func TypeFromBytes(data []byte) Type

TypeFromBytes converts bytes slice to Type.

func TypeFromString

func TypeFromString(str string) Type

TypeFromString converts string to Type.

func (Type) Equal

func (t Type) Equal(t2 Type) bool

Equal compares two Type values and returns true if they are equal.

func (Type) String

func (t Type) String() string

String returns casted to string Type.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL