Documentation ¶
Index ¶
- Constants
- type BlockSyncMgr
- type P2PServer
- func (this *P2PServer) GetConnectionCnt() uint32
- func (this *P2PServer) GetConnectionState() uint32
- func (this *P2PServer) GetID() uint64
- func (this *P2PServer) GetNeighborAddrs() []common.PeerAddr
- func (this *P2PServer) GetNetWork() p2pnet.P2P
- func (this *P2PServer) GetPID() *evtActor.PID
- func (this *P2PServer) GetPort() (uint16, uint16)
- func (this *P2PServer) GetTime() int64
- func (this *P2PServer) GetVersion() uint32
- func (this *P2PServer) OnAddNode(id uint64)
- func (this *P2PServer) OnBlockReceive(block *types.Block)
- func (this *P2PServer) OnDelNode(id uint64)
- func (this *P2PServer) OnHeaderReceive(headers []*types.Header)
- func (this *P2PServer) Send(p *peer.Peer, msg msgtypes.Message, isConsensus bool) error
- func (this *P2PServer) SetPID(pid *evtActor.PID)
- func (this *P2PServer) Start() error
- func (this *P2PServer) Stop()
- func (this *P2PServer) WaitForPeersStart()
- func (this *P2PServer) WaitForSyncBlkFinish()
- func (this *P2PServer) Xmit(message interface{}) error
- type ReconnectAddrs
- type SyncFlightInfo
- func (this *SyncFlightInfo) GetFailedTimes(nodeId uint64) int
- func (this *SyncFlightInfo) GetNodeId() uint64
- func (this *SyncFlightInfo) GetStartTime() time.Time
- func (this *SyncFlightInfo) GetTotalFailedTimes() int
- func (this *SyncFlightInfo) MarkFailedNode()
- func (this *SyncFlightInfo) ResetStartTime()
- func (this *SyncFlightInfo) SetNodeId(nodeId uint64)
Constants ¶
const ( SYNC_MAX_HEADER_FORWARD_SIZE = 5000 //keep CurrentHeaderHeight - CurrentBlockHeight <= SYNC_MAX_HEADER_FORWARD_SIZE SYNC_MAX_FLIGHT_HEADER_SIZE = 1 //Number of headers on flight SYNC_MAX_FLIGHT_BLOCK_SIZE = 50 //Number of blocks on flight SYNC_MAX_BLOCK_CACHE_SIZE = 500 //Cache size of block wait to commit to ledger SYNC_HEADER_REQUEST_TIMEOUT = 10 //s, Request header timeout time. If header haven't receive after SYNC_HEADER_REQUEST_TIMEOUT second, retry SYNC_BLOCK_REQUEST_TIMEOUT = 15 //s, Request block timeout time. If block haven't received after SYNC_BLOCK_REQUEST_TIMEOUT second, retry )
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type BlockSyncMgr ¶
type BlockSyncMgr struct {
// contains filtered or unexported fields
}
BlockSyncMgr is the manager class to deal with block sync
func NewBlockSyncMgr ¶
func NewBlockSyncMgr(server *P2PServer) *BlockSyncMgr
NewBlockSyncMgr return a BlockSyncMgr instance
func (*BlockSyncMgr) OnAddNode ¶
func (this *BlockSyncMgr) OnAddNode(nodeId uint64)
OnAddNode to node list when a new node added
func (*BlockSyncMgr) OnBlockReceive ¶
func (this *BlockSyncMgr) OnBlockReceive(block *types.Block)
OnBlockReceive receive block from net
func (*BlockSyncMgr) OnDelNode ¶
func (this *BlockSyncMgr) OnDelNode(nodeId uint64)
OnDelNode remove from node list. When the node disconnect
func (*BlockSyncMgr) OnHeaderReceive ¶
func (this *BlockSyncMgr) OnHeaderReceive(headers []*types.Header)
OnHeaderReceive receive header from net
type P2PServer ¶
type P2PServer struct { ReconnectAddrs // contains filtered or unexported fields }
P2PServer control all network activities
func (*P2PServer) GetConnectionCnt ¶
GetConnectionCnt return the established connect count
func (*P2PServer) GetConnectionState ¶
Todo: remove it if no use
func (*P2PServer) GetNeighborAddrs ¶
GetNeighborAddrs return all nbr`s address
func (*P2PServer) GetNetWork ¶
GetNetWork returns the low level netserver
func (*P2PServer) GetVersion ¶
GetVersion return self version
func (*P2PServer) OnBlockReceive ¶
OnBlockReceive adds the block from network
func (*P2PServer) OnHeaderReceive ¶
OnHeaderReceive adds the header list from network
func (*P2PServer) Stop ¶
func (this *P2PServer) Stop()
Stop halt all service by send signal to channels
func (*P2PServer) WaitForPeersStart ¶
func (this *P2PServer) WaitForPeersStart()
WaitForPeersStart check whether enough peer linked in loop
func (*P2PServer) WaitForSyncBlkFinish ¶
func (this *P2PServer) WaitForSyncBlkFinish()
WaitForSyncBlkFinish compare the height of self and remote peer in loop
type ReconnectAddrs ¶
ReconnectAddrs contain addr need to reconnect
type SyncFlightInfo ¶
type SyncFlightInfo struct { Height uint32 //BlockHeight of HeaderHeight // contains filtered or unexported fields }
SyncFlightInfo record the info of fight object(header or block)
func NewSyncFlightInfo ¶
func NewSyncFlightInfo(height uint32, nodeId uint64) *SyncFlightInfo
NewSyncFlightInfo return a new SyncFlightInfo instance
func (*SyncFlightInfo) GetFailedTimes ¶
func (this *SyncFlightInfo) GetFailedTimes(nodeId uint64) int
GetFailedTimes return failed times of a node
func (*SyncFlightInfo) GetNodeId ¶
func (this *SyncFlightInfo) GetNodeId() uint64
GetNodeId return current node id for sending msg
func (*SyncFlightInfo) GetStartTime ¶
func (this *SyncFlightInfo) GetStartTime() time.Time
GetStartTime return the start time of request
func (*SyncFlightInfo) GetTotalFailedTimes ¶
func (this *SyncFlightInfo) GetTotalFailedTimes() int
GetTotalFailedTimes return the total failed times of request
func (*SyncFlightInfo) MarkFailedNode ¶
func (this *SyncFlightInfo) MarkFailedNode()
MarkFailedNode mark node failed, after request timeout
func (*SyncFlightInfo) SetNodeId ¶
func (this *SyncFlightInfo) SetNodeId(nodeId uint64)
SetNodeId set a new node id