messages

package
v0.0.0-...-829742f Latest Latest
Warning

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

Go to latest
Published: Aug 28, 2022 License: AGPL-3.0 Imports: 6 Imported by: 0

Documentation

Index

Constants

View Source
const (
	BlockchainChannel = byte(0x40)

	BlockRequestByte    = byte(0x10)
	BlockResponseByte   = byte(0x11)
	HeadersRequestByte  = byte(0x12)
	HeadersResponseByte = byte(0x13)
	BlocksRequestByte   = byte(0x14)
	BlocksResponseByte  = byte(0x15)
	StatusByte          = byte(0x21)
	NewTransactionByte  = byte(0x30)
	NewTransactionsByte = byte(0x31)
	NewMineBlockByte    = byte(0x40)
	FilterLoadByte      = byte(0x50)
	FilterAddByte       = byte(0x51)
	FilterClearByte     = byte(0x52)
	MerkleRequestByte   = byte(0x60)
	MerkleResponseByte  = byte(0x61)

	MaxBlockchainResponseSize = 22020096 + 2
	TxsMsgMaxTxNum            = 1024
)

protocol msg byte

Variables

This section is empty.

Functions

This section is empty.

Types

type BlockMessage

type BlockMessage struct {
	RawBlock []byte
}

BlockMessage response get block msg

func NewBlockMessage

func NewBlockMessage(block *types.Block) (*BlockMessage, error)

NewBlockMessage construct bock response msg

func (*BlockMessage) GetBlock

func (m *BlockMessage) GetBlock() (*types.Block, error)

GetBlock get block from msg

func (*BlockMessage) String

func (m *BlockMessage) String() string

type BlockchainMessage

type BlockchainMessage interface {
	String() string
}

BlockchainMessage is a generic message for this reactor.

type BlocksMessage

type BlocksMessage struct {
	RawBlocks [][]byte
}

BlocksMessage is one of the janeta msg type

func NewBlocksMessage

func NewBlocksMessage(blocks []*types.Block) (*BlocksMessage, error)

NewBlocksMessage create a new BlocksMessage

func (*BlocksMessage) GetBlocks

func (m *BlocksMessage) GetBlocks() ([]*types.Block, error)

GetBlocks returns the blocks in the msg

func (*BlocksMessage) String

func (m *BlocksMessage) String() string

type FilterAddMessage

type FilterAddMessage struct {
	Address []byte
}

FilterAddMessage tells the receiving peer to add address to the filter.

func (*FilterAddMessage) String

func (m *FilterAddMessage) String() string

type FilterClearMessage

type FilterClearMessage struct{}

FilterClearMessage tells the receiving peer to remove a previously-set filter.

func (*FilterClearMessage) String

func (m *FilterClearMessage) String() string

type FilterLoadMessage

type FilterLoadMessage struct {
	Addresses [][]byte
}

FilterLoadMessage tells the receiving peer to filter the transactions according to address.

func (*FilterLoadMessage) String

func (m *FilterLoadMessage) String() string

type GetBlockMessage

type GetBlockMessage struct {
	Height  uint64
	RawHash [32]byte
}

GetBlockMessage request blocks from remote peers by height/hash

func (*GetBlockMessage) GetHash

func (m *GetBlockMessage) GetHash() *bc.Hash

GetHash reutrn the hash of the request

func (*GetBlockMessage) String

func (m *GetBlockMessage) String() string

type GetBlocksMessage

type GetBlocksMessage struct {
	RawBlockLocator [][32]byte
	RawStopHash     [32]byte
}

GetBlocksMessage is one of the janeta msg type

func NewGetBlocksMessage

func NewGetBlocksMessage(blockLocator []*bc.Hash, stopHash *bc.Hash) *GetBlocksMessage

NewGetBlocksMessage create a new GetBlocksMessage

func (*GetBlocksMessage) GetBlockLocator

func (m *GetBlocksMessage) GetBlockLocator() []*bc.Hash

GetBlockLocator return the locator of the msg

func (*GetBlocksMessage) GetStopHash

func (m *GetBlocksMessage) GetStopHash() *bc.Hash

GetStopHash return the stop hash of the msg

func (*GetBlocksMessage) String

func (m *GetBlocksMessage) String() string

type GetHeadersMessage

type GetHeadersMessage struct {
	RawBlockLocator [][32]byte
	RawStopHash     [32]byte
	Skip            uint64
}

GetHeadersMessage is one of the janeta msg type

func NewGetHeadersMessage

func NewGetHeadersMessage(blockLocator []*bc.Hash, stopHash *bc.Hash, skip uint64) *GetHeadersMessage

NewGetHeadersMessage return a new GetHeadersMessage

func (*GetHeadersMessage) GetBlockLocator

