subscription

package
v0.9.0 Latest Latest
Warning

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

Go to latest
Published: Mar 1, 2024 License: LGPL-3.0 Imports: 21 Imported by: 0

Documentation

Index

Constants

View Source
const InvalidRequestCode = -32600

InvalidRequestCode error code returned for invalid request parameters, value derived from Substrate node output

View Source
const InvalidRequestMessage = "Invalid request"

InvalidRequestMessage error message for invalid request parameters

Variables

View Source
var (
	// ErrCannotCancel when is not possible to cancel a goroutine after `cancelTimeout` seconds
	ErrCannotCancel = errors.New("cannot cancel listening goroutines")
)

Functions

This section is empty.

Types

type AllBlocksListener added in v0.7.0

type AllBlocksListener struct {
	// contains filtered or unexported fields
}

AllBlocksListener is a listener that is aware of new and newly finalised blocks```

func (*AllBlocksListener) Listen added in v0.7.0

func (l *AllBlocksListener) Listen()

Listen start a goroutine to listen imported and finalised blocks

func (*AllBlocksListener) Stop added in v0.7.0

func (l *AllBlocksListener) Stop() error

Stop will unregister the imported chanells and stop the goroutine

type BaseResponseJSON

type BaseResponseJSON struct {
	Jsonrpc string `json:"jsonrpc"`
	Method  string `json:"method"`
	Params  Params `json:"params"`
}

BaseResponseJSON for base json response

type BlockAPI added in v0.8.0

type BlockAPI interface {
	GetJustification(hash common.Hash) ([]byte, error)
	GetImportedBlockNotifierChannel() chan *types.Block
	FreeImportedBlockNotifierChannel(ch chan *types.Block)
	GetFinalisedNotifierChannel() chan *types.FinalisationInfo
	FreeFinalisedNotifierChannel(ch chan *types.FinalisationInfo)
	RegisterRuntimeUpdatedChannel(ch chan<- runtime.Version) (uint32, error)
}

BlockAPI is the interface for the block state

type BlockFinalizedListener

type BlockFinalizedListener struct {
	// contains filtered or unexported fields
}

BlockFinalizedListener to handle listening for finalised blocks

func (*BlockFinalizedListener) Listen

func (l *BlockFinalizedListener) Listen()

Listen implementation of Listen interface to listen for importedChan changes

func (*BlockFinalizedListener) Stop added in v0.7.0

func (l *BlockFinalizedListener) Stop() error

Stop to cancel the running goroutines to this listener

type BlockListener

type BlockListener struct {
	Channel chan *types.Block
	// contains filtered or unexported fields
}

BlockListener to handle listening for blocks importedChan

func NewBlockListener added in v0.7.0

func NewBlockListener(conn *WSConn) *BlockListener

NewBlockListener constructor for creating BlockListener

func (*BlockListener) Listen

func (l *BlockListener) Listen()

Listen implementation of Listen interface to listen for importedChan changes

func (*BlockListener) Stop added in v0.7.0

func (l *BlockListener) Stop() error

Stop to cancel the running goroutines to this listener

type BooleanResponse added in v0.7.0

type BooleanResponse struct {
	JSONRPC string  `json:"jsonrpc"`
	Result  bool    `json:"result"`
	ID      float64 `json:"id"`
}

BooleanResponse for responses that return boolean values

type Change added in v0.7.0

type Change [2]string

Change type defining key value pair representing change

type ChangeResult added in v0.7.0

type ChangeResult struct {
	Changes []Change `json:"changes"`
	Block   string   `json:"block"`
}

ChangeResult struct to hold change result data

type CoreAPI added in v0.8.0

type CoreAPI interface {
	GetRuntimeVersion(bhash *common.Hash) (runtime.Version, error)
	HandleSubmittedExtrinsic(types.Extrinsic) error
}

CoreAPI is the interface for the core methods

type ErrorMessageJSON

type ErrorMessageJSON struct {
	Code    *big.Int `json:"code"`
	Message string   `json:"message"`
}

ErrorMessageJSON json for error messages

type ErrorResponseJSON

type ErrorResponseJSON struct {
	Jsonrpc string            `json:"jsonrpc"`
	Error   *ErrorMessageJSON `json:"error"`
	ID      float64           `json:"id"`
}

ErrorResponseJSON json for error responses

type ExtrinsicSubmitListener

type ExtrinsicSubmitListener struct {
	// contains filtered or unexported fields
}

ExtrinsicSubmitListener to handle listening for extrinsic events

func NewExtrinsicSubmitListener added in v0.7.0

func NewExtrinsicSubmitListener(conn *WSConn, extBytes []byte,
	importedChan chan *types.Block, txStatusChan chan transaction.Status,
	finalisedChan chan *types.FinalisationInfo) *ExtrinsicSubmitListener

NewExtrinsicSubmitListener constructor to build new ExtrinsicSubmitListener

func (*ExtrinsicSubmitListener) Listen

func (l *ExtrinsicSubmitListener) Listen()

Listen implementation of Listen interface to listen for importedChan changes

func (*ExtrinsicSubmitListener) Stop added in v0.7.0

func (l *ExtrinsicSubmitListener) Stop() error

Stop to cancel the running goroutines to this listener

type GrandpaJustificationListener added in v0.7.0

type GrandpaJustificationListener struct {
	// contains filtered or unexported fields
}

GrandpaJustificationListener struct has the finalisedCh and the context to stop the goroutines

func (*GrandpaJustificationListener) Listen added in v0.7.0

func (g *GrandpaJustificationListener) Listen()

Listen will start goroutines that listen to the finaised blocks

func (*GrandpaJustificationListener) Stop added in v0.7.0

Stop will cancel all the goroutines that are executing

type Listener

type Listener interface {
	Listen()
	Stop() error
}

Listener interface for functions that define Listener related functions

type Params

type Params struct {
	Result         interface{} `json:"result"`
	SubscriptionID uint32      `json:"subscription"`
}

Params for json param response

type ResponseJSON

type ResponseJSON struct {
	Jsonrpc string  `json:"jsonrpc"`
	Result  uint32  `json:"result"`
	ID      float64 `json:"id"`
}

ResponseJSON for json subscription responses

func NewSubscriptionResponseJSON added in v0.7.0

func NewSubscriptionResponseJSON(subID uint32, reqID float64) ResponseJSON

NewSubscriptionResponseJSON builds a Response JSON object

type RuntimeVersionListener

type RuntimeVersionListener struct {
	// contains filtered or unexported fields
}

RuntimeVersionListener to handle listening for Runtime Version

func (*RuntimeVersionListener) GetChannelID added in v0.7.0

func (l *RuntimeVersionListener) GetChannelID() uint32

GetChannelID function that returns listener's channel ID

func (*RuntimeVersionListener) Listen

func (l *RuntimeVersionListener) Listen()

Listen implementation of Listen interface to listen for runtime version changes

func (*RuntimeVersionListener) Stop added in v0.7.0

func (*RuntimeVersionListener) Stop() error

Stop to runtimeVersionListener not implemented yet because the listener does not need to be stoped

type StorageAPI added in v0.8.0

type StorageAPI interface {
	RegisterStorageObserver(observer state.Observer)
	UnregisterStorageObserver(observer state.Observer)
}

StorageAPI is the interface for the storage state

type StorageObserver added in v0.7.0

type StorageObserver struct {
	// contains filtered or unexported fields
}

StorageObserver struct to hold data for observer (Observer Design Pattern)

func (*StorageObserver) GetFilter added in v0.7.0

func (s *StorageObserver) GetFilter() map[string][]byte

GetFilter returns the filter the Observer is using

func (*StorageObserver) GetID added in v0.7.0

func (s *StorageObserver) GetID() uint

GetID the id for the Observer

func (*StorageObserver) Listen added in v0.7.0

func (*StorageObserver) Listen()

Listen to satisfy Listener interface (but is no longer used by StorageObserver)

func (*StorageObserver) Stop added in v0.7.0

func (s *StorageObserver) Stop() error

Stop to satisfy Listener interface (but is no longer used by StorageObserver)

func (*StorageObserver) Update added in v0.7.0

func (s *StorageObserver) Update(change *state.SubscriptionResult)

Update is called to notify observer of new value

type TransactionStateAPI added in v0.8.0

type TransactionStateAPI interface {
	GetStatusNotifierChannel(ext types.Extrinsic) chan transaction.Status
	FreeStatusNotifierChannel(ch chan transaction.Status)
}

TransactionStateAPI is the interface to get and free status notifier channels

type WSConn

type WSConn struct {
	UnsafeEnabled bool
	Wsconn        *websocket.Conn

	Subscriptions map[uint32]Listener
	StorageAPI    StorageAPI
	BlockAPI      BlockAPI
	CoreAPI       CoreAPI
	TxStateAPI    TransactionStateAPI
	RPCHost       string
	HTTP          httpclient
	// contains filtered or unexported fields
}

WSConn struct to hold WebSocket Connection references

func (*WSConn) HandleConn added in v0.7.0

func (c *WSConn) HandleConn()

HandleConn handles messages received on websocket connections

type WSConnAPI added in v0.7.0

type WSConnAPI interface {
	// contains filtered or unexported methods
}

WSConnAPI interface defining methors a WSConn should have

Jump to

Keyboard shortcuts

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