Documentation ¶
Index ¶
Constants ¶
View Source
const ( NIL = MessageType(iota) // nil message type VERSION_TYPE //peer`s information VERACK_TYPE //ack msg after version recv GETADDR_TYPE //req nbr address from peer ADDR_TYPE //nbr address PING_TYPE //ping sync height PONG_TYPE //pong recv nbr height GET_HEADERS_TYPE //req blk hdr HEADERS_TYPE //blk hdr BLOCK_TYPE //blk payload TX_TYPE //transaction GET_BLOCK_TYPE //req blks from peer NOT_FOUND_TYPE //peer can`t find blk according to the hash REJECT_TYPE DISCONNECT_TYPE //peer disconnect info raise by link TRACE_TYPE //trace message )
View Source
const (
MAX_BLOCK_HEADER_NUM = 100
)
Variables ¶
View Source
var EmptyHash = types.Hash{}
Functions ¶
func EncodeMessage ¶
EncodeMessage encode message to byte array.
Types ¶
type Addr ¶
type Addr struct {
NetAddresses []*common.NetAddress `json:"net_addresses"`
}
func (*Addr) MsgType ¶
func (this *Addr) MsgType() MessageType
func (*Addr) ResponseMsgType ¶
func (this *Addr) ResponseMsgType() MessageType
type AddrReq ¶
type AddrReq struct{}
func (*AddrReq) MsgType ¶
func (this *AddrReq) MsgType() MessageType
func (*AddrReq) ResponseMsgType ¶
func (this *AddrReq) ResponseMsgType() MessageType
type Block ¶
Block block message
func (*Block) MsgType ¶
func (this *Block) MsgType() MessageType
func (*Block) ResponseMsgType ¶
func (this *Block) ResponseMsgType() MessageType
type BlockHeaderReq ¶
type BlockHeaderReq struct { Len uint8 `json:"len"` HashStart types.Hash `json:"hash_start"` HashStop types.Hash `json:"hash_stop"` }
BlockHeaderReq block request message
func (*BlockHeaderReq) MsgId ¶
func (this *BlockHeaderReq) MsgId() types.Hash
func (*BlockHeaderReq) MsgType ¶
func (this *BlockHeaderReq) MsgType() MessageType
func (*BlockHeaderReq) ResponseMsgType ¶
func (this *BlockHeaderReq) ResponseMsgType() MessageType
type BlockHeaders ¶
BlockHeaders block header message
func (*BlockHeaders) MsgId ¶
func (this *BlockHeaders) MsgId() types.Hash
func (*BlockHeaders) MsgType ¶
func (this *BlockHeaders) MsgType() MessageType
func (*BlockHeaders) ResponseMsgType ¶
func (this *BlockHeaders) ResponseMsgType() MessageType
type BlockReq ¶
BlockReq block request message
func (*BlockReq) MsgType ¶
func (this *BlockReq) MsgType() MessageType
func (*BlockReq) ResponseMsgType ¶
func (this *BlockReq) ResponseMsgType() MessageType
type Message ¶
type Message interface { MsgId() types.Hash MsgType() MessageType ResponseMsgType() MessageType }
type PingMsg ¶
type PingMsg struct {
State uint64
}
PingMsg ping message
func (*PingMsg) MsgType ¶
func (this *PingMsg) MsgType() MessageType
func (*PingMsg) ResponseMsgType ¶
func (this *PingMsg) ResponseMsgType() MessageType
type PongMsg ¶
type PongMsg struct {
State uint64
}
PongMsg pong message
func (*PongMsg) MsgType ¶
func (this *PongMsg) MsgType() MessageType
func (*PongMsg) ResponseMsgType ¶
func (this *PongMsg) ResponseMsgType() MessageType
type RejectMsg ¶
type RejectMsg struct {
Reason string
}
RejectMsg reject message
func (*RejectMsg) MsgType ¶
func (this *RejectMsg) MsgType() MessageType
func (*RejectMsg) ResponseMsgType ¶
func (this *RejectMsg) ResponseMsgType() MessageType
type TraceMsg ¶
type TraceMsg struct { ID types.Hash `json:"id"` Routes []*common.NetAddress `json:"routes"` }
DebugP2P is a test message, used to trace the message route in p2p.
func (*TraceMsg) MsgType ¶
func (this *TraceMsg) MsgType() MessageType
func (*TraceMsg) ResponseMsgType ¶
func (this *TraceMsg) ResponseMsgType() MessageType
type Transaction ¶
type Transaction struct {
Tx *types.Transaction `json:"tx"`
}
Transaction message
func (*Transaction) MsgId ¶
func (this *Transaction) MsgId() types.Hash
func (*Transaction) MsgType ¶
func (this *Transaction) MsgType() MessageType
func (*Transaction) ResponseMsgType ¶
func (this *Transaction) ResponseMsgType() MessageType
type Version ¶
type Version struct { Version string `json:"version"` PortMe int32 `json:"port_me"` Service config.ServiceFlag `json:"service"` }
Version version message
func (*Version) MsgType ¶
func (this *Version) MsgType() MessageType
func (*Version) ResponseMsgType ¶
func (this *Version) ResponseMsgType() MessageType
type VersionAck ¶
type VersionAck struct { }
Version ack message
func (*VersionAck) MsgId ¶
func (this *VersionAck) MsgId() types.Hash
func (*VersionAck) MsgType ¶
func (this *VersionAck) MsgType() MessageType
func (*VersionAck) ResponseMsgType ¶
func (this *VersionAck) ResponseMsgType() MessageType
Click to show internal directories.
Click to hide internal directories.