2015-07-07 03:54:22 +03:00
|
|
|
// Copyright 2015 The go-ethereum Authors
|
2015-07-22 19:48:40 +03:00
|
|
|
// This file is part of the go-ethereum library.
|
2015-07-07 03:54:22 +03:00
|
|
|
//
|
2015-07-23 19:35:11 +03:00
|
|
|
// The go-ethereum library is free software: you can redistribute it and/or modify
|
2015-07-07 03:54:22 +03:00
|
|
|
// it under the terms of the GNU Lesser General Public License as published by
|
|
|
|
// the Free Software Foundation, either version 3 of the License, or
|
|
|
|
// (at your option) any later version.
|
|
|
|
//
|
2015-07-22 19:48:40 +03:00
|
|
|
// The go-ethereum library is distributed in the hope that it will be useful,
|
2015-07-07 03:54:22 +03:00
|
|
|
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
2015-07-22 19:48:40 +03:00
|
|
|
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
2015-07-07 03:54:22 +03:00
|
|
|
// GNU Lesser General Public License for more details.
|
|
|
|
//
|
|
|
|
// You should have received a copy of the GNU Lesser General Public License
|
2015-07-22 19:48:40 +03:00
|
|
|
// along with the go-ethereum library. If not, see <http://www.gnu.org/licenses/>.
|
2015-07-07 03:54:22 +03:00
|
|
|
|
2015-06-21 20:23:37 +03:00
|
|
|
// Contains the meters and timers used by the networking layer.
|
|
|
|
|
|
|
|
package p2p
|
|
|
|
|
|
|
|
import (
|
|
|
|
"net"
|
2018-10-16 01:40:51 +03:00
|
|
|
"sync"
|
|
|
|
"sync/atomic"
|
|
|
|
"time"
|
2015-06-21 20:23:37 +03:00
|
|
|
|
2018-10-16 01:40:51 +03:00
|
|
|
"github.com/ethereum/go-ethereum/event"
|
|
|
|
"github.com/ethereum/go-ethereum/log"
|
2015-06-29 16:11:01 +03:00
|
|
|
"github.com/ethereum/go-ethereum/metrics"
|
2015-06-21 20:23:37 +03:00
|
|
|
)
|
|
|
|
|
2018-10-16 01:40:51 +03:00
|
|
|
const (
|
2019-06-10 14:21:02 +03:00
|
|
|
MetricsInboundTraffic = "p2p/ingress" // Name for the registered inbound traffic meter
|
|
|
|
MetricsOutboundTraffic = "p2p/egress" // Name for the registered outbound traffic meter
|
|
|
|
MetricsOutboundConnects = "p2p/dials" // Name for the registered outbound connects meter
|
|
|
|
MetricsInboundConnects = "p2p/serves" // Name for the registered inbound connects meter
|
2018-10-16 01:40:51 +03:00
|
|
|
|
|
|
|
MeteredPeerLimit = 1024 // This amount of peers are individually metered
|
|
|
|
)
|
|
|
|
|
2015-06-21 20:23:37 +03:00
|
|
|
var (
|
2018-10-16 01:40:51 +03:00
|
|
|
ingressConnectMeter = metrics.NewRegisteredMeter(MetricsInboundConnects, nil) // Meter counting the ingress connections
|
|
|
|
ingressTrafficMeter = metrics.NewRegisteredMeter(MetricsInboundTraffic, nil) // Meter metering the cumulative ingress traffic
|
|
|
|
egressConnectMeter = metrics.NewRegisteredMeter(MetricsOutboundConnects, nil) // Meter counting the egress connections
|
|
|
|
egressTrafficMeter = metrics.NewRegisteredMeter(MetricsOutboundTraffic, nil) // Meter metering the cumulative egress traffic
|
2019-09-10 14:39:07 +03:00
|
|
|
activePeerGauge = metrics.NewRegisteredGauge("p2p/peers", nil) // Gauge tracking the current peer count
|
2018-10-16 01:40:51 +03:00
|
|
|
|
2018-11-09 12:20:51 +03:00
|
|
|
PeerIngressRegistry = metrics.NewPrefixedChildRegistry(metrics.EphemeralRegistry, MetricsInboundTraffic+"/") // Registry containing the peer ingress
|
|
|
|
PeerEgressRegistry = metrics.NewPrefixedChildRegistry(metrics.EphemeralRegistry, MetricsOutboundTraffic+"/") // Registry containing the peer egress
|
2018-10-16 01:40:51 +03:00
|
|
|
|
|
|
|
meteredPeerFeed event.Feed // Event feed for peer metrics
|
|
|
|
meteredPeerCount int32 // Actually stored peer connection count
|
2015-06-21 20:23:37 +03:00
|
|
|
)
|
|
|
|
|
2018-10-16 01:40:51 +03:00
|
|
|
// MeteredPeerEventType is the type of peer events emitted by a metered connection.
|
|
|
|
type MeteredPeerEventType int
|
|
|
|
|
|
|
|
const (
|
dashboard: send current block to the dashboard client (#19762)
This adds all dashboard changes from the last couple months.
We're about to remove the dashboard, but decided that we should
get all the recent work in first in case anyone wants to pick up this
project later on.
* cmd, dashboard, eth, p2p: send peer info to the dashboard
* dashboard: update npm packages, improve UI, rebase
* dashboard, p2p: remove println, change doc
* cmd, dashboard, eth, p2p: cleanup after review
* dashboard: send current block to the dashboard client
2019-11-13 14:13:13 +03:00
|
|
|
// PeerHandshakeSucceeded is the type of event
|
|
|
|
// emitted when a peer successfully makes the handshake.
|
|
|
|
PeerHandshakeSucceeded MeteredPeerEventType = iota
|
2018-10-16 01:40:51 +03:00
|
|
|
|
|
|
|
// PeerHandshakeFailed is the type of event emitted when a peer fails to
|
dashboard: send current block to the dashboard client (#19762)
This adds all dashboard changes from the last couple months.
We're about to remove the dashboard, but decided that we should
get all the recent work in first in case anyone wants to pick up this
project later on.
* cmd, dashboard, eth, p2p: send peer info to the dashboard
* dashboard: update npm packages, improve UI, rebase
* dashboard, p2p: remove println, change doc
* cmd, dashboard, eth, p2p: cleanup after review
* dashboard: send current block to the dashboard client
2019-11-13 14:13:13 +03:00
|
|
|
// make the handshake or disconnects before it.
|
2018-10-16 01:40:51 +03:00
|
|
|
PeerHandshakeFailed
|
dashboard: send current block to the dashboard client (#19762)
This adds all dashboard changes from the last couple months.
We're about to remove the dashboard, but decided that we should
get all the recent work in first in case anyone wants to pick up this
project later on.
* cmd, dashboard, eth, p2p: send peer info to the dashboard
* dashboard: update npm packages, improve UI, rebase
* dashboard, p2p: remove println, change doc
* cmd, dashboard, eth, p2p: cleanup after review
* dashboard: send current block to the dashboard client
2019-11-13 14:13:13 +03:00
|
|
|
|
|
|
|
// PeerDisconnected is the type of event emitted when a peer disconnects.
|
|
|
|
PeerDisconnected
|
2018-10-16 01:40:51 +03:00
|
|
|
)
|
|
|
|
|
|
|
|
// MeteredPeerEvent is an event emitted when peers connect or disconnect.
|
|
|
|
type MeteredPeerEvent struct {
|
|
|
|
Type MeteredPeerEventType // Type of peer event
|
dashboard: send current block to the dashboard client (#19762)
This adds all dashboard changes from the last couple months.
We're about to remove the dashboard, but decided that we should
get all the recent work in first in case anyone wants to pick up this
project later on.
* cmd, dashboard, eth, p2p: send peer info to the dashboard
* dashboard: update npm packages, improve UI, rebase
* dashboard, p2p: remove println, change doc
* cmd, dashboard, eth, p2p: cleanup after review
* dashboard: send current block to the dashboard client
2019-11-13 14:13:13 +03:00
|
|
|
Addr string // TCP address of the peer
|
2018-10-16 01:40:51 +03:00
|
|
|
Elapsed time.Duration // Time elapsed between the connection and the handshake/disconnection
|
dashboard: send current block to the dashboard client (#19762)
This adds all dashboard changes from the last couple months.
We're about to remove the dashboard, but decided that we should
get all the recent work in first in case anyone wants to pick up this
project later on.
* cmd, dashboard, eth, p2p: send peer info to the dashboard
* dashboard: update npm packages, improve UI, rebase
* dashboard, p2p: remove println, change doc
* cmd, dashboard, eth, p2p: cleanup after review
* dashboard: send current block to the dashboard client
2019-11-13 14:13:13 +03:00
|
|
|
Peer *Peer // Connected remote node instance
|
2018-10-16 01:40:51 +03:00
|
|
|
Ingress uint64 // Ingress count at the moment of the event
|
|
|
|
Egress uint64 // Egress count at the moment of the event
|
|
|
|
}
|
|
|
|
|
|
|
|
// SubscribeMeteredPeerEvent registers a subscription for peer life-cycle events
|
|
|
|
// if metrics collection is enabled.
|
|
|
|
func SubscribeMeteredPeerEvent(ch chan<- MeteredPeerEvent) event.Subscription {
|
|
|
|
return meteredPeerFeed.Subscribe(ch)
|
|
|
|
}
|
|
|
|
|
2018-06-20 15:06:27 +03:00
|
|
|
// meteredConn is a wrapper around a net.Conn that meters both the
|
2015-06-21 20:23:37 +03:00
|
|
|
// inbound and outbound network traffic.
|
|
|
|
type meteredConn struct {
|
2018-06-20 15:06:27 +03:00
|
|
|
net.Conn // Network connection to wrap with metering
|
2018-10-16 01:40:51 +03:00
|
|
|
|
dashboard: send current block to the dashboard client (#19762)
This adds all dashboard changes from the last couple months.
We're about to remove the dashboard, but decided that we should
get all the recent work in first in case anyone wants to pick up this
project later on.
* cmd, dashboard, eth, p2p: send peer info to the dashboard
* dashboard: update npm packages, improve UI, rebase
* dashboard, p2p: remove println, change doc
* cmd, dashboard, eth, p2p: cleanup after review
* dashboard: send current block to the dashboard client
2019-11-13 14:13:13 +03:00
|
|
|
connected time.Time // Connection time of the peer
|
|
|
|
addr *net.TCPAddr // TCP address of the peer
|
|
|
|
peer *Peer // Peer instance
|
2018-10-16 01:40:51 +03:00
|
|
|
|
|
|
|
// trafficMetered denotes if the peer is registered in the traffic registries.
|
|
|
|
// Its value is true if the metered peer count doesn't reach the limit in the
|
|
|
|
// moment of the peer's connection.
|
|
|
|
trafficMetered bool
|
|
|
|
ingressMeter metrics.Meter // Meter for the read bytes of the peer
|
|
|
|
egressMeter metrics.Meter // Meter for the written bytes of the peer
|
|
|
|
|
|
|
|
lock sync.RWMutex // Lock protecting the metered connection's internals
|
2015-06-21 20:23:37 +03:00
|
|
|
}
|
|
|
|
|
2018-10-16 01:40:51 +03:00
|
|
|
// newMeteredConn creates a new metered connection, bumps the ingress or egress
|
|
|
|
// connection meter and also increases the metered peer count. If the metrics
|
|
|
|
// system is disabled or the IP address is unspecified, this function returns
|
|
|
|
// the original object.
|
dashboard: send current block to the dashboard client (#19762)
This adds all dashboard changes from the last couple months.
We're about to remove the dashboard, but decided that we should
get all the recent work in first in case anyone wants to pick up this
project later on.
* cmd, dashboard, eth, p2p: send peer info to the dashboard
* dashboard: update npm packages, improve UI, rebase
* dashboard, p2p: remove println, change doc
* cmd, dashboard, eth, p2p: cleanup after review
* dashboard: send current block to the dashboard client
2019-11-13 14:13:13 +03:00
|
|
|
func newMeteredConn(conn net.Conn, ingress bool, addr *net.TCPAddr) net.Conn {
|
2015-07-02 14:13:46 +03:00
|
|
|
// Short circuit if metrics are disabled
|
|
|
|
if !metrics.Enabled {
|
|
|
|
return conn
|
|
|
|
}
|
dashboard: send current block to the dashboard client (#19762)
This adds all dashboard changes from the last couple months.
We're about to remove the dashboard, but decided that we should
get all the recent work in first in case anyone wants to pick up this
project later on.
* cmd, dashboard, eth, p2p: send peer info to the dashboard
* dashboard: update npm packages, improve UI, rebase
* dashboard, p2p: remove println, change doc
* cmd, dashboard, eth, p2p: cleanup after review
* dashboard: send current block to the dashboard client
2019-11-13 14:13:13 +03:00
|
|
|
if addr == nil || addr.IP.IsUnspecified() {
|
|
|
|
log.Warn("Peer address is unspecified")
|
2018-10-16 01:40:51 +03:00
|
|
|
return conn
|
|
|
|
}
|
|
|
|
// Bump the connection counters and wrap the connection
|
2015-06-21 20:23:37 +03:00
|
|
|
if ingress {
|
|
|
|
ingressConnectMeter.Mark(1)
|
|
|
|
} else {
|
|
|
|
egressConnectMeter.Mark(1)
|
|
|
|
}
|
2019-09-10 14:39:07 +03:00
|
|
|
activePeerGauge.Inc(1)
|
2019-06-10 14:21:02 +03:00
|
|
|
|
2018-10-16 01:40:51 +03:00
|
|
|
return &meteredConn{
|
|
|
|
Conn: conn,
|
dashboard: send current block to the dashboard client (#19762)
This adds all dashboard changes from the last couple months.
We're about to remove the dashboard, but decided that we should
get all the recent work in first in case anyone wants to pick up this
project later on.
* cmd, dashboard, eth, p2p: send peer info to the dashboard
* dashboard: update npm packages, improve UI, rebase
* dashboard, p2p: remove println, change doc
* cmd, dashboard, eth, p2p: cleanup after review
* dashboard: send current block to the dashboard client
2019-11-13 14:13:13 +03:00
|
|
|
addr: addr,
|
2018-10-16 01:40:51 +03:00
|
|
|
connected: time.Now(),
|
|
|
|
}
|
2015-06-21 20:23:37 +03:00
|
|
|
}
|
|
|
|
|
2018-10-16 01:40:51 +03:00
|
|
|
// Read delegates a network read to the underlying connection, bumping the common
|
|
|
|
// and the peer ingress traffic meters along the way.
|
2015-06-21 20:23:37 +03:00
|
|
|
func (c *meteredConn) Read(b []byte) (n int, err error) {
|
2018-06-20 15:06:27 +03:00
|
|
|
n, err = c.Conn.Read(b)
|
2015-06-21 20:23:37 +03:00
|
|
|
ingressTrafficMeter.Mark(int64(n))
|
2018-10-16 01:40:51 +03:00
|
|
|
c.lock.RLock()
|
|
|
|
if c.trafficMetered {
|
|
|
|
c.ingressMeter.Mark(int64(n))
|
|
|
|
}
|
|
|
|
c.lock.RUnlock()
|
|
|
|
return n, err
|
2015-06-21 20:23:37 +03:00
|
|
|
}
|
|
|
|
|
2018-10-16 01:40:51 +03:00
|
|
|
// Write delegates a network write to the underlying connection, bumping the common
|
|
|
|
// and the peer egress traffic meters along the way.
|
2015-06-21 20:23:37 +03:00
|
|
|
func (c *meteredConn) Write(b []byte) (n int, err error) {
|
2018-06-20 15:06:27 +03:00
|
|
|
n, err = c.Conn.Write(b)
|
2015-06-21 20:23:37 +03:00
|
|
|
egressTrafficMeter.Mark(int64(n))
|
2018-10-16 01:40:51 +03:00
|
|
|
c.lock.RLock()
|
|
|
|
if c.trafficMetered {
|
|
|
|
c.egressMeter.Mark(int64(n))
|
|
|
|
}
|
|
|
|
c.lock.RUnlock()
|
|
|
|
return n, err
|
|
|
|
}
|
|
|
|
|
dashboard: send current block to the dashboard client (#19762)
This adds all dashboard changes from the last couple months.
We're about to remove the dashboard, but decided that we should
get all the recent work in first in case anyone wants to pick up this
project later on.
* cmd, dashboard, eth, p2p: send peer info to the dashboard
* dashboard: update npm packages, improve UI, rebase
* dashboard, p2p: remove println, change doc
* cmd, dashboard, eth, p2p: cleanup after review
* dashboard: send current block to the dashboard client
2019-11-13 14:13:13 +03:00
|
|
|
// handshakeDone is called after the connection passes the handshake.
|
|
|
|
func (c *meteredConn) handshakeDone(peer *Peer) {
|
2018-10-16 01:40:51 +03:00
|
|
|
if atomic.AddInt32(&meteredPeerCount, 1) >= MeteredPeerLimit {
|
|
|
|
// Don't register the peer in the traffic registries.
|
|
|
|
atomic.AddInt32(&meteredPeerCount, -1)
|
|
|
|
c.lock.Lock()
|
dashboard: send current block to the dashboard client (#19762)
This adds all dashboard changes from the last couple months.
We're about to remove the dashboard, but decided that we should
get all the recent work in first in case anyone wants to pick up this
project later on.
* cmd, dashboard, eth, p2p: send peer info to the dashboard
* dashboard: update npm packages, improve UI, rebase
* dashboard, p2p: remove println, change doc
* cmd, dashboard, eth, p2p: cleanup after review
* dashboard: send current block to the dashboard client
2019-11-13 14:13:13 +03:00
|
|
|
c.peer, c.trafficMetered = peer, false
|
2018-10-16 01:40:51 +03:00
|
|
|
c.lock.Unlock()
|
|
|
|
log.Warn("Metered peer count reached the limit")
|
|
|
|
} else {
|
dashboard: send current block to the dashboard client (#19762)
This adds all dashboard changes from the last couple months.
We're about to remove the dashboard, but decided that we should
get all the recent work in first in case anyone wants to pick up this
project later on.
* cmd, dashboard, eth, p2p: send peer info to the dashboard
* dashboard: update npm packages, improve UI, rebase
* dashboard, p2p: remove println, change doc
* cmd, dashboard, eth, p2p: cleanup after review
* dashboard: send current block to the dashboard client
2019-11-13 14:13:13 +03:00
|
|
|
enode := peer.Node().String()
|
2018-10-16 01:40:51 +03:00
|
|
|
c.lock.Lock()
|
dashboard: send current block to the dashboard client (#19762)
This adds all dashboard changes from the last couple months.
We're about to remove the dashboard, but decided that we should
get all the recent work in first in case anyone wants to pick up this
project later on.
* cmd, dashboard, eth, p2p: send peer info to the dashboard
* dashboard: update npm packages, improve UI, rebase
* dashboard, p2p: remove println, change doc
* cmd, dashboard, eth, p2p: cleanup after review
* dashboard: send current block to the dashboard client
2019-11-13 14:13:13 +03:00
|
|
|
c.peer, c.trafficMetered = peer, true
|
|
|
|
c.ingressMeter = metrics.NewRegisteredMeter(enode, PeerIngressRegistry)
|
|
|
|
c.egressMeter = metrics.NewRegisteredMeter(enode, PeerEgressRegistry)
|
2018-10-16 01:40:51 +03:00
|
|
|
c.lock.Unlock()
|
|
|
|
}
|
|
|
|
meteredPeerFeed.Send(MeteredPeerEvent{
|
dashboard: send current block to the dashboard client (#19762)
This adds all dashboard changes from the last couple months.
We're about to remove the dashboard, but decided that we should
get all the recent work in first in case anyone wants to pick up this
project later on.
* cmd, dashboard, eth, p2p: send peer info to the dashboard
* dashboard: update npm packages, improve UI, rebase
* dashboard, p2p: remove println, change doc
* cmd, dashboard, eth, p2p: cleanup after review
* dashboard: send current block to the dashboard client
2019-11-13 14:13:13 +03:00
|
|
|
Type: PeerHandshakeSucceeded,
|
|
|
|
Addr: c.addr.String(),
|
|
|
|
Peer: peer,
|
2018-10-16 01:40:51 +03:00
|
|
|
Elapsed: time.Since(c.connected),
|
|
|
|
})
|
|
|
|
}
|
|
|
|
|
|
|
|
// Close delegates a close operation to the underlying connection, unregisters
|
|
|
|
// the peer from the traffic registries and emits close event.
|
|
|
|
func (c *meteredConn) Close() error {
|
|
|
|
err := c.Conn.Close()
|
|
|
|
c.lock.RLock()
|
dashboard: send current block to the dashboard client (#19762)
This adds all dashboard changes from the last couple months.
We're about to remove the dashboard, but decided that we should
get all the recent work in first in case anyone wants to pick up this
project later on.
* cmd, dashboard, eth, p2p: send peer info to the dashboard
* dashboard: update npm packages, improve UI, rebase
* dashboard, p2p: remove println, change doc
* cmd, dashboard, eth, p2p: cleanup after review
* dashboard: send current block to the dashboard client
2019-11-13 14:13:13 +03:00
|
|
|
if c.peer == nil {
|
|
|
|
// If the peer disconnects before/during the handshake.
|
2018-10-16 01:40:51 +03:00
|
|
|
c.lock.RUnlock()
|
|
|
|
meteredPeerFeed.Send(MeteredPeerEvent{
|
|
|
|
Type: PeerHandshakeFailed,
|
dashboard: send current block to the dashboard client (#19762)
This adds all dashboard changes from the last couple months.
We're about to remove the dashboard, but decided that we should
get all the recent work in first in case anyone wants to pick up this
project later on.
* cmd, dashboard, eth, p2p: send peer info to the dashboard
* dashboard: update npm packages, improve UI, rebase
* dashboard, p2p: remove println, change doc
* cmd, dashboard, eth, p2p: cleanup after review
* dashboard: send current block to the dashboard client
2019-11-13 14:13:13 +03:00
|
|
|
Addr: c.addr.String(),
|
2018-10-16 01:40:51 +03:00
|
|
|
Elapsed: time.Since(c.connected),
|
|
|
|
})
|
2019-09-10 14:39:07 +03:00
|
|
|
activePeerGauge.Dec(1)
|
2018-10-16 01:40:51 +03:00
|
|
|
return err
|
|
|
|
}
|
dashboard: send current block to the dashboard client (#19762)
This adds all dashboard changes from the last couple months.
We're about to remove the dashboard, but decided that we should
get all the recent work in first in case anyone wants to pick up this
project later on.
* cmd, dashboard, eth, p2p: send peer info to the dashboard
* dashboard: update npm packages, improve UI, rebase
* dashboard, p2p: remove println, change doc
* cmd, dashboard, eth, p2p: cleanup after review
* dashboard: send current block to the dashboard client
2019-11-13 14:13:13 +03:00
|
|
|
peer := c.peer
|
2018-10-16 01:40:51 +03:00
|
|
|
if !c.trafficMetered {
|
|
|
|
// If the peer isn't registered in the traffic registries.
|
|
|
|
c.lock.RUnlock()
|
|
|
|
meteredPeerFeed.Send(MeteredPeerEvent{
|
|
|
|
Type: PeerDisconnected,
|
dashboard: send current block to the dashboard client (#19762)
This adds all dashboard changes from the last couple months.
We're about to remove the dashboard, but decided that we should
get all the recent work in first in case anyone wants to pick up this
project later on.
* cmd, dashboard, eth, p2p: send peer info to the dashboard
* dashboard: update npm packages, improve UI, rebase
* dashboard, p2p: remove println, change doc
* cmd, dashboard, eth, p2p: cleanup after review
* dashboard: send current block to the dashboard client
2019-11-13 14:13:13 +03:00
|
|
|
Addr: c.addr.String(),
|
|
|
|
Peer: peer,
|
2018-10-16 01:40:51 +03:00
|
|
|
})
|
2019-09-10 14:39:07 +03:00
|
|
|
activePeerGauge.Dec(1)
|
2018-10-16 01:40:51 +03:00
|
|
|
return err
|
|
|
|
}
|
dashboard: send current block to the dashboard client (#19762)
This adds all dashboard changes from the last couple months.
We're about to remove the dashboard, but decided that we should
get all the recent work in first in case anyone wants to pick up this
project later on.
* cmd, dashboard, eth, p2p: send peer info to the dashboard
* dashboard: update npm packages, improve UI, rebase
* dashboard, p2p: remove println, change doc
* cmd, dashboard, eth, p2p: cleanup after review
* dashboard: send current block to the dashboard client
2019-11-13 14:13:13 +03:00
|
|
|
ingress, egress, enode := uint64(c.ingressMeter.Count()), uint64(c.egressMeter.Count()), c.peer.Node().String()
|
2018-10-16 01:40:51 +03:00
|
|
|
c.lock.RUnlock()
|
|
|
|
|
|
|
|
// Decrement the metered peer count
|
|
|
|
atomic.AddInt32(&meteredPeerCount, -1)
|
|
|
|
|
|
|
|
// Unregister the peer from the traffic registries
|
dashboard: send current block to the dashboard client (#19762)
This adds all dashboard changes from the last couple months.
We're about to remove the dashboard, but decided that we should
get all the recent work in first in case anyone wants to pick up this
project later on.
* cmd, dashboard, eth, p2p: send peer info to the dashboard
* dashboard: update npm packages, improve UI, rebase
* dashboard, p2p: remove println, change doc
* cmd, dashboard, eth, p2p: cleanup after review
* dashboard: send current block to the dashboard client
2019-11-13 14:13:13 +03:00
|
|
|
PeerIngressRegistry.Unregister(enode)
|
|
|
|
PeerEgressRegistry.Unregister(enode)
|
2018-10-16 01:40:51 +03:00
|
|
|
|
|
|
|
meteredPeerFeed.Send(MeteredPeerEvent{
|
|
|
|
Type: PeerDisconnected,
|
dashboard: send current block to the dashboard client (#19762)
This adds all dashboard changes from the last couple months.
We're about to remove the dashboard, but decided that we should
get all the recent work in first in case anyone wants to pick up this
project later on.
* cmd, dashboard, eth, p2p: send peer info to the dashboard
* dashboard: update npm packages, improve UI, rebase
* dashboard, p2p: remove println, change doc
* cmd, dashboard, eth, p2p: cleanup after review
* dashboard: send current block to the dashboard client
2019-11-13 14:13:13 +03:00
|
|
|
Addr: c.addr.String(),
|
|
|
|
Peer: peer,
|
2018-10-16 01:40:51 +03:00
|
|
|
Ingress: ingress,
|
|
|
|
Egress: egress,
|
|
|
|
})
|
2019-09-10 14:39:07 +03:00
|
|
|
activePeerGauge.Dec(1)
|
2018-10-16 01:40:51 +03:00
|
|
|
return err
|
2015-06-21 20:23:37 +03:00
|
|
|
}
|