func (m *GetHeadersMessage) GetBlockLocator() []*bc.Hash

GetBlockLocator return the locator of the msg

func (*GetHeadersMessage) GetSkip

func (m *GetHeadersMessage) GetSkip() uint64

func (*GetHeadersMessage) GetStopHash

func (m *GetHeadersMessage) GetStopHash() *bc.Hash

GetStopHash return the stop hash of the msg

func (*GetHeadersMessage) String

func (m *GetHeadersMessage) String() string

type GetMerkleBlockMessage

type GetMerkleBlockMessage struct {
	Height  uint64
	RawHash [32]byte
}

GetMerkleBlockMessage request merkle blocks from remote peers by height/hash

func (*GetMerkleBlockMessage) GetHash

func (m *GetMerkleBlockMessage) GetHash() *bc.Hash

GetHash reutrn the hash of the request

func (*GetMerkleBlockMessage) String

func (m *GetMerkleBlockMessage) String() string

type HeadersMessage

type HeadersMessage struct {
	RawHeaders [][]byte
}

HeadersMessage is one of the janeta msg type

func NewHeadersMessage

func NewHeadersMessage(headers []*types.BlockHeader) (*HeadersMessage, error)

NewHeadersMessage create a new HeadersMessage

func (*HeadersMessage) GetHeaders

func (m *HeadersMessage) GetHeaders() ([]*types.BlockHeader, error)

GetHeaders return the headers in the msg

func (*HeadersMessage) String

func (m *HeadersMessage) String() string

type MerkleBlockMessage

type MerkleBlockMessage struct {
	RawBlockHeader []byte
	TxHashes       [][32]byte
	RawTxDatas     [][]byte
	Flags          []byte
}

MerkleBlockMessage return the merkle block to client

func NewMerkleBlockMessage

func NewMerkleBlockMessage() *MerkleBlockMessage

NewMerkleBlockMessage construct merkle block message

func (*MerkleBlockMessage) SetRawBlockHeader

func (m *MerkleBlockMessage) SetRawBlockHeader(bh types.BlockHeader) error

func (*MerkleBlockMessage) SetTxInfo

func (m *MerkleBlockMessage) SetTxInfo(txHashes []*bc.Hash, txFlags []uint8, relatedTxs []*types.Tx) error

func (*MerkleBlockMessage) String

func (m *MerkleBlockMessage) String() string

type MineBlockMessage

type MineBlockMessage struct {
	RawBlock []byte
}

MineBlockMessage new mined block msg

func NewMinedBlockMessage

func NewMinedBlockMessage(block *types.Block) (*MineBlockMessage, error)

NewMinedBlockMessage construct new mined block msg

func (*MineBlockMessage) GetMineBlock

func (m *MineBlockMessage) GetMineBlock() (*types.Block, error)

GetMineBlock get mine block from msg

func (*MineBlockMessage) String

func (m *MineBlockMessage) String() string

type StatusMessage

type StatusMessage struct {
	BestHeight      uint64
	BestHash        [32]byte
	JustifiedHeight uint64
	JustifiedHash   [32]byte
}

StatusResponseMessage get status response msg

func NewStatusMessage

func NewStatusMessage(bestHeader, justifiedHeader *types.BlockHeader) *StatusMessage

NewStatusResponseMessage construct get status response msg

func (*StatusMessage) GetBestHash

func (m *StatusMessage) GetBestHash() *bc.Hash

GetHash get hash from msg

func (*StatusMessage) GetIrreversibleHash

func (m *StatusMessage) GetIrreversibleHash() *bc.Hash

func (*StatusMessage) String

func (m *StatusMessage) String() string

type TransactionMessage

type TransactionMessage struct {
	RawTx []byte
}

TransactionMessage notify new tx msg

func NewTransactionMessage

func NewTransactionMessage(tx *types.Tx) (*TransactionMessage, error)

NewTransactionMessage construct notify new tx msg

func (*TransactionMessage) GetTransaction

func (m *TransactionMessage) GetTransaction() (*types.Tx, error)

GetTransaction get tx from msg

func (*TransactionMessage) String

func (m *TransactionMessage) String() string

type TransactionsMessage

type TransactionsMessage struct {
	RawTxs [][]byte
}

TransactionsMessage notify new txs msg

func NewTransactionsMessage

func NewTransactionsMessage(txs []*types.Tx) (*TransactionsMessage, error)

NewTransactionsMessage construct notify new txs msg

func (*TransactionsMessage) GetTransactions

func (m *TransactionsMessage) GetTransactions() ([]*types.Tx, error)

GetTransactions get txs from msg

func (*TransactionsMessage) String

func (m *TransactionsMessage) String() string

Jump to

Keyboard shortcuts

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