rpc

package
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: Sep 24, 2024 License: Apache-2.0 Imports: 13 Imported by: 0

Documentation

Index

Constants

View Source
const (
	ServerKindWS  = "websocket"
	ServerKindRPC = "http"
)

Variables

This section is empty.

Functions

This section is empty.

Types

type BlockCache

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

func (*BlockCache) Add

func (cache *BlockCache) Add(block dto.Block)

func (*BlockCache) Get

func (cache *BlockCache) Get(number uint64) (*dto.Block, bool)

func (*BlockCache) GetByHash

func (cache *BlockCache) GetByHash(hash string) (*dto.Block, bool)

type RPCClient

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

func NewRPCClient

func NewRPCClient(log *logrus.Logger, endpoints endpoint.Provider, blockCacheSize int) *RPCClient

func (*RPCClient) ChainGetBlock

func (w *RPCClient) ChainGetBlock(ctx context.Context, hash string) (*dto.Block, error)

TODO: rewrite

func (*RPCClient) ChainGetBlockHash

func (w *RPCClient) ChainGetBlockHash(ctx context.Context, num uint64) (string, error)

func (*RPCClient) ChainGetHeader

func (w *RPCClient) ChainGetHeader(ctx context.Context, hash string) (dto.Mapped, error)

func (*RPCClient) ChainSubscribeJustifications

func (w *RPCClient) ChainSubscribeJustifications(ctx context.Context) (chan *dto.RPCFrame, chan error)

func (*RPCClient) ChainSubscribeNewHead

func (w *RPCClient) ChainSubscribeNewHead(ctx context.Context) (chan *dto.RPCFrame, chan error)

func (*RPCClient) FindExtrinsicsBlock

func (w *RPCClient) FindExtrinsicsBlock(ctx context.Context, blockHash string, extrinsic string, limit int) (*dto.Block, error)

func (*RPCClient) GetAliveServer

func (w *RPCClient) GetAliveServer(kind string) string

func (*RPCClient) GetOrCreateConnection

func (w *RPCClient) GetOrCreateConnection(ctx context.Context) (*WSMessageBroker, error)

func (*RPCClient) NewConnectionContext

func (w *RPCClient) NewConnectionContext(ctx context.Context, name string) context.Context

Returns context that can be used later for RPC requests

func (*RPCClient) RawRequest

func (w *RPCClient) RawRequest(msg string) (*dto.RPCFrame, error)

func (*RPCClient) ReleaseConnection

func (w *RPCClient) ReleaseConnection(ctx context.Context)

func (*RPCClient) StateGetMetadata

func (w *RPCClient) StateGetMetadata(ctx context.Context) (string, error)

func (*RPCClient) StateGetStorage

func (w *RPCClient) StateGetStorage(ctx context.Context, request *decoder.StorageRequest, blockHash string) (string, error)

func (*RPCClient) WithConnection

func (w *RPCClient) WithConnection(ctx context.Context, server string, do func(*websocket.Conn) error) error

type WSMessageBroker

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

func NewWSMessageBroker

func NewWSMessageBroker(ctx context.Context, log *logrus.Logger, conn *websocket.Conn) *WSMessageBroker

func (*WSMessageBroker) Subscribe

func (broker *WSMessageBroker) Subscribe(ctx context.Context, req *dto.RPCFrame) (chan *dto.RPCFrame, chan error)

Submit and subscribe on server pushes

func (*WSMessageBroker) WSRequest

func (broker *WSMessageBroker) WSRequest(ctx context.Context, req *dto.RPCFrame) (*dto.RPCFrame, error)

Simple request wihtout need to watch server-side pushes

type WSMessageBrokerFrame

type WSMessageBrokerFrame struct {
	Frame *dto.RPCFrame
	Error error
	// contains filtered or unexported fields
}

Jump to

Keyboard shortcuts

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