Documentation ¶
Index ¶
- Constants
- Variables
- func HasConsensusService(services protocol.ServiceFlag) bool
- func ParseUserAgent(data string) (error, string, string, string)
- func UseLogger(logger l.Logger)
- type Peer
- func (p *Peer) Address() ma.Multiaddr
- func (p *Peer) BadResponses() int
- func (p *Peer) Broadcast(key string, record interface{})
- func (p *Peer) BytesRecv() uint64
- func (p *Peer) BytesSent() uint64
- func (p *Peer) CanConnectWithNetwork() bool
- func (p *Peer) ChainState() *pb.ChainState
- func (p *Peer) ChainStateLastUpdated() time.Time
- func (p *Peer) CommitteeIndices() []uint64
- func (p *Peer) ConnectionState() PeerConnectionState
- func (p *Peer) ConnectionTime() time.Time
- func (p *Peer) Decay()
- func (p *Peer) Direction() network.Direction
- func (p *Peer) DisableRelayTx() bool
- func (p *Peer) FeeFilter() int64
- func (p *Peer) Filter() *bloom.Filter
- func (p *Peer) GetBidChanCap() time.Time
- func (p *Peer) GetID() peer.ID
- func (p *Peer) GetName() string
- func (p *Peer) GetNetwork() string
- func (p *Peer) GetVersion() string
- func (p *Peer) GraphState() *blockdag.GraphState
- func (p *Peer) HasBroadcast(key string) bool
- func (p *Peer) IDWithAddress() string
- func (p *Peer) IncreaseBytesRecv(size int)
- func (p *Peer) IncreaseBytesSent(size int)
- func (p *Peer) IncrementBadResponses(reason string)
- func (p *Peer) IsActive() bool
- func (p *Peer) IsBad() bool
- func (p *Peer) IsConnected() bool
- func (p *Peer) IsConsensus() bool
- func (p *Peer) IsRelay() bool
- func (p *Peer) Metadata() *pb.MetaData
- func (p *Peer) Node() *qnode.Node
- func (p *Peer) QAddress() common.QMultiaddr
- func (p *Peer) QNR() *qnr.Record
- func (p *Peer) ResetBad()
- func (p *Peer) RunRate(task string, delay time.Duration, f func())
- func (p *Peer) Services() protocol.ServiceFlag
- func (p *Peer) SetBidChanCap(life time.Time)
- func (p *Peer) SetChainState(chainState *pb.ChainState)
- func (p *Peer) SetConnectionState(state PeerConnectionState)
- func (p *Peer) SetMetadata(metaData *pb.MetaData)
- func (p *Peer) SetQNR(record *qnr.Record)
- func (p *Peer) StatsSnapshot() (*StatsSnap, error)
- func (p *Peer) SyncPoint() *hash.Hash
- func (p *Peer) Timestamp() time.Time
- func (p *Peer) UpdateAddrDir(record *qnr.Record, address ma.Multiaddr, direction network.Direction)
- func (p *Peer) UpdateBroadcast()
- func (p *Peer) UpdateGraphState(gs *pb.GraphState)
- func (p *Peer) UpdateSyncPoint(point *hash.Hash)
- type PeerConnectionState
- type StatsSnap
- type Status
- func (p *Status) Active() []peer.ID
- func (p *Status) Add(record *qnr.Record, pid peer.ID, address ma.Multiaddr, ...)
- func (p *Status) All() []peer.ID
- func (p *Status) AllPeers() []*Peer
- func (p *Status) Bad() []peer.ID
- func (p *Status) Connected() []peer.ID
- func (p *Status) ConnectedPeers() []*Peer
- func (p *Status) Connecting() []peer.ID
- func (p *Status) Decay()
- func (p *Status) DirInbound() []peer.ID
- func (p *Status) Disconnected() []peer.ID
- func (p *Status) Disconnecting() []peer.ID
- func (p *Status) Fetch(pid peer.ID) *Peer
- func (p *Status) ForPeers(state PeerConnectionState, closure func(pe *Peer))
- func (p *Status) Get(pid peer.ID) *Peer
- func (p *Status) Inactive() []peer.ID
- func (p *Status) IncrementBadResponses(pid peer.ID, reason string)
- func (p *Status) StatsSnapshots() []*StatsSnap
- func (p *Status) SubscribedToSubnet(index uint64) []peer.ID
- func (p *Status) UpdateBroadcasts()
Constants ¶
const ( MinBroadcastRecord = 10 BroadcastRecordLife = 30 * time.Minute )
Variables ¶
var ( // ErrPeerUnknown is returned when there is an attempt to obtain data from a peer that is not known. ErrPeerUnknown = errors.New("peer unknown") )
var (
// maxBadResponses is the maximum number of bad responses from a peer before we stop talking to it.
MaxBadResponses = 50
)
Functions ¶
func HasConsensusService ¶
func HasConsensusService(services protocol.ServiceFlag) bool
func ParseUserAgent ¶ added in v0.10.2
Types ¶
type Peer ¶
Peer represents a connected p2p network remote node.
func (*Peer) Address ¶
Address returns the multiaddress of the given remote peer. This will error if the peer does not exist.
func (*Peer) BadResponses ¶
BadResponses obtains the number of bad responses we have received from the given remote peer. This will error if the peer does not exist.
func (*Peer) CanConnectWithNetwork ¶ added in v0.10.2
func (*Peer) ChainState ¶
func (p *Peer) ChainState() *pb.ChainState
ChainState gets the chain state of the given remote peer. This can return nil if there is no known chain state for the peer. This will error if the peer does not exist.
func (*Peer) ChainStateLastUpdated ¶
ChainStateLastUpdated gets the last time the chain state of the given remote peer was updated. This will error if the peer does not exist.
func (*Peer) CommitteeIndices ¶
CommitteeIndices retrieves the committee subnets the peer is subscribed to.
func (*Peer) ConnectionState ¶
func (p *Peer) ConnectionState() PeerConnectionState
ConnectionState gets the connection state of the given remote peer. This will error if the peer does not exist.
func (*Peer) ConnectionTime ¶
func (*Peer) Direction ¶
Direction returns the direction of the given remote peer. This will error if the peer does not exist.
func (*Peer) DisableRelayTx ¶
func (*Peer) GetBidChanCap ¶ added in v0.10.3
func (*Peer) GetNetwork ¶ added in v0.10.2
func (*Peer) GetVersion ¶ added in v0.10.2
func (*Peer) GraphState ¶
func (p *Peer) GraphState() *blockdag.GraphState
func (*Peer) HasBroadcast ¶ added in v0.10.5
func (*Peer) IDWithAddress ¶ added in v0.10.3
IDWithAddress returns the printable id and address of the remote peer. It's useful on printing out the trace log messages.
func (*Peer) IncreaseBytesRecv ¶
func (*Peer) IncreaseBytesSent ¶
func (*Peer) IncrementBadResponses ¶
IncrementBadResponses increments the number of bad responses we have received from the given remote peer.
func (*Peer) IsBad ¶
IsBad states if the peer is to be considered bad. If the peer is unknown this will return `false`, which makes using this function easier than returning an error.
func (*Peer) IsConnected ¶ added in v0.10.3
func (*Peer) IsConsensus ¶
func (*Peer) Metadata ¶
Metadata returns a copy of the metadata corresponding to the provided peer id.
func (*Peer) QAddress ¶
func (p *Peer) QAddress() common.QMultiaddr
func (*Peer) Services ¶
func (p *Peer) Services() protocol.ServiceFlag
func (*Peer) SetBidChanCap ¶ added in v0.10.3
func (*Peer) SetChainState ¶
func (p *Peer) SetChainState(chainState *pb.ChainState)
SetChainState sets the chain state of the given remote peer.
func (*Peer) SetConnectionState ¶
func (p *Peer) SetConnectionState(state PeerConnectionState)
SetConnectionState sets the connection state of the given remote peer.
func (*Peer) SetMetadata ¶
SetMetadata sets the metadata of the given remote peer.
func (*Peer) StatsSnapshot ¶
func (*Peer) UpdateAddrDir ¶
func (*Peer) UpdateBroadcast ¶ added in v0.10.5
func (p *Peer) UpdateBroadcast()
func (*Peer) UpdateGraphState ¶
func (p *Peer) UpdateGraphState(gs *pb.GraphState)
func (*Peer) UpdateSyncPoint ¶
type PeerConnectionState ¶
type PeerConnectionState int32
PeerConnectionState is the state of the connection.
const ( // PeerDisconnected means there is no connection to the peer. PeerDisconnected PeerConnectionState = iota // PeerDisconnecting means there is an on-going attempt to disconnect from the peer. PeerDisconnecting // PeerConnected means the peer has an active connection. PeerConnected // PeerConnecting means there is an on-going attempt to connect to the peer. PeerConnecting )
func (PeerConnectionState) IsConnected ¶
func (pcs PeerConnectionState) IsConnected() bool
func (PeerConnectionState) IsConnecting ¶
func (pcs PeerConnectionState) IsConnecting() bool
func (PeerConnectionState) IsDisconnected ¶
func (pcs PeerConnectionState) IsDisconnected() bool
func (PeerConnectionState) IsDisconnecting ¶
func (pcs PeerConnectionState) IsDisconnecting() bool
func (PeerConnectionState) String ¶
func (pcs PeerConnectionState) String() string
type StatsSnap ¶
type StatsSnap struct { NodeID string PeerID string QNR string Address string Protocol uint32 Genesis *hash.Hash Services protocol.ServiceFlag Name string Version string Network string State PeerConnectionState Direction network.Direction GraphState *blockdag.GraphState GraphStateDur time.Duration TimeOffset int64 ConnTime time.Duration LastSend time.Time LastRecv time.Time BytesSent uint64 BytesRecv uint64 IsCircuit bool Bads int }
StatsSnap is a snapshot of peer stats at a point in time.
func (*StatsSnap) IsTheSameNetwork ¶ added in v0.10.2
type Status ¶
type Status struct {
// contains filtered or unexported fields
}
Status is the structure holding the peer status information.
func (*Status) Add ¶
func (p *Status) Add(record *qnr.Record, pid peer.ID, address ma.Multiaddr, direction network.Direction)
Add adds a peer. If a peer already exists with this ID its address and direction are updated with the supplied data.
func (*Status) ConnectedPeers ¶
func (*Status) Connecting ¶
Connecting returns the peers that are connecting.
func (*Status) Decay ¶
func (p *Status) Decay()
Decay reduces the bad responses of all peers, giving reformed peers a chance to join the network. This can be run periodically, although note that each time it runs it does give all bad peers another chance as well to clog up the network with bad responses, so should not be run too frequently; once an hour would be reasonable.
func (*Status) DirInbound ¶
func (*Status) Disconnected ¶
Disconnected returns the peers that are disconnected.
func (*Status) Disconnecting ¶
Disconnecting returns the peers that are disconnecting.
func (*Status) ForPeers ¶
func (p *Status) ForPeers(state PeerConnectionState, closure func(pe *Peer))
func (*Status) IncrementBadResponses ¶
IncrementBadResponses increments the number of bad responses we have received from the given remote peer.
func (*Status) StatsSnapshots ¶
func (*Status) SubscribedToSubnet ¶
SubscribedToSubnet retrieves the peers subscribed to the given committee subnet.
func (*Status) UpdateBroadcasts ¶ added in v0.10.5
func (p *Status) UpdateBroadcasts()