message

package
v0.3.11-alpha Latest Latest
Warning

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

Go to latest
Published: Sep 28, 2018 License: Apache-2.0 Imports: 26 Imported by: 0

Documentation

Index

Constants

View Source
const (
	MsgHdrLen      = 24
	MsgCmdLen      = 12
	MsgCmdOffset   = 4
	MsgChecksumLen = 4
	NetID          = 0x00000000
	MaxHdrCnt      = 500
	MaxInvHdrCnt   = 500
	HashLen        = 32
)
View Source
const (
	HTTPINFOFLAG = 0
)

Variables

View Source
var LastInvHash Uint256

Functions

func GetHeadersFromHash

func GetHeadersFromHash(startHash Uint256, stopHash Uint256) ([]ledger.Header, uint32, error)

func HandleNodeMsg

func HandleNodeMsg(node Noder, buf []byte, len int) error

FIXME the length exceed int32 case?

func MsgType

func MsgType(buf []byte) (string, error)

func NewAddrs

func NewAddrs(nodeaddrs []NodeAddr, count uint64) ([]byte, error)

func NewBlock

func NewBlock(bk *ledger.Block) ([]byte, error)

func NewBlockFromHash

func NewBlockFromHash(hash common.Uint256) (*ledger.Block, error)

func NewBlocksReq

func NewBlocksReq(n Noder) ([]byte, error)

func NewConsensus

func NewConsensus(cp *ConsensusPayload) ([]byte, error)

func NewHeaders

func NewHeaders(headers []ledger.Header, count uint32) ([]byte, error)

func NewHeadersReq

func NewHeadersReq(stopHash Uint256) ([]byte, error)

func NewInv

func NewInv(inv *InvPayload) ([]byte, error)

func NewIsingConsensus

func NewIsingConsensus(pld *IsingPayload) ([]byte, error)

func NewMsg

func NewMsg(t string, n Noder) ([]byte, error)

TODO combine all of message alloc in one function via interface

func NewNotFound

func NewNotFound(hash common.Uint256) ([]byte, error)

func NewPingMsg

func NewPingMsg(state SyncState) ([]byte, error)

func NewPongMsg

func NewPongMsg(state SyncState) ([]byte, error)

func NewTxn

func NewTxn(txn *transaction.Transaction) ([]byte, error)

func NewTxnFromHash

func NewTxnFromHash(hash common.Uint256) (*transaction.Transaction, error)

func NewVerack

func NewVerack() ([]byte, error)

func NewVersion

func NewVersion(n Noder) ([]byte, error)

func PayloadLen

func PayloadLen(buf []byte) int

func ReqBlkData

func ReqBlkData(node Noder, hash common.Uint256) error

func ReqTxnPool

func ReqTxnPool(node Noder) error

func SendMsgSyncHeaders

func SendMsgSyncHeaders(node Noder, stopHash Uint256)

func ValidMsgHdr

func ValidMsgHdr(buf []byte) bool

Types

type ConsensusPayload

type ConsensusPayload struct {
	Version         uint32
	PrevHash        common.Uint256
	Height          uint32
	BookKeeperIndex uint16
	Timestamp       int64
	Data            []byte
	Owner           *crypto.PubKey
	Program         *program.Program
	// contains filtered or unexported fields
}

func (*ConsensusPayload) Deserialize

func (cp *ConsensusPayload) Deserialize(r io.Reader) error

func (*ConsensusPayload) DeserializeUnsigned

func (cp *ConsensusPayload) DeserializeUnsigned(r io.Reader) error

func (*ConsensusPayload) GetMessage

func (cp *ConsensusPayload) GetMessage() []byte

func (*ConsensusPayload) GetProgramHashes

func (cp *ConsensusPayload) GetProgramHashes() ([]common.Uint160, error)

func (*ConsensusPayload) GetPrograms

func (cp *ConsensusPayload) GetPrograms() []*program.Program

func (*ConsensusPayload) Serialize

