rpc

package
v0.0.7 Latest Latest
Warning

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

Go to latest
Published: Jan 28, 2025 License: MIT Imports: 22 Imported by: 0

Documentation

Index

Constants

View Source
const (
	GET_STATUS          = uint32(0)
	NEW_BLOCK           = uint32(1)
	NEW_BLOCK_ID        = uint32(2)
	NEW_TX              = uint32(3)
	GET_BLOCK_BY_ID     = uint32(4)
	GET_BLOCKS_FROM_NUM = uint32(5)
	GET_TXS             = uint32(6)
)

Variables

This section is empty.

Functions

func MsgName

func MsgName(msgType uint32) string

Types

type HandleBlockStream

type HandleBlockStream func(ctx context.Context, stream <-chan *block.EscortedBlock) error

HandleBlockStream to handle the stream of downloaded blocks in sync process.

type HandleQC

type HandleQC func(ctx context.Context, qc *block.QuorumCert) (bool, error)

type NewBlockEvent

type NewBlockEvent struct {
	*block.EscortedBlock
}

NewBlockEvent event emitted when received block announcement.

type RPC

type RPC interface {
	Notify(ctx context.Context, msgCode uint64, arg interface{}) error
	Call(ctx context.Context, msgCode uint64, arg interface{}, result interface{}) error
	String() string
	Info(msg string, ctx ...interface{})
	Debug(msg string, ctx ...interface{})
	Warn(msg string, ctx ...interface{})
}

RPC defines RPC interface.

type RPCServer

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

RPCServer represents the RPC server

func NewRPCServer

func NewRPCServer(p2pSrv p2p.P2P, c *chain.Chain, txPool *txpool.TxPool) *RPCServer

NewRPCServer creates a new RPC server

func (*RPCServer) GetBlockByID

func (s *RPCServer) GetBlockByID(pid peer.ID, id types.Bytes32) (*block.EscortedBlock, error)

GetBlockByID query block from remote peer by given block ID. It may return nil block even no error.

func (*RPCServer) GetBlocksFromNumber

func (s *RPCServer) GetBlocksFromNumber(pid peer.ID, num uint32) ([]*block.EscortedBlock, error)

GetBlocksFromNumber get a batch of blocks starts with num from remote peer.

func (*RPCServer) GetStatus

func (s *RPCServer) GetStatus(pid peer.ID) (*Status, error)

GetStatus get status of remote peer.

func (*RPCServer) GetTxs

func (s *RPCServer) GetTxs(pid peer.ID) (types.Transactions, error)

GetTxs get txs from remote peer.

func (*RPCServer) NotifyNewBlock

func (s *RPCServer) NotifyNewBlock(pid peer.ID, escortedBlk *block.EscortedBlock) error

NotifyNewBlock notify new block to remote peer.

func (*RPCServer) NotifyNewBlockID

func (s *RPCServer) NotifyNewBlockID(pid peer.ID, id types.Bytes32) error

NotifyNewBlockID notify new block ID to remote peer.

func (*RPCServer) NotifyNewTx

func (s *RPCServer) NotifyNewTx(pid peer.ID, tx cmttypes.Tx) error

NotifyNewTx notify new tx to remote peer.

func (*RPCServer) Reply

func (s *RPCServer) Reply(stream network.Stream, msgType uint32, content interface{}, isResponse bool) error

func (*RPCServer) Start

func (s *RPCServer) Start(ctx context.Context)

Start sets up the stream handler and starts listening

func (*RPCServer) Stop

func (s *RPCServer) Stop()

func (*RPCServer) Sync

func (s *RPCServer) Sync(handler HandleBlockStream)

Sync start synchronization process.

type Status

type Status struct {
	GenesisBlockID types.Bytes32
	SysTimestamp   uint64
	BestBlockID    types.Bytes32
	BestBlockNum   uint32
}

Status result of MsgGetStatus.

Jump to

Keyboard shortcuts

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