message

package
v1.6.0 Latest Latest
Warning

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

Go to latest
Published: Nov 13, 2024 License: MIT Imports: 15 Imported by: 0

Documentation

Index

Constants

View Source
const (
	ResponseCodeOK           = ResponseCode(0)
	ResponseCodeRejected     = ResponseCode(1)
	ResponseCodeMoreBlocks   = ResponseCode(2)
	ResponseCodeNoMoreBlocks = ResponseCode(3)
	ResponseCodeSynced       = ResponseCode(4)
)
View Source
const (
	TypeHello          = Type(1)
	TypeHelloAck       = Type(2)
	TypeTransaction    = Type(3)
	TypeQueryProposal  = Type(4)
	TypeProposal       = Type(5)
	TypeQueryVote      = Type(6)
	TypeVote           = Type(7)
	TypeBlockAnnounce  = Type(8)
	TypeBlocksRequest  = Type(9)
	TypeBlocksResponse = Type(10)
)

Variables

This section is empty.

Functions

This section is empty.

Types

type BasicCheckError added in v1.5.0

type BasicCheckError struct {
	Reason string
}

BasicCheckError is returned when the basic check on the message fails.

func (BasicCheckError) Error added in v1.5.0

func (e BasicCheckError) Error() string

type BlockAnnounceMessage

type BlockAnnounceMessage struct {
	Block       *block.Block                  `cbor:"1,keyasint"`
	Certificate *certificate.BlockCertificate `cbor:"2,keyasint"`
}

func NewBlockAnnounceMessage

func NewBlockAnnounceMessage(blk *block.Block, cert *certificate.BlockCertificate) *BlockAnnounceMessage

func (*BlockAnnounceMessage) BasicCheck added in v0.15.0

func (m *BlockAnnounceMessage) BasicCheck() error

func (*BlockAnnounceMessage) Height

func (m *BlockAnnounceMessage) Height() uint32

func (*BlockAnnounceMessage) ShouldBroadcast added in v1.4.0

func (*BlockAnnounceMessage) ShouldBroadcast() bool

func (*BlockAnnounceMessage) String added in v0.15.0

func (m *BlockAnnounceMessage) String() string

func (*BlockAnnounceMessage) TopicID added in v1.4.0

func (*BlockAnnounceMessage) Type

func (*BlockAnnounceMessage) Type() Type

type BlocksRequestMessage

type BlocksRequestMessage struct {
	SessionID int    `cbor:"1,keyasint"`
	From      uint32 `cbor:"2,keyasint"`
	Count     uint32 `cbor:"3,keyasint"`
}

func NewBlocksRequestMessage

func NewBlocksRequestMessage(sid int, from, count uint32) *BlocksRequestMessage

func (*BlocksRequestMessage) BasicCheck added in v0.15.0

func (m *BlocksRequestMessage) BasicCheck() error

func (*BlocksRequestMessage) ShouldBroadcast added in v1.4.0

func (*BlocksRequestMessage) ShouldBroadcast() bool

func (*BlocksRequestMessage) String added in v0.15.0

func (m *BlocksRequestMessage) String() string

func (*BlocksRequestMessage) To

func (m *BlocksRequestMessage) To() uint32

func (*BlocksRequestMessage) TopicID added in v1.4.0

func (*BlocksRequestMessage) Type

func (*BlocksRequestMessage) Type() Type

type BlocksResponseMessage

type BlocksResponseMessage struct {
	ResponseCode    ResponseCode                  `cbor:"1,keyasint"`
	SessionID       int                           `cbor:"2,keyasint"`
	From            uint32                        `cbor:"3,keyasint"`
	BlocksData      [][]byte                      `cbor:"4,keyasint"`
	LastCertificate *certificate.BlockCertificate `cbor:"5,keyasint"`
	Reason          string                        `cbor:"6,keyasint"`
}

func NewBlocksResponseMessage

func NewBlocksResponseMessage(code ResponseCode, reason string, sid int, from uint32,
	blocksData [][]byte, lastCert *certificate.BlockCertificate,
) *BlocksResponseMessage

func (*BlocksResponseMessage) BasicCheck added in v0.15.0

func (m *BlocksResponseMessage) BasicCheck() error

func (*BlocksResponseMessage) Count added in v0.11.0

