Documentation ¶
Index ¶
- Constants
- Variables
- func NewInboundHSHandler(pm p2pcommon.PeerManager, actor p2pcommon.ActorService, ...) p2pcommon.HSHandler
- func NewOutboundHSHandler(pm p2pcommon.PeerManager, actor p2pcommon.ActorService, ...) p2pcommon.HSHandler
- func NewPeerFinder(logger *log.Logger, pm *peerManager, actorService p2pcommon.ActorService, ...) p2pcommon.PeerFinder
- func NewPeerManager(is p2pcommon.InternalService, hsFactory p2pcommon.HSHandlerFactory, ...) p2pcommon.PeerManager
- func NewWaitingPeerManager(logger *log.Logger, is p2pcommon.InternalService, pm *peerManager, ...) p2pcommon.WaitingPeerManager
- func SetupSelfMeta(peerID types.PeerID, conf *config.P2PConfig, produceBlock bool) p2pcommon.PeerMeta
- type AncestorReceiver
- type BlockHashByNoReceiver
- type BlockHashesReceiver
- type BlocksChunkReceiver
- type By
- type ConnWork
- type DPOSAgentRoleManager
- type DPOSRoleManager
- func (rm *DPOSRoleManager) CheckRole(remoteInfo p2pcommon.RemoteInfo, newRole types.PeerRole) bool
- func (rm *DPOSRoleManager) FilterBPNoticeReceiver(block *types.Block, pm p2pcommon.PeerManager, targetZone p2pcommon.PeerZone) []p2pcommon.RemotePeer
- func (rm *DPOSRoleManager) FilterNewBlockNoticeReceiver(block *types.Block, pm p2pcommon.PeerManager) []p2pcommon.RemotePeer
- func (rm *DPOSRoleManager) GetRole(pid types.PeerID) types.PeerRole
- func (rm *DPOSRoleManager) SelfRole() types.PeerRole
- func (rm *DPOSRoleManager) Start()
- func (rm *DPOSRoleManager) Stop()
- func (rm *DPOSRoleManager) UpdateBP(toAdd []types.PeerID, toRemove []types.PeerID)
- type GetTxsReceiver
- type InboundWireHandshaker
- type OutboundWireHandshaker
- type P2P
- func (p2ps *P2P) AfterStart()
- func (p2ps *P2P) BeforeStart()
- func (p2ps *P2P) BeforeStop()
- func (p2ps *P2P) CallRequest(actor string, msg interface{}, timeout time.Duration) (interface{}, error)
- func (p2ps *P2P) CallRequestDefaultTimeout(actor string, msg interface{}) (interface{}, error)
- func (p2ps *P2P) CertificateManager() p2pcommon.CertificateManager
- func (p2ps *P2P) ConsensusAccessor() consensus.ConsensusAccessor
- func (p2ps *P2P) CreateHSHandler(outbound bool, pid types.PeerID) p2pcommon.HSHandler
- func (p2ps *P2P) CreateRemotePeer(remoteInfo p2pcommon.RemoteInfo, seq uint32, rw p2pcommon.MsgReadWriter) p2pcommon.RemotePeer
- func (p2ps *P2P) FutureRequest(actor string, msg interface{}, timeout time.Duration) *actor.Future
- func (p2ps *P2P) FutureRequestDefaultTimeout(actor string, msg interface{}) *actor.Future
- func (p2ps *P2P) GenesisChainID() *types.ChainID
- func (p2ps *P2P) GetAddresses(peerID types.PeerID, size uint32) bool
- func (p2ps *P2P) GetBlockHashByNo(context actor.Context, msg *message.GetHashByNo)
- func (p2ps *P2P) GetBlockHashes(context actor.Context, msg *message.GetHashes)
- func (p2ps *P2P) GetBlockHeaders(msg *message.GetBlockHeaders) bool
- func (p2ps *P2P) GetBlocks(peerID types.PeerID, blockHashes []message.BlockHash) bool
- func (p2ps *P2P) GetBlocksChunk(context actor.Context, msg *message.GetBlockChunks)
- func (p2ps *P2P) GetChainAccessor() types.ChainAccessor
- func (p2ps *P2P) GetNetworkTransport() p2pcommon.NetworkTransport
- func (p2ps *P2P) GetPeer(ID types.PeerID) (p2pcommon.RemotePeer, bool)
- func (p2ps *P2P) GetPeerAccessor() p2pcommon.PeerAccessor
- func (p2ps *P2P) GetPeerBlockInfos() []types.PeerBlockInfo
- func (p2ps *P2P) GetSyncAncestor(context actor.Context, msg *message.GetSyncAncestor)
- func (p2ps *P2P) GetTXs(peerID types.PeerID, txHashes []message.TXHash) bool
- func (p2ps *P2P) LocalSettings() p2pcommon.LocalSettings
- func (p2ps *P2P) NotifyBlockProduced(blockNotice message.NotifyNewBlock) bool
- func (p2ps *P2P) NotifyCertRenewed(context actor.Context, renewed message.NotifyCertRenewed)
- func (p2ps *P2P) NotifyNewBlock(blockNotice message.NotifyNewBlock) bool
- func (p2ps *P2P) NotifyNewTX(msg *message.NotifyNewTransactions) bool
- func (p2ps *P2P) PeerManager() p2pcommon.PeerManager
- func (p2ps *P2P) Receive(context actor.Context)
- func (p2ps *P2P) RoleManager() p2pcommon.PeerRoleManager
- func (p2ps *P2P) SelfMeta() p2pcommon.PeerMeta
- func (p2ps *P2P) SelfNodeID() types.PeerID
- func (p2ps *P2P) SendIssueCertMessage(context actor.Context, msg message.IssueAgentCertificate)
- func (p2ps *P2P) SendRaftMessage(context actor.Context, msg *message.SendRaft)
- func (p2ps *P2P) SendRequest(actor string, msg interface{})
- func (p2ps *P2P) SetConsensusAccessor(ca consensus.ConsensusAccessor)
- func (p2ps *P2P) Statistics() *map[string]interface{}
- func (p2ps *P2P) TellRequest(actor string, msg interface{})
- func (p2ps *P2P) TossBPNotice(msg message.TossBPNotice) bool
- type RaftRoleManager
- func (rm *RaftRoleManager) CheckRole(remoteInfo p2pcommon.RemoteInfo, newRole types.PeerRole) bool
- func (rm *RaftRoleManager) FilterBPNoticeReceiver(block *types.Block, pm p2pcommon.PeerManager, targetZone p2pcommon.PeerZone) []p2pcommon.RemotePeer
- func (rm *RaftRoleManager) FilterNewBlockNoticeReceiver(block *types.Block, pm p2pcommon.PeerManager) []p2pcommon.RemotePeer
- func (rm *RaftRoleManager) GetRole(pid types.PeerID) types.PeerRole
- func (rm *RaftRoleManager) SelfRole() types.PeerRole
- func (rm *RaftRoleManager) Start()
- func (rm *RaftRoleManager) Stop()
- func (rm *RaftRoleManager) UpdateBP(toAdd []types.PeerID, toRemove []types.PeerID)
Constants ¶
const ( DiscoveryQueryInterval = time.Minute * 1 MaxAddrListSizePolaris = 200 MaxAddrListSizePeer = 50 )
constants for node discovery
const ( DefaultGlobalBlockCacheSize = 300 DefaultPeerBlockCacheSize = 100 DefaultGlobalTxCacheSize = 40000 DefaultPeerTxCacheSize = 10000 // DefaultPeerTxQueueSize is maximum size of hashes in a single tx notice message DefaultPeerTxQueueSize = 2000 )
constants for caching TODO this value better related to max peer and block produce interval, not constant
const ( GapToSkipAll = 86400 GapToSkipHourly = 3600 GapToSkip5Min = 300 HourlyInterval = time.Hour TenMinutesInterval = time.Minute * 10 MinNewBlkNoticeInterval = time.Second >> 2 )
constants for block notice tuning
const ( BP voteRank = iota Candidate )
Variables ¶
var CancelError = errors.New("canceled")
var TimeoutError = errors.New("timeout")
Functions ¶
func NewInboundHSHandler ¶
func NewInboundHSHandler(pm p2pcommon.PeerManager, actor p2pcommon.ActorService, verManager p2pcommon.VersionedManager, log *log.Logger, chainID *types.ChainID, peerID types.PeerID) p2pcommon.HSHandler
func NewOutboundHSHandler ¶
func NewOutboundHSHandler(pm p2pcommon.PeerManager, actor p2pcommon.ActorService, verManager p2pcommon.VersionedManager, log *log.Logger, chainID *types.ChainID, peerID types.PeerID) p2pcommon.HSHandler
func NewPeerFinder ¶
func NewPeerFinder(logger *log.Logger, pm *peerManager, actorService p2pcommon.ActorService, maxCap int, useDiscover, usePolaris bool) p2pcommon.PeerFinder
func NewPeerManager ¶
func NewPeerManager(is p2pcommon.InternalService, hsFactory p2pcommon.HSHandlerFactory, actor p2pcommon.ActorService, pf p2pcommon.PeerFactory, nt p2pcommon.NetworkTransport, mm metric.MetricsManager, lm p2pcommon.ListManager, logger *log.Logger, cfg *cfg.Config, skipHandshakeSync bool) p2pcommon.PeerManager
NewPeerManager creates a peer manager object.
func NewWaitingPeerManager ¶
func NewWaitingPeerManager(logger *log.Logger, is p2pcommon.InternalService, pm *peerManager, lm p2pcommon.ListManager, maxCap int, useDiscover bool) p2pcommon.WaitingPeerManager
Types ¶
type AncestorReceiver ¶
type AncestorReceiver struct {
// contains filtered or unexported fields
}
BlocksChunkReceiver is send p2p getBlocksRequest to target peer and receive p2p responses till all requests blocks are received It will send response actor message if all blocks are received or failed to receive, but not send response if timeout expired.
func NewAncestorReceiver ¶
func NewAncestorReceiver(actor p2pcommon.ActorService, peer p2pcommon.RemotePeer, seq uint64, hashes [][]byte, ttl time.Duration) *AncestorReceiver
func (*AncestorReceiver) ReceiveResp ¶
func (br *AncestorReceiver) ReceiveResp(msg p2pcommon.Message, msgBody p2pcommon.MessageBody) (ret bool)
ReceiveResp must be called just in read go routine
func (*AncestorReceiver) StartGet ¶
func (br *AncestorReceiver) StartGet()
type BlockHashByNoReceiver ¶
type BlockHashByNoReceiver struct {
// contains filtered or unexported fields
}
BlocksChunkReceiver is send p2p getBlocksRequest to target peer and receive p2p responses till all requests blocks are received It will send response actor message if all blocks are received or failed to receive, but not send response if timeout expired.
func NewBlockHashByNoReceiver ¶
func NewBlockHashByNoReceiver(actor p2pcommon.ActorService, peer p2pcommon.RemotePeer, seq uint64, blockNo types.BlockNo, ttl time.Duration) *BlockHashByNoReceiver
func (*BlockHashByNoReceiver) ReceiveResp ¶
func (br *BlockHashByNoReceiver) ReceiveResp(msg p2pcommon.Message, msgBody p2pcommon.MessageBody) (ret bool)
ReceiveResp must be called just in read go routine
func (*BlockHashByNoReceiver) StartGet ¶
func (br *BlockHashByNoReceiver) StartGet()
type BlockHashesReceiver ¶
type BlockHashesReceiver struct {
// contains filtered or unexported fields
}
BlockHashesReceiver is send p2p GetHashesRequest to target peer and receive p2p responses till all requested hashes are received It will send response actor message if all hashes are received or failed to receive, but not send response if timeout expired.
func NewBlockHashesReceiver ¶
func NewBlockHashesReceiver(actor p2pcommon.ActorService, peer p2pcommon.RemotePeer, seq uint64, req *message.GetHashes, ttl time.Duration) *BlockHashesReceiver
func (*BlockHashesReceiver) ReceiveResp ¶
func (br *BlockHashesReceiver) ReceiveResp(msg p2pcommon.Message, msgBody p2pcommon.MessageBody) (ret bool)
ReceiveResp must be called just in read go routine
func (*BlockHashesReceiver) StartGet ¶
func (br *BlockHashesReceiver) StartGet()
type BlocksChunkReceiver ¶
type BlocksChunkReceiver struct {
// contains filtered or unexported fields
}
BlocksChunkReceiver is send p2p getBlocksRequest to target peer and receive p2p responses till all requests blocks are received It will send response actor message if all blocks are received or failed to receive, but not send response if timeout expired, since syncer actor already dropped wait before.
func NewBlockReceiver ¶
func NewBlockReceiver(actor p2pcommon.ActorService, peer p2pcommon.RemotePeer, seq uint64, blockHashes []message.BlockHash, ttl time.Duration) *BlocksChunkReceiver
func (*BlocksChunkReceiver) ReceiveResp ¶
func (br *BlocksChunkReceiver) ReceiveResp(msg p2pcommon.Message, msgBody p2pcommon.MessageBody) (ret bool)
ReceiveResp must be called just in read go routine
func (*BlocksChunkReceiver) StartGet ¶
func (br *BlocksChunkReceiver) StartGet()
type By ¶
type By func(p1, p2 *incomingTxNotice) bool
By is the type of a "less" function that defines the ordering of its Planet arguments.
type DPOSAgentRoleManager ¶
type DPOSAgentRoleManager struct { DPOSRoleManager // contains filtered or unexported fields }
func NewDPOSAgentRoleManager ¶
func NewDPOSAgentRoleManager(is p2pcommon.InternalService, actor p2pcommon.ActorService, logger *log.Logger, producers map[types.PeerID]bool) *DPOSAgentRoleManager
func (*DPOSAgentRoleManager) FilterBPNoticeReceiver ¶
func (rm *DPOSAgentRoleManager) FilterBPNoticeReceiver(block *types.Block, pm p2pcommon.PeerManager, targetZone p2pcommon.PeerZone) []p2pcommon.RemotePeer
func (*DPOSAgentRoleManager) FilterNewBlockNoticeReceiver ¶
func (rm *DPOSAgentRoleManager) FilterNewBlockNoticeReceiver(block *types.Block, pm p2pcommon.PeerManager) []p2pcommon.RemotePeer
type DPOSRoleManager ¶
type DPOSRoleManager struct {
// contains filtered or unexported fields
}
func NewDPOSRoleManager ¶
func NewDPOSRoleManager(is p2pcommon.InternalService, actor p2pcommon.ActorService, logger *log.Logger) *DPOSRoleManager
func (*DPOSRoleManager) CheckRole ¶
func (rm *DPOSRoleManager) CheckRole(remoteInfo p2pcommon.RemoteInfo, newRole types.PeerRole) bool
func (*DPOSRoleManager) FilterBPNoticeReceiver ¶
func (rm *DPOSRoleManager) FilterBPNoticeReceiver(block *types.Block, pm p2pcommon.PeerManager, targetZone p2pcommon.PeerZone) []p2pcommon.RemotePeer
func (*DPOSRoleManager) FilterNewBlockNoticeReceiver ¶
func (rm *DPOSRoleManager) FilterNewBlockNoticeReceiver(block *types.Block, pm p2pcommon.PeerManager) []p2pcommon.RemotePeer
func (*DPOSRoleManager) GetRole ¶
func (rm *DPOSRoleManager) GetRole(pid types.PeerID) types.PeerRole
func (*DPOSRoleManager) SelfRole ¶
func (rm *DPOSRoleManager) SelfRole() types.PeerRole
func (*DPOSRoleManager) Start ¶
func (rm *DPOSRoleManager) Start()
func (*DPOSRoleManager) Stop ¶
func (rm *DPOSRoleManager) Stop()
type GetTxsReceiver ¶
type GetTxsReceiver struct {
// contains filtered or unexported fields
}
GetTxsReceiver is send p2p getTXsRequest to target peer and receive p2p responses till all requests transactions are received syncer actor already dropped wait before.
func NewGetTxsReceiver ¶
func NewGetTxsReceiver(actor p2pcommon.ActorService, peer p2pcommon.RemotePeer, sm p2pcommon.SyncManager, logger *log.Logger, txIDs []types.TxID, ttl time.Duration) *GetTxsReceiver
func (*GetTxsReceiver) ReceiveResp ¶
func (br *GetTxsReceiver) ReceiveResp(msg p2pcommon.Message, msgBody p2pcommon.MessageBody) (ret bool)
ReceiveResp must be called just in read go routine
func (*GetTxsReceiver) StartGet ¶
func (br *GetTxsReceiver) StartGet()
type InboundWireHandshaker ¶
type InboundWireHandshaker struct {
// contains filtered or unexported fields
}
func (*InboundWireHandshaker) Handle ¶
func (h *InboundWireHandshaker) Handle(s io.ReadWriteCloser, ttl time.Duration) (*p2pcommon.HandshakeResult, error)
type OutboundWireHandshaker ¶
type OutboundWireHandshaker struct {
// contains filtered or unexported fields
}
func (*OutboundWireHandshaker) Handle ¶
func (h *OutboundWireHandshaker) Handle(s io.ReadWriteCloser, ttl time.Duration) (*p2pcommon.HandshakeResult, error)
type P2P ¶
type P2P struct { *component.BaseComponent // contains filtered or unexported fields }
P2P is actor component for p2p
func NewP2P ¶
func NewP2P(cfg *config.Config, chainSvc *chain.ChainService) *P2P
NewP2P create a new ActorService for p2p
func (*P2P) AfterStart ¶
func (p2ps *P2P) AfterStart()
func (*P2P) BeforeStop ¶
func (p2ps *P2P) BeforeStop()
BeforeStop is called before actor hub stops. it finishes underlying peer manager
func (*P2P) CallRequest ¶
func (p2ps *P2P) CallRequest(actor string, msg interface{}, timeout time.Duration) (interface{}, error)
CallRequest implement interface method of ActorService
func (*P2P) CallRequestDefaultTimeout ¶
CallRequest implement interface method of ActorService
func (*P2P) CertificateManager ¶
func (p2ps *P2P) CertificateManager() p2pcommon.CertificateManager
func (*P2P) ConsensusAccessor ¶
func (p2ps *P2P) ConsensusAccessor() consensus.ConsensusAccessor
ConsensusAccessor implement interface method of InternalService
func (*P2P) CreateHSHandler ¶
func (*P2P) CreateRemotePeer ¶
func (p2ps *P2P) CreateRemotePeer(remoteInfo p2pcommon.RemoteInfo, seq uint32, rw p2pcommon.MsgReadWriter) p2pcommon.RemotePeer
func (*P2P) FutureRequest ¶
FutureRequest implement interface method of ActorService
func (*P2P) FutureRequestDefaultTimeout ¶
FutureRequestDefaultTimeout implement interface method of ActorService
func (*P2P) GenesisChainID ¶
func (*P2P) GetAddresses ¶
GetAddresses send getAddress request to other peer
func (*P2P) GetBlockHashByNo ¶
func (p2ps *P2P) GetBlockHashByNo(context actor.Context, msg *message.GetHashByNo)
GetBlockHashes send request message to peer and make response message for block hashes
func (*P2P) GetBlockHashes ¶
GetBlockHashes send request message to peer and make response message for block hashes
func (*P2P) GetBlockHeaders ¶
func (p2ps *P2P) GetBlockHeaders(msg *message.GetBlockHeaders) bool
GetBlockHeaders send request message to peer and
func (*P2P) GetBlocksChunk ¶
func (p2ps *P2P) GetBlocksChunk(context actor.Context, msg *message.GetBlockChunks)
GetBlocksChunk send request message to peer and
func (*P2P) GetChainAccessor ¶
func (p2ps *P2P) GetChainAccessor() types.ChainAccessor
GetChainAccessor implement interface method of InternalService
func (*P2P) GetNetworkTransport ¶
func (p2ps *P2P) GetNetworkTransport() p2pcommon.NetworkTransport
func (*P2P) GetPeerAccessor ¶
func (p2ps *P2P) GetPeerAccessor() p2pcommon.PeerAccessor
func (*P2P) GetPeerBlockInfos ¶
func (p2ps *P2P) GetPeerBlockInfos() []types.PeerBlockInfo
func (*P2P) GetSyncAncestor ¶
func (p2ps *P2P) GetSyncAncestor(context actor.Context, msg *message.GetSyncAncestor)
GetSyncAncestor request remote peer to find ancestor
func (*P2P) LocalSettings ¶
func (p2ps *P2P) LocalSettings() p2pcommon.LocalSettings
func (*P2P) NotifyBlockProduced ¶
func (p2ps *P2P) NotifyBlockProduced(blockNotice message.NotifyNewBlock) bool
NotifyNewBlock send notice message of new block to a peer
func (*P2P) NotifyCertRenewed ¶
func (p2ps *P2P) NotifyCertRenewed(context actor.Context, renewed message.NotifyCertRenewed)
func (*P2P) NotifyNewBlock ¶
func (p2ps *P2P) NotifyNewBlock(blockNotice message.NotifyNewBlock) bool
NotifyNewBlock send notice message of new block to a peer
func (*P2P) NotifyNewTX ¶
func (p2ps *P2P) NotifyNewTX(msg *message.NotifyNewTransactions) bool
NotifyNewTX notice tx(s) id created
func (*P2P) PeerManager ¶
func (p2ps *P2P) PeerManager() p2pcommon.PeerManager
func (*P2P) RoleManager ¶
func (p2ps *P2P) RoleManager() p2pcommon.PeerRoleManager
func (*P2P) SelfNodeID ¶
func (*P2P) SendIssueCertMessage ¶
func (p2ps *P2P) SendIssueCertMessage(context actor.Context, msg message.IssueAgentCertificate)
func (*P2P) SendRaftMessage ¶
func (*P2P) SendRequest ¶
SendRequest implement interface method of ActorService
func (*P2P) SetConsensusAccessor ¶
func (p2ps *P2P) SetConsensusAccessor(ca consensus.ConsensusAccessor)
func (*P2P) Statistics ¶
Statistics show statistic information of p2p module. NOTE: It it not implemented yet
func (*P2P) TellRequest ¶
TellRequest implement interface method of ActorService
func (*P2P) TossBPNotice ¶
func (p2ps *P2P) TossBPNotice(msg message.TossBPNotice) bool
type RaftRoleManager ¶
type RaftRoleManager struct {
// contains filtered or unexported fields
}
func NewRaftRoleManager ¶
func NewRaftRoleManager(is p2pcommon.InternalService, actor p2pcommon.ActorService, logger *log.Logger) *RaftRoleManager
func (*RaftRoleManager) CheckRole ¶
func (rm *RaftRoleManager) CheckRole(remoteInfo p2pcommon.RemoteInfo, newRole types.PeerRole) bool
func (*RaftRoleManager) FilterBPNoticeReceiver ¶
func (rm *RaftRoleManager) FilterBPNoticeReceiver(block *types.Block, pm p2pcommon.PeerManager, targetZone p2pcommon.PeerZone) []p2pcommon.RemotePeer
func (*RaftRoleManager) FilterNewBlockNoticeReceiver ¶
func (rm *RaftRoleManager) FilterNewBlockNoticeReceiver(block *types.Block, pm p2pcommon.PeerManager) []p2pcommon.RemotePeer
func (*RaftRoleManager) GetRole ¶
func (rm *RaftRoleManager) GetRole(pid types.PeerID) types.PeerRole
func (*RaftRoleManager) SelfRole ¶
func (rm *RaftRoleManager) SelfRole() types.PeerRole
func (*RaftRoleManager) Start ¶
func (rm *RaftRoleManager) Start()
func (*RaftRoleManager) Stop ¶
func (rm *RaftRoleManager) Stop()
Source Files ¶
- actorwork.go
- ancestorreceiver.go
- blkreceiver.go
- certmanager.go
- configs.go
- handshakev2.go
- hashbynoreceiver.go
- hashreceiver.go
- mofactory.go
- msgorder.go
- p2p.go
- peerfinder.go
- peermanager.go
- pi.go
- reconnect.go
- remotepeer.go
- rolemanager.go
- signature.go
- syncmanager.go
- synctx.go
- txreceiver.go
- versionmanager.go
- waitpeermanager.go
Directories ¶
Path | Synopsis |
---|---|
* @file * @copyright defined in aergo/LICENSE.txt
|
* @file * @copyright defined in aergo/LICENSE.txt |
package p2pmock is a generated GoMock package.
|
package p2pmock is a generated GoMock package. |
Package v030 is a collection of classes for p2p version 0.3.0 It contains IO, handshake, handlers, etc.
|
Package v030 is a collection of classes for p2p version 0.3.0 It contains IO, handshake, handlers, etc. |