Documentation ¶
Overview ¶
Package manage p2p manage
Index ¶
- Variables
- type ConnManager
- func (s *ConnManager) AddNeighbors(pr *peer.AddrInfo)
- func (s *ConnManager) BandTrackerByProtocol() *types.NetProtocolInfos
- func (s *ConnManager) BoundSize() (insize int, outsize int)
- func (s *ConnManager) CheckDirection(pid peer.ID) network.Direction
- func (s *ConnManager) Delete(pid peer.ID)
- func (s *ConnManager) FetchConnPeers() []peer.ID
- func (s *ConnManager) FetchNearestPeers(count int) []peer.ID
- func (s *ConnManager) GetNetRate() metrics.Stats
- func (s *ConnManager) InBounds() map[peer.ID][]network.Conn
- func (s *ConnManager) IsNeighbors(pid peer.ID) bool
- func (s *ConnManager) MonitorAllPeers(wg *sync.WaitGroup)
- func (s *ConnManager) OutBounds() map[peer.ID][]network.Conn
- func (s *ConnManager) RateCalculate(ratebytes float64) string
- func (s *ConnManager) Size() int
- type Conngater
- func (s *Conngater) InterceptAccept(n network.ConnMultiaddrs) (allow bool)
- func (s *Conngater) InterceptAddrDial(p peer.ID, m multiaddr.Multiaddr) (allow bool)
- func (s *Conngater) InterceptPeerDial(p peer.ID) (allow bool)
- func (s *Conngater) InterceptSecured(_ network.Direction, p peer.ID, n network.ConnMultiaddrs) (allow bool)
- func (s *Conngater) InterceptUpgraded(n network.Conn) (allow bool, reason control.DisconnectReason)
- type PeerInfoManager
- type TimeCache
Constants ¶
This section is empty.
Variables ¶
var CacheLimit int32 = 20
CacheLimit cachebuffer
Functions ¶
This section is empty.
Types ¶
type ConnManager ¶
type ConnManager struct {
// contains filtered or unexported fields
}
ConnManager p2p connection manager
func NewConnManager ¶
func NewConnManager(ctx context.Context, host core.Host, rt *kb.RoutingTable, tracker *metrics.BandwidthCounter, cfg *p2pty.P2PSubConfig) *ConnManager
NewConnManager new connection manager
func (*ConnManager) AddNeighbors ¶
func (s *ConnManager) AddNeighbors(pr *peer.AddrInfo)
AddNeighbors add neighbors by peer info
func (*ConnManager) BandTrackerByProtocol ¶
func (s *ConnManager) BandTrackerByProtocol() *types.NetProtocolInfos
BandTrackerByProtocol returns all protocols band info
func (*ConnManager) BoundSize ¶
func (s *ConnManager) BoundSize() (insize int, outsize int)
BoundSize get in out conn bound size
func (*ConnManager) CheckDirection ¶
func (s *ConnManager) CheckDirection(pid peer.ID) network.Direction
CheckDirection 检查连接的节点ID是被连接的还是主动连接的
func (*ConnManager) FetchConnPeers ¶
func (s *ConnManager) FetchConnPeers() []peer.ID
FetchConnPeers 获取连接的Peer's ID 这个连接包含被连接的peer以及主动连接的peer.
func (*ConnManager) FetchNearestPeers ¶
func (s *ConnManager) FetchNearestPeers(count int) []peer.ID
FetchNearestPeers fetch nearest peer ids
func (*ConnManager) GetNetRate ¶
func (s *ConnManager) GetNetRate() metrics.Stats
GetNetRate get rateinfo
func (*ConnManager) InBounds ¶
func (s *ConnManager) InBounds() map[peer.ID][]network.Conn
InBounds get in bounds conn peers
func (*ConnManager) IsNeighbors ¶
func (s *ConnManager) IsNeighbors(pid peer.ID) bool
IsNeighbors check is neighbors by id
func (*ConnManager) MonitorAllPeers ¶
func (s *ConnManager) MonitorAllPeers(wg *sync.WaitGroup)
MonitorAllPeers monitory all peers
func (*ConnManager) OutBounds ¶
func (s *ConnManager) OutBounds() map[peer.ID][]network.Conn
OutBounds get out bounds conn peers
func (*ConnManager) RateCalculate ¶
func (s *ConnManager) RateCalculate(ratebytes float64) string
RateCalculate means bytes sent / received per second.
type Conngater ¶
type Conngater struct {
// contains filtered or unexported fields
}
Conngater gater struct data
func NewConnGater ¶
func NewConnGater(h *host.Host, limit int32, cache *TimeCache, whitPeers []*peer.AddrInfo) *Conngater
NewConnGater connect gater
func (*Conngater) InterceptAccept ¶
func (s *Conngater) InterceptAccept(n network.ConnMultiaddrs) (allow bool)
InterceptAccept tests whether an incipient inbound connection is allowed.
func (*Conngater) InterceptAddrDial ¶
InterceptAddrDial tests whether we're permitted to dial the specified multiaddr for the given peer.
func (*Conngater) InterceptPeerDial ¶
InterceptPeerDial tests whether we're permitted to Dial the specified peer.
func (*Conngater) InterceptSecured ¶
func (s *Conngater) InterceptSecured(_ network.Direction, p peer.ID, n network.ConnMultiaddrs) (allow bool)
InterceptSecured tests whether a given connection, now authenticated, is allowed.
func (*Conngater) InterceptUpgraded ¶
InterceptUpgraded tests whether a fully capable connection is allowed.
type PeerInfoManager ¶
type PeerInfoManager struct {
// contains filtered or unexported fields
}
PeerInfoManager peer info manager
func NewPeerInfoManager ¶
NewPeerInfoManager new peer info manager
func (*PeerInfoManager) Fetch ¶
func (p *PeerInfoManager) Fetch(pid peer.ID) *types.Peer
Fetch returns info of given peer
func (*PeerInfoManager) FetchAll ¶
func (p *PeerInfoManager) FetchAll() []*types.Peer
FetchAll returns all peers info
func (*PeerInfoManager) PeerHeight ¶
func (p *PeerInfoManager) PeerHeight(pid peer.ID) int64
PeerHeight returns block height of given peer
func (*PeerInfoManager) PeerMaxHeight ¶
func (p *PeerInfoManager) PeerMaxHeight() int64
PeerMaxHeight returns max block height of all connected peers.
func (*PeerInfoManager) Refresh ¶
func (p *PeerInfoManager) Refresh(peer *types.Peer)
Refresh refreshes peer info