msg

package
v0.8.0 Latest Latest
Warning

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

Go to latest
Published: Oct 15, 2021 License: MIT Imports: 13 Imported by: 0

Documentation

Index

Constants

View Source
const (
	CmdVersion  = "version"
	CmdVerAck   = "verack"
	CmdAddr     = "addr"
	CmdPing     = "ping"
	CmdPong     = "pong"
	CmdInv      = "inv"
	CmdGetBlock = "getblock"

	CmdReceivedProposal            = "proposal"
	CmdAcceptVote                  = "acc_vote"
	CmdRejectVote                  = "rej_vote"
	CmdGetBlocks                   = "get_blc"
	CmdResponseBlocks              = "res_blc"
	CmdRequestConsensus            = "req_con"
	CmdResponseConsensus           = "res_con"
	CmdRequestProposal             = "req_pro"
	CmdIllegalProposals            = "ill_pro"
	CmdIllegalVotes                = "ill_vote"
	CmdSidechainIllegalData        = "side_ill"
	CmdResponseInactiveArbitrators = "ina_ars"
	CmdResponseRevertToDPOS        = "rev_to_dpos"
)
View Source
const DefaultProposalMessageDataSize = 168 //67+32+4+65
View Source
const DefaultResponseBlocksMessageDataSize = 8000000 * 10

todo move to config

View Source
const DefaultResponseConsensusMessageDataSize = 8000000 * 10
View Source
const DefaultVoteMessageDataSize = 297 //164+67+1+65
View Source
const MaxIllegalProposalSize = 1000000
View Source
const MaxIllegalVoteSize = 1000000
View Source
const ResponseInactiveArbitratorsLength = 32 + 33 + 64 + 8*2
View Source
const ResponseRevertToDPOSLength = 512

Variables

This section is empty.

Functions

func GetMessageHash

func GetMessageHash(msg p2p.Message) common.Uint256

Types

type Addr added in v0.3.2

type Addr struct {
	Host string
	Port uint16
}

Addr represents a DPoS network address for connect to a peer.

func NewAddr added in v0.3.2

func NewAddr(host string, port uint16) *Addr

func (*Addr) CMD added in v0.3.2

func (msg *Addr) CMD() string

func (*Addr) Deserialize added in v0.3.2

func (msg *Addr) Deserialize(r io.Reader) error

func (*Addr) MaxLength added in v0.3.2

func (msg *Addr) MaxLength() uint32

func (*Addr) Serialize added in v0.3.2

func (msg *Addr) Serialize(w io.Writer) error

type ConsensusStatus

type ConsensusStatus struct {
	ConsensusStatus uint32
	ViewOffset      uint32
	ViewStartTime   time.Time

	AcceptVotes      []payload.DPOSProposalVote
	RejectedVotes    []payload.DPOSProposalVote
	PendingProposals []payload.DPOSProposal
	PendingVotes     []payload.DPOSProposalVote
}

func (*ConsensusStatus) Deserialize

func (s *ConsensusStatus) Deserialize(r io.Reader) error

func (*ConsensusStatus) Serialize

func (s *ConsensusStatus) Serialize(w io.Writer) error

type GetBlock

type GetBlock struct {
	Inventory
}

func NewGetBlock

func NewGetBlock(blockHash common.Uint256) *GetBlock

func (*GetBlock) CMD

func (msg *GetBlock) CMD() string

type GetBlocks

type GetBlocks struct {
	StartBlockHeight uint32
	EndBlockHeight   uint32
}

func (*GetBlocks) CMD

func (msg *GetBlocks) CMD() string

func (*GetBlocks) Deserialize

func (msg *GetBlocks) Deserialize(r io.Reader) error

func (*GetBlocks) MaxLength

func (msg *GetBlocks) MaxLength() uint32

func (*GetBlocks) Serialize

func (msg *GetBlocks) Serialize(w io.Writer) error

type IllegalProposals

type IllegalProposals struct {
	Proposals payload.DPOSIllegalProposals
}

func (*IllegalProposals) CMD

func (msg *IllegalProposals) CMD() string

func (*IllegalProposals) Deserialize

func (msg *IllegalProposals) Deserialize(r io.Reader) error

func (*IllegalProposals) MaxLength

func (msg *IllegalProposals) MaxLength() uint32

func (*IllegalProposals) Serialize

func (msg *IllegalProposals) Serialize(w io.Writer) error

type IllegalVotes

type IllegalVotes struct {
	Votes payload.DPOSIllegalVotes
}

func (*IllegalVotes) CMD

func (msg *IllegalVotes) CMD() string

func (*IllegalVotes) Deserialize

func (msg *IllegalVotes) Deserialize(r io.Reader) error

func (*IllegalVotes) MaxLength

func (msg *IllegalVotes) MaxLength() uint32

func (*IllegalVotes) Serialize