func (m *BlocksResponseMessage) Count() uint32

func (*BlocksResponseMessage) IsRequestRejected

func (m *BlocksResponseMessage) IsRequestRejected() bool

func (*BlocksResponseMessage) ShouldBroadcast added in v1.4.0

func (*BlocksResponseMessage) ShouldBroadcast() bool

func (*BlocksResponseMessage) String added in v0.15.0

func (m *BlocksResponseMessage) String() string

func (*BlocksResponseMessage) To

func (m *BlocksResponseMessage) To() uint32

func (*BlocksResponseMessage) TopicID added in v1.4.0

func (*BlocksResponseMessage) Type

func (*BlocksResponseMessage) Type() Type

type HelloAckMessage added in v0.15.0

type HelloAckMessage struct {
	ResponseCode ResponseCode `cbor:"1,keyasint"`
	Reason       string       `cbor:"2,keyasint"`
	Height       uint32       `cbor:"3,keyasint"`
}

func NewHelloAckMessage added in v0.15.0

func NewHelloAckMessage(code ResponseCode, reason string, height uint32) *HelloAckMessage

func (*HelloAckMessage) BasicCheck added in v0.15.0

func (*HelloAckMessage) BasicCheck() error

func (*HelloAckMessage) ShouldBroadcast added in v1.4.0

func (*HelloAckMessage) ShouldBroadcast() bool

func (*HelloAckMessage) String added in v0.15.0

func (m *HelloAckMessage) String() string

func (*HelloAckMessage) TopicID added in v1.4.0

func (*HelloAckMessage) TopicID() network.TopicID

func (*HelloAckMessage) Type added in v0.15.0

func (*HelloAckMessage) Type() Type

type HelloMessage

type HelloMessage struct {
	PeerID          peer.ID          `cbor:"1,keyasint"`
	Agent           string           `cbor:"2,keyasint"`
	Moniker         string           `cbor:"3,keyasint"`
	PublicKeys      []*bls.PublicKey `cbor:"4,keyasint"`
	Signature       *bls.Signature   `cbor:"5,keyasint"`
	Height          uint32           `cbor:"6,keyasint"`
	Services        service.Services `cbor:"7,keyasint"`
	GenesisHash     hash.Hash        `cbor:"8,keyasint"`
	BlockHash       hash.Hash        `cbor:"9,keyasint"`
	MyTimeUnixMilli int64            `cbor:"10,keyasint"`
}

func NewHelloMessage

func NewHelloMessage(pid peer.ID, moniker string,
	services service.Services, height uint32, blockHash, genesisHash hash.Hash,
) *HelloMessage

func (*HelloMessage) BasicCheck added in v0.15.0

func (m *HelloMessage) BasicCheck() error

func (*HelloMessage) MyTime added in v0.15.0

func (m *HelloMessage) MyTime() time.Time

func (*HelloMessage) ShouldBroadcast added in v1.4.0

func (*HelloMessage) ShouldBroadcast() bool

func (*HelloMessage) Sign added in v0.15.0

func (m *HelloMessage) Sign(valKeys []*bls.ValidatorKey)

func (*HelloMessage) SignBytes

func (m *HelloMessage) SignBytes() []byte

func (*HelloMessage) String added in v0.15.0

func (m *HelloMessage) String() string

func (*HelloMessage) TopicID added in v1.4.0

func (*HelloMessage) TopicID() network.TopicID

func (*HelloMessage) Type

func (*HelloMessage) Type() Type

type InvalidMessageTypeError added in v1.5.0

type InvalidMessageTypeError struct {
	Type int
}

InvalidMessageTypeError is returned when the message type is not valid.

func (InvalidMessageTypeError) Error added in v1.5.0

func (e InvalidMessageTypeError) Error() string

type Message

type Message interface {
	BasicCheck() error
	Type() Type
	TopicID() network.TopicID
	ShouldBroadcast() bool
	String() string
}

func MakeMessage

func MakeMessage(msgType Type) (Message, error)

type ProposalMessage

type ProposalMessage struct {
	Proposal *proposal.Proposal `cbor:"1,keyasint"`
}

func NewProposalMessage

func NewProposalMessage(p *proposal.Proposal) *ProposalMessage

