Documentation ¶
Index ¶
- Constants
- Variables
- func HasConsensusService(services protocol.ServiceFlag) bool
- func ParseUserAgent(data string) (error, string, string, string)
- func UseLogger(logger l.Logger)
- type BadResponse
- type P2P
- type P2PRPC
- type Peer
- func (p *Peer) Address() ma.Multiaddr
- func (p *Peer) BadResponses() []*BadResponse
- 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) 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) GetMempoolReqTime() time.Time
- func (p *Peer) GetName() string
- func (p *Peer) GetNetwork() string
- func (p *Peer) GetVersion() string
- func (p *Peer) GraphState() *meerdag.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) IncreaseReConnect()
- func (p *Peer) IncrementBadResponses(err *common.Error)
- 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) SetMempoolReqTime(t time.Time)
- func (p *Peer) SetMetadata(metaData *pb.MetaData)
- func (p *Peer) SetQNR(record *qnr.Record)
- func (p *Peer) SetStateRoot(stateRoot *hash.Hash, order uint64)
- 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) CanConnect(pid peer.ID) bool
- func (p *Status) CanSyncPeers() []*Peer
- func (p *Status) Connected() []peer.ID
- func (p *Status) ConnectedPeers() []*Peer
- func (p *Status) Connecting() []peer.ID
- 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) GetByAddress(address ma.Multiaddr) *Peer
- func (p *Status) Inactive() []peer.ID
- func (p *Status) IncrementBadResponses(pid peer.ID, err *common.Error)
- func (p *Status) IsActive(pe *Peer) bool
- func (p *Status) IsActiveID(pid peer.ID) bool
- 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 BadResponseLife = 30 * time.Second )
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
Types ¶
type BadResponse ¶ added in v1.0.21
func (*BadResponse) String ¶ added in v1.0.21
func (br *BadResponse) String() string
type P2P ¶ added in v1.0.21
type P2P interface { GetGenesisHash() *hash.Hash BlockChain() *blockchain.BlockChain Host() host.Host Disconnect(pid peer.ID) error Context() context.Context Encoding() encoder.NetworkEncoding Config() *common.Config TxMemPool() *mempool.TxPool Metadata() *pb.MetaData MetadataSeq() uint64 TimeSource() model.MedianTimeSource Notify() model.Notify ConnectTo(node *qnode.Node) Resolve(n *qnode.Node) *qnode.Node Node() *qnode.Node RelayNodeInfo() *peer.AddrInfo IncreaseBytesSent(pid peer.ID, size int) IncreaseBytesRecv(pid peer.ID, size int) ConnectToPeer(qmaddr string, force bool) error RegainMempool() IsCurrent() bool Peers() *Status IsRunning() bool Consensus() model.Consensus }
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 ¶
func (p *Peer) BadResponses() []*BadResponse
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 ¶
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 ¶
func (*Peer) GetMempoolReqTime ¶ added in v1.0.21
func (*Peer) GetNetwork ¶
func (*Peer) GetVersion ¶
func (*Peer) GraphState ¶
func (p *Peer) GraphState() *meerdag.GraphState
func (*Peer) HasBroadcast ¶
func (*Peer) IDWithAddress ¶
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) IncreaseReConnect ¶ added in v1.0.21
func (p *Peer) IncreaseReConnect()
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 ¶
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 ¶
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) SetMempoolReqTime ¶ added in v1.0.21
func (*Peer) SetMetadata ¶
SetMetadata sets the metadata of the given remote peer.
func (*Peer) SetStateRoot ¶ added in v1.0.21
func (*Peer) StatsSnapshot ¶
func (*Peer) UpdateAddrDir ¶
func (*Peer) UpdateBroadcast ¶
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 peer.ID QNR string Address string Protocol uint32 Genesis *hash.Hash Services protocol.ServiceFlag Name string Version string Network string State bool Direction network.Direction GraphState *meerdag.GraphState GraphStateDur time.Duration TimeOffset int64 ConnTime time.Duration LastSend time.Time LastRecv time.Time BytesSent uint64 BytesRecv uint64 IsCircuit bool Bads []string ReConnect uint64 StateRoot string MempoolReqTime time.Time Tasks int Broadcast int }
StatsSnap is a snapshot of peer stats at a point in time.
func (*StatsSnap) IsTheSameNetwork ¶
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) CanSyncPeers ¶ added in v1.0.21
func (*Status) ConnectedPeers ¶
func (*Status) Connecting ¶
Connecting returns the peers that are connecting.
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) GetByAddress ¶ added in v1.0.21
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 ¶
func (p *Status) UpdateBroadcasts()