common

package
v0.9.3 Latest Latest
Warning

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

Go to latest
Published: Jun 27, 2018 License: LGPL-3.0 Imports: 3 Imported by: 45

Documentation

Index

Constants

View Source
const (
	VERIFY_NODE  = 1 //peer involved in consensus
	SERVICE_NODE = 2 //peer only sync with consensus peer
)

peer capability

View Source
const (
	PER_SEND_LEN   = 1024 * 256 //byte len per conn write
	MAX_BUF_LEN    = 1024 * 256 //the maximum buffer to receive message
	WRITE_DEADLINE = 5          //deadline of conn write
)

link and concurrent const

View Source
const (
	MSG_CMD_LEN      = 12               //msg type length in byte
	CMD_OFFSET       = 4                //cmd type offet in msg hdr
	CHECKSUM_LEN     = 4                //checksum length in byte
	HASH_LEN         = 32               // hash length in byte
	MSG_HDR_LEN      = 24               //msg hdr length in byte
	MAX_BLK_HDR_CNT  = 500              //hdr count once when sync header
	MAX_INV_HDR_CNT  = 500              //inventory count once when req inv
	MAX_REQ_BLK_ONCE = 16               //req blk count once from one peer when sync blk
	MAX_MSG_LEN      = 30 * 1024 * 1024 //the maximum message length
	MAX_PAYLOAD_LEN  = MAX_MSG_LEN - MSG_HDR_LEN
)

msg cmd const

View Source
const (
	MAX_ADDR_NODE_CNT = 64 //the maximum peer address from msg
	MAX_INV_BLK_CNT   = 64 //the maximum blk hash cnt of inv msg
)

msg type const

View Source
const (
	PROTOCOL_VERSION      = 0     //protocol version
	UPDATE_RATE_PER_BLOCK = 2     //info update rate in one generate block period
	KEEPALIVE_TIMEOUT     = 15    //contact timeout in sec
	DIAL_TIMEOUT          = 6     //connect timeout in sec
	CONN_MONITOR          = 6     //time to retry connect in sec
	CONN_MAX_BACK         = 4000  //max backoff time in micro sec
	MAX_RETRY_COUNT       = 3     //max reconnect time of remote peer
	CHAN_CAPABILITY       = 10000 //channel capability of recv link
	SYNC_BLK_WAIT         = 2     //timespan for blk sync check
)

info update const

View Source
const (
	INIT        = 0 //initial
	HAND        = 1 //send verion to peer
	HAND_SHAKE  = 2 //haven`t send verion to peer and receive peer`s version
	HAND_SHAKED = 3 //send verion to peer and receive peer`s version
	ESTABLISH   = 4 //receive peer`s verack
	INACTIVITY  = 5 //link broken
)

The peer state

View Source
const (
	RECENT_TIMEOUT   = 60
	RECENT_FILE_NAME = "peers.recent"
	RECENT_LIMIT     = 10 //recent contact list limit
)

recent contact const

View Source
const (
	VERSION_TYPE     = "version"    //peer`s information
	VERACK_TYPE      = "verack"     //ack msg after version recv
	GetADDR_TYPE     = "getaddr"    //req nbr address from peer
	ADDR_TYPE        = "addr"       //nbr address
	PING_TYPE        = "ping"       //ping  sync height
	PONG_TYPE        = "pong"       //pong  recv nbr height
	GET_HEADERS_TYPE = "getheaders" //req blk hdr
	HEADERS_TYPE     = "headers"    //blk hdr
	INV_TYPE         = "inv"        //inv payload
	GET_DATA_TYPE    = "getdata"    //req data from peer
	BLOCK_TYPE       = "block"      //blk payload
	TX_TYPE          = "tx"         //transaction
	CONSENSUS_TYPE   = "consensus"  //consensus payload
	GET_BLOCKS_TYPE  = "getblocks"  //req blks from peer
	NOT_FOUND_TYPE   = "notfound"   //peer can`t find blk according to the hash
	DISCONNECT_TYPE  = "disconnect" //peer disconnect info raise by link
)

const channel msg id and type

View Source
const (
	ACTOR_TIMEOUT = 5 //actor request timeout in secs
)

actor const

View Source
const (
	HTTP_INFO_FLAG = 0 //peer`s http info bit in cap field
)

cap flag

Variables

This section is empty.

Functions

func ParseIPAddr added in v0.9.2

func ParseIPAddr(s string) (string, error)

ParseIPAddr return ip address

Types

type AppendBlock

type AppendBlock struct {
	Block *types.Block // Block to be added to the ledger
}

type AppendHeaders

type AppendHeaders struct {
	Headers []*types.Header // Headers to be added to the ledger
}

type AppendPeerID

type AppendPeerID struct {
	ID uint64 // The peer id
}

type PeerAddr

type PeerAddr struct {
	Time          int64    //latest timestamp
	Services      uint64   //service type
	IpAddr        [16]byte //ip address
	Port          uint16   //sync port
	ConsensusPort uint16   //consensus port
	ID            uint64   //Unique ID
}

PeerAddr represent peer`s net information

type RemovePeerID

type RemovePeerID struct {
	ID uint64 // The peer id
}

Jump to

Keyboard shortcuts

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