func (msg *IllegalVotes) Serialize(w io.Writer) error

type Inventory

type Inventory struct {
	BlockHash common.Uint256
}

func NewInventory

func NewInventory(blockHash common.Uint256) *Inventory

func (*Inventory) CMD

func (msg *Inventory) CMD() string

func (*Inventory) Deserialize

func (msg *Inventory) Deserialize(reader io.Reader) error

func (*Inventory) MaxLength

func (msg *Inventory) MaxLength() uint32

func (*Inventory) Serialize

func (msg *Inventory) Serialize(writer io.Writer) error

type Ping

type Ping struct {
	Nonce uint64
}

func NewPing

func NewPing(nonce uint64) *Ping

func (*Ping) CMD

func (msg *Ping) CMD() string

func (*Ping) Deserialize

func (msg *Ping) Deserialize(reader io.Reader) error

func (*Ping) MaxLength

func (msg *Ping) MaxLength() uint32

func (*Ping) Serialize

func (msg *Ping) Serialize(writer io.Writer) error

type Pong

type Pong struct {
	Ping
}

func NewPong

func NewPong(nonce uint64) *Pong

func (*Pong) CMD

func (msg *Pong) CMD() string

type Proposal

type Proposal struct {
	Proposal payload.DPOSProposal
}

func (*Proposal) CMD

func (m *Proposal) CMD() string

func (*Proposal) Deserialize

func (m *Proposal) Deserialize(r io.Reader) error

func (*Proposal) MaxLength

func (m *Proposal) MaxLength() uint32

func (*Proposal) Serialize

func (m *Proposal) Serialize(w io.Writer) error

type Reject

type Reject struct {
	// Cmd is the command for the message which was rejected such as
	// as CmdBlock or CmdReject.  This can be obtained from the Command function
	// of a Message.
	Cmd string

	// RejectCode is a code indicating why the command was rejected.  It
	// is encoded as a uint8 on the wire.
	Code RejectCode

	// Reason is a human-readable string with specific details (over and
	// above the reject code) about why the command was rejected.
	Reason string

	// Hash identifies a specific block or transaction that was rejected
	// and therefore only applies the MsgBlock and MsgReject messages.
	Hash common.Uint256
}

func NewReject

func NewReject(cmd string, code RejectCode, reason string) *Reject

func (*Reject) CMD

func (msg *Reject) CMD() string

func (*Reject) Deserialize

func (msg *Reject) Deserialize(r io.Reader) (err error)

func (*Reject) MaxLength

func (msg *Reject) MaxLength() uint32

func (*Reject) Serialize

func (msg *Reject) Serialize(w io.Writer) error

type RejectCode

type RejectCode uint8

RejectCode represents a numeric value by which a remote peer indicates why a message was rejected.

const (
	RejectMalformed       RejectCode = 0x01
	RejectInvalid         RejectCode = 0x10
	RejectObsolete        RejectCode = 0x11
	RejectDuplicate       RejectCode = 0x12
	RejectNonstandard     RejectCode = 0x40
	RejectDust            RejectCode = 0x41
	RejectInsufficientFee RejectCode = 0x42
	RejectCheckpoint      RejectCode = 0x43
)

These constants define the various supported reject codes.

func (RejectCode) String

func (code RejectCode) String() string

String returns the RejectCode in human-readable form.

type RequestConsensus

type RequestConsensus struct {
	Height uint32
}

func (*RequestConsensus) CMD

func (msg *RequestConsensus) CMD() string

func (*RequestConsensus) Deserialize

func (msg *RequestConsensus) Deserialize(r io.Reader) error

func (*RequestConsensus) MaxLength

func (msg *RequestConsensus) MaxLength() uint32

func (*RequestConsensus) Serialize

func (msg *RequestConsensus) Serialize(w io.Writer) error

type RequestProposal

type RequestProposal struct {
	ProposalHash common.Uint256
}

func (*RequestProposal) CMD

func (msg *RequestProposal) CMD() string

func (*RequestProposal) Deserialize

func (msg *RequestProposal) Deserialize(r io.Reader) error

func (*RequestProposal) MaxLength

func (msg *RequestProposal) MaxLength() uint32

func (*RequestProposal) Serialize

func (msg *RequestProposal) Serialize(w io.Writer) error

type ResponseBlocks

type ResponseBlocks struct {
	Command       string
	BlockConfirms []*types.DposBlock
}

func (*ResponseBlocks) CMD

func (m *ResponseBlocks) CMD() string

func (*ResponseBlocks) Deserialize

func (m *ResponseBlocks) Deserialize(r io.Reader) error

func (*ResponseBlocks) MaxLength

func (m *ResponseBlocks) MaxLength() uint32

func (*ResponseBlocks) Serialize

func (m *ResponseBlocks) Serialize(w io.Writer) error

type ResponseConsensus

type ResponseConsensus struct {
	Consensus ConsensusStatus
}

