subscription

package
v0.0.0-...-c69f244 Latest Latest
Warning

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

Go to latest
Published: Jul 16, 2022 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

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

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

func (*AllBlocksListener) Listen

func (l *AllBlocksListener) Listen()

Listen start a goroutine to listen imported and finalised blocks

func (*AllBlocksListener) Stop

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

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

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

func (l *BlockListener) Stop() error

Stop to cancel the running goroutines to this listener

type BooleanResponse

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

BooleanResponse for responses that return boolean values

type Change

type Change [2]string

Change type defining key value pair representing change

type ChangeResult

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

ChangeResult struct to hold change result data

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

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

func (l *ExtrinsicSubmitListener) Stop() error

Stop to cancel the running goroutines to this listener

type GrandpaJustificationListener

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

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

func (*GrandpaJustificationListener) Listen

func (g *GrandpaJustificationListener) Listen()

Listen will start goroutines that listen to the finaised blocks

func (*GrandpaJustificationListener) Stop

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

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

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

func (*RuntimeVersionListener) Stop() error

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

type StorageObserver

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

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

func (*StorageObserver) GetFilter

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

GetFilter returns the filter the Observer is using

func (*StorageObserver) GetID

func (s *StorageObserver) GetID() uint

GetID the id for the Observer

func (*StorageObserver) Listen

func (*StorageObserver) Listen()

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

func (*StorageObserver) Stop

func (s *StorageObserver) Stop() error

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

func (*StorageObserver) Update

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

Update is called to notify observer of new value

type VersionListener

type VersionListener interface {
	GetChannelID() uint32
}

VersionListener interface defining methods that version listener must implement

type WSConn

type WSConn struct {
	UnsafeEnabled bool
	Wsconn        *websocket.Conn

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

WSConn struct to hold WebSocket Connection references

func (*WSConn) HandleConn

func (c *WSConn) HandleConn()

HandleConn handles messages received on websocket connections

type WSConnAPI

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