func (cp *ConsensusPayload) Serialize(w io.Writer) error

func (*ConsensusPayload) SerializeUnsigned

func (cp *ConsensusPayload) SerializeUnsigned(w io.Writer) error

func (*ConsensusPayload) SetPrograms

func (cp *ConsensusPayload) SetPrograms(programs []*program.Program)

func (*ConsensusPayload) ToArray

func (b *ConsensusPayload) ToArray() []byte

type Inv

type Inv struct {
	Hdr msgHdr
	P   InvPayload
}

func (*Inv) Deserialize

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

func (Inv) Handle

func (msg Inv) Handle(node Noder) error

func (Inv) Serialize

func (msg Inv) Serialize(w io.Writer) error

func (Inv) Verify

func (msg Inv) Verify(buf []byte) error

type InvPayload

type InvPayload struct {
	InvType InventoryType
	Cnt     uint32
	Blk     []byte
}

func GetInvFromBlockHash

func GetInvFromBlockHash(starthash Uint256, stophash Uint256) (*InvPayload, error)

func NewInvPayload

func NewInvPayload(invType InventoryType, count uint32, msg []byte) *InvPayload

func (*InvPayload) Serialize

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

type IsingMessage

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

func (*IsingMessage) Deserialize

func (p *IsingMessage) Deserialize(r io.Reader) error

func (IsingMessage) Handle

func (msg IsingMessage) Handle(node Noder) error

func (*IsingMessage) Serialize

func (p *IsingMessage) Serialize(w io.Writer) error

func (IsingMessage) Verify

func (hdr IsingMessage) Verify(buf []byte) error

Verify the message header information @p payload of the message

type IsingPayload

type IsingPayload struct {
	PayloadData []byte
	Sender      *crypto.PubKey
	Signature   []byte
}

func (*IsingPayload) DataHash

func (p *IsingPayload) DataHash() ([]byte, error)

func (*IsingPayload) Deserialize

func (p *IsingPayload) Deserialize(r io.Reader) error

func (*IsingPayload) DeserializeUnsigned

func (p *IsingPayload) DeserializeUnsigned(r io.Reader) error

func (*IsingPayload) Serialize

func (p *IsingPayload) Serialize(w io.Writer) error

func (*IsingPayload) SerializeUnsigned

func (p *IsingPayload) SerializeUnsigned(w io.Writer) error

type Messager

type Messager interface {
	Verify([]byte) error
	Handle(Noder) error
	serialization.SerializableData
}

func AllocMsg

func AllocMsg(t string, length int) Messager

Alloc different message stucture @t the message name or type @len the message length only valid for varible length structure

Return: @messager the messager interface @error error code FixMe fix the ugly multiple return.

type NotifyInfo

type NotifyInfo struct {
	Payload  *IsingPayload
	SenderID uint64
}

type RelayMessage

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

func NewRelayMessage

func NewRelayMessage(packet *RelayPacket) (*RelayMessage, error)

func (*RelayMessage) Deserialize

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

func (RelayMessage) Handle

func (msg RelayMessage) Handle(node protocol.Noder) error

func (*RelayMessage) Serialize

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

func (*RelayMessage) ToBytes

func (msg *RelayMessage) ToBytes() ([]byte, error)

func (RelayMessage) Verify

func (hdr RelayMessage) Verify(buf []byte) error

Verify the message header information @p payload of the message

type RelayPacket

type RelayPacket struct {
	SrcAddr  string
	DestID   []byte
	Payload  []byte
	SigChain *por.SigChain
}

func NewRelayPacket

func NewRelayPacket(srcAddr string, destID, payload []byte, sigChain *por.SigChain) (*RelayPacket, error)

func (*RelayPacket) Deserialize

func (packet *RelayPacket) Deserialize(r io.Reader) error

func (*RelayPacket) Serialize

func (packet *RelayPacket) Serialize(w io.Writer) error

Jump to

Keyboard shortcuts

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