func (*ResponseConsensus) CMD

func (msg *ResponseConsensus) CMD() string

func (*ResponseConsensus) Deserialize

func (msg *ResponseConsensus) Deserialize(r io.Reader) error

func (*ResponseConsensus) MaxLength

func (msg *ResponseConsensus) MaxLength() uint32

func (*ResponseConsensus) Serialize

func (msg *ResponseConsensus) Serialize(w io.Writer) error

type ResponseInactiveArbitrators added in v0.3.0

type ResponseInactiveArbitrators struct {
	TxHash common.Uint256
	Signer []byte
	Sign   []byte
}

func (*ResponseInactiveArbitrators) CMD added in v0.3.0

func (*ResponseInactiveArbitrators) Deserialize added in v0.3.0

func (i *ResponseInactiveArbitrators) Deserialize(r io.Reader) (err error)

func (*ResponseInactiveArbitrators) DeserializeUnsigned added in v0.3.0

func (i *ResponseInactiveArbitrators) DeserializeUnsigned(r io.Reader) (err error)

func (*ResponseInactiveArbitrators) MaxLength added in v0.3.0

func (i *ResponseInactiveArbitrators) MaxLength() uint32

func (*ResponseInactiveArbitrators) Serialize added in v0.3.0

func (i *ResponseInactiveArbitrators) Serialize(w io.Writer) error

func (*ResponseInactiveArbitrators) SerializeUnsigned added in v0.3.0

func (i *ResponseInactiveArbitrators) SerializeUnsigned(w io.Writer) error

type ResponseRevertToDPOS added in v0.7.0

type ResponseRevertToDPOS struct {
	TxHash common.Uint256
	Signer []byte
	Sign   []byte
}

func (*ResponseRevertToDPOS) CMD added in v0.7.0

func (i *ResponseRevertToDPOS) CMD() string

func (*ResponseRevertToDPOS) Deserialize added in v0.7.0

func (i *ResponseRevertToDPOS) Deserialize(r io.Reader) (err error)

func (*ResponseRevertToDPOS) DeserializeUnsigned added in v0.7.0

func (i *ResponseRevertToDPOS) DeserializeUnsigned(r io.Reader) (err error)

func (*ResponseRevertToDPOS) MaxLength added in v0.7.0

func (i *ResponseRevertToDPOS) MaxLength() uint32

func (*ResponseRevertToDPOS) Serialize added in v0.7.0

func (i *ResponseRevertToDPOS) Serialize(w io.Writer) error

func (*ResponseRevertToDPOS) SerializeUnsigned added in v0.7.0

func (i *ResponseRevertToDPOS) SerializeUnsigned(w io.Writer) error

type SidechainIllegalData added in v0.3.0

type SidechainIllegalData struct {
	Data payload.SidechainIllegalData
}

func (*SidechainIllegalData) CMD added in v0.3.0

func (msg *SidechainIllegalData) CMD() string

func (*SidechainIllegalData) Deserialize added in v0.3.0

func (msg *SidechainIllegalData) Deserialize(r io.Reader) error

func (*SidechainIllegalData) MaxLength added in v0.3.0

func (msg *SidechainIllegalData) MaxLength() uint32

func (*SidechainIllegalData) Serialize added in v0.3.0

func (msg *SidechainIllegalData) Serialize(w io.Writer) error

type VerAck

type VerAck struct {
	Signature [64]byte
}

func NewVerAck

func NewVerAck(signature []byte) *VerAck

func (*VerAck) CMD

func (msg *VerAck) CMD() string

func (*VerAck) Deserialize

func (msg *VerAck) Deserialize(r io.Reader) error

func (*VerAck) MaxLength

func (msg *VerAck) MaxLength() uint32

func (*VerAck) Serialize

func (msg *VerAck) Serialize(w io.Writer) error

type Version

type Version struct {
	PID       [33]byte
	Target    [16]byte
	Nonce     [16]byte
	Port      uint16
	Timestamp time.Time
}

func NewVersion

func NewVersion(pid [33]byte, target, nonce [16]byte, port uint16) *Version

func (*Version) CMD

func (msg *Version) CMD() string

func (*Version) Deserialize

func (msg *Version) Deserialize(r io.Reader) error

func (*Version) MaxLength

func (msg *Version) MaxLength() uint32

func (*Version) Serialize

func (msg *Version) Serialize(w io.Writer) error

type Vote

type Vote struct {
	Command string
	Vote    payload.DPOSProposalVote
}

func (*Vote) CMD

func (msg *Vote) CMD() string

func (*Vote) Deserialize

func (msg *Vote) Deserialize(r io.Reader) error

func (*Vote) MaxLength

func (msg *Vote) MaxLength() uint32

func (*Vote) Serialize

func (msg *Vote) Serialize(w io.Writer) error

Jump to

Keyboard shortcuts

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