msg

package
v0.2.2 Latest Latest
Warning

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

Go to latest
Published: Feb 19, 2019 License: MIT Imports: 8 Imported by: 0

Documentation

Index

Constants

View Source
const (
	CmdVersion = "version"
	CmdVerAck  = "verack"
	CmdPing    = "ping"
	CmdPong    = "pong"

	CmdInv      = "inventory"
	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"
)
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

Variables

This section is empty.

Functions

func GetMessageHash

func GetMessageHash(msg p2p.Message) common.Uint256

Types

type ConsensusStatus

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

	AcceptVotes      []types.DPosProposalVote
	RejectedVotes    []types.DPosProposalVote
	PendingProposals []types.DPosProposal
	PendingVotes     []types.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 types.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 types.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 types.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 VerAck

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

func NewVerAck

func NewVerAck() *VerAck

func (*VerAck) CMD

func (msg *VerAck) CMD() string

func (*VerAck) Deserialize

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

func (*VerAck) MaxLength

func (msg *VerAck) MaxLength() uint32

func (*VerAck) Serialize

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

type Version

type Version struct {
	Version   uint32
	Services  uint64
	PID       [33]byte
	Nonce     [32]byte
	Signature [64]byte
}

func NewVersion

func NewVersion(pver uint32, services uint64, pid [33]byte,
	nonce [32]byte, signature [64]byte) *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    types.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