mirror of
https://github.com/ethereum/go-ethereum.git
synced 2026-08-19 10:22:23 +00:00
p2p: documentation, rename nodeID to id
This commit is contained in:
parent
67c6281ab2
commit
100c6c9f47
2 changed files with 6 additions and 5 deletions
|
|
@ -254,6 +254,7 @@ func RandomID(a ID, n int) (b ID) {
|
|||
return b
|
||||
}
|
||||
|
||||
// Equal returns a boolean reporting whether a and b contain the same bytes.
|
||||
func Equal(a, b ID) bool {
|
||||
for i := range a {
|
||||
if a[i] != b[i] {
|
||||
|
|
|
|||
|
|
@ -160,18 +160,18 @@ func (c *meteredConn) Write(b []byte) (n int, err error) {
|
|||
// handshakeDone is called when a peer handshake is done. Registers the peer to
|
||||
// the ingress and the egress traffic registries using the peer's IP and node ID,
|
||||
// also emits connect event.
|
||||
func (c *meteredConn) handshakeDone(nodeID enode.ID) {
|
||||
func (c *meteredConn) handshakeDone(id enode.ID) {
|
||||
if atomic.AddInt32(&meteredPeerCount, 1) >= MeteredPeerLimit {
|
||||
// Don't register the peer in the traffic registries.
|
||||
atomic.AddInt32(&meteredPeerCount, -1)
|
||||
c.lock.Lock()
|
||||
c.id, c.trafficMetered = nodeID, false
|
||||
c.id, c.trafficMetered = id, false
|
||||
c.lock.Unlock()
|
||||
log.Warn("Metered peer count reached the limit")
|
||||
} else {
|
||||
key := fmt.Sprintf("%s/%s", c.ip, nodeID.String())
|
||||
key := fmt.Sprintf("%s/%s", c.ip, id.String())
|
||||
c.lock.Lock()
|
||||
c.id, c.trafficMetered = nodeID, true
|
||||
c.id, c.trafficMetered = id, true
|
||||
c.ingressMeter = metrics.NewRegisteredMeter(key, PeerIngressRegistry)
|
||||
c.egressMeter = metrics.NewRegisteredMeter(key, PeerEgressRegistry)
|
||||
c.lock.Unlock()
|
||||
|
|
@ -179,7 +179,7 @@ func (c *meteredConn) handshakeDone(nodeID enode.ID) {
|
|||
meteredPeerFeed.Send(MeteredPeerEvent{
|
||||
Type: PeerConnected,
|
||||
IP: c.ip,
|
||||
ID: nodeID,
|
||||
ID: id,
|
||||
Elapsed: time.Since(c.connected),
|
||||
})
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in a new issue