func (*ProposalMessage) BasicCheck added in v0.15.0

func (*ProposalMessage) BasicCheck() error

func (*ProposalMessage) ShouldBroadcast added in v1.4.0

func (*ProposalMessage) ShouldBroadcast() bool

func (*ProposalMessage) String added in v0.15.0

func (m *ProposalMessage) String() string

func (*ProposalMessage) TopicID added in v1.4.0

func (*ProposalMessage) TopicID() network.TopicID

func (*ProposalMessage) Type

func (*ProposalMessage) Type() Type

type QueryProposalMessage

type QueryProposalMessage struct {
	Height  uint32         `cbor:"1,keyasint"`
	Round   int16          `cbor:"3,keyasint"`
	Querier crypto.Address `cbor:"2,keyasint"`
}

func NewQueryProposalMessage

func NewQueryProposalMessage(height uint32, round int16, querier crypto.Address) *QueryProposalMessage

func (*QueryProposalMessage) BasicCheck added in v0.15.0

func (m *QueryProposalMessage) BasicCheck() error

func (*QueryProposalMessage) ShouldBroadcast added in v1.4.0

func (*QueryProposalMessage) ShouldBroadcast() bool

func (*QueryProposalMessage) String added in v0.15.0

func (m *QueryProposalMessage) String() string

func (*QueryProposalMessage) TopicID added in v1.4.0

func (*QueryProposalMessage) Type

func (*QueryProposalMessage) Type() Type

type QueryVoteMessage added in v1.4.0

type QueryVoteMessage struct {
	Height  uint32         `cbor:"1,keyasint"`
	Round   int16          `cbor:"2,keyasint"`
	Querier crypto.Address `cbor:"3,keyasint"`
}

func NewQueryVoteMessage added in v1.4.0

func NewQueryVoteMessage(height uint32, round int16, querier crypto.Address) *QueryVoteMessage

func (*QueryVoteMessage) BasicCheck added in v1.4.0

func (m *QueryVoteMessage) BasicCheck() error

func (*QueryVoteMessage) ShouldBroadcast added in v1.4.0

func (*QueryVoteMessage) ShouldBroadcast() bool

func (*QueryVoteMessage) String added in v1.4.0

func (m *QueryVoteMessage) String() string

func (*QueryVoteMessage) TopicID added in v1.4.0

func (*QueryVoteMessage) TopicID() network.TopicID

func (*QueryVoteMessage) Type added in v1.4.0

func (*QueryVoteMessage) Type() Type

type ResponseCode

type ResponseCode int

func (ResponseCode) String

func (c ResponseCode) String() string

type TransactionsMessage

type TransactionsMessage struct {
	Transactions []*tx.Tx `cbor:"1,keyasint"`
}

func NewTransactionsMessage

func NewTransactionsMessage(trxs []*tx.Tx) *TransactionsMessage

func (*TransactionsMessage) BasicCheck added in v0.15.0

func (m *TransactionsMessage) BasicCheck() error

func (*TransactionsMessage) ShouldBroadcast added in v1.4.0

func (*TransactionsMessage) ShouldBroadcast() bool

func (*TransactionsMessage) String added in v0.15.0

func (m *TransactionsMessage) String() string

func (*TransactionsMessage) TopicID added in v1.4.0

func (*TransactionsMessage) TopicID() network.TopicID

func (*TransactionsMessage) Type

func (*TransactionsMessage) Type() Type

type Type

type Type int32

func (Type) String

func (t Type) String() string

type VoteMessage

type VoteMessage struct {
	Vote *vote.Vote `cbor:"1,keyasint"`
}

func NewVoteMessage

func NewVoteMessage(v *vote.Vote) *VoteMessage

func (*VoteMessage) BasicCheck added in v0.15.0

func (m *VoteMessage) BasicCheck() error

func (*VoteMessage) ShouldBroadcast added in v1.4.0

func (*VoteMessage) ShouldBroadcast() bool

func (*VoteMessage) String added in v0.15.0

func (m *VoteMessage) String() string

func (*VoteMessage) TopicID added in v1.4.0

func (*VoteMessage) TopicID() network.TopicID

func (*VoteMessage) Type

func (*VoteMessage) Type() Type

Jump to

Keyboard shortcuts

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