mirror of https://github.com/status-im/nim-eth.git
use new nim-metrics API
This commit is contained in:
parent
14ae046354
commit
620573f63c
|
@ -10,5 +10,5 @@ proc parseAddress*(hexString: string): EthAddress =
|
||||||
proc `$`*(a: EthAddress): string =
|
proc `$`*(a: EthAddress): string =
|
||||||
a.toHex()
|
a.toHex()
|
||||||
|
|
||||||
var peerGauge* = newGauge("connected_peers", "number of peers in the pool")
|
newPublicGauge(connected_peers, "number of peers in the pool")
|
||||||
|
|
||||||
|
|
|
@ -110,8 +110,7 @@ proc getRandomBootnode(p: PeerPool): Option[Node] =
|
||||||
proc addPeer*(pool: PeerPool, peer: Peer) {.gcsafe.} =
|
proc addPeer*(pool: PeerPool, peer: Peer) {.gcsafe.} =
|
||||||
doAssert(peer.remote notin pool.connectedNodes)
|
doAssert(peer.remote notin pool.connectedNodes)
|
||||||
pool.connectedNodes[peer.remote] = peer
|
pool.connectedNodes[peer.remote] = peer
|
||||||
{.gcsafe.}:
|
connected_peers.inc()
|
||||||
peerGauge.inc()
|
|
||||||
for o in pool.observers.values:
|
for o in pool.observers.values:
|
||||||
if not o.onPeerConnected.isNil:
|
if not o.onPeerConnected.isNil:
|
||||||
if o.protocol.isNil or peer.supports(o.protocol):
|
if o.protocol.isNil or peer.supports(o.protocol):
|
||||||
|
|
|
@ -795,8 +795,7 @@ proc removePeer(network: EthereumNode, peer: Peer) =
|
||||||
# between which side disconnects first.
|
# between which side disconnects first.
|
||||||
if network.peerPool != nil and not peer.remote.isNil and peer.remote in network.peerPool.connectedNodes:
|
if network.peerPool != nil and not peer.remote.isNil and peer.remote in network.peerPool.connectedNodes:
|
||||||
network.peerPool.connectedNodes.del(peer.remote)
|
network.peerPool.connectedNodes.del(peer.remote)
|
||||||
{.gcsafe.}:
|
connected_peers.dec()
|
||||||
peerGauge.dec()
|
|
||||||
|
|
||||||
# Note: we need to do this check as disconnect (and thus removePeer)
|
# Note: we need to do this check as disconnect (and thus removePeer)
|
||||||
# currently can get called before the dispatcher is initialized.
|
# currently can get called before the dispatcher is initialized.
|
||||||
|
|
Loading…
Reference in New Issue