From 620573f63c9176425c75fd407547c2162cb7263f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C8=98tefan=20Talpalaru?= Date: Tue, 16 Jul 2019 12:56:36 +0200 Subject: [PATCH] use new nim-metrics API --- eth/common/utils.nim | 2 +- eth/p2p/peer_pool.nim | 3 +-- eth/p2p/rlpx.nim | 3 +-- 3 files changed, 3 insertions(+), 5 deletions(-) diff --git a/eth/common/utils.nim b/eth/common/utils.nim index 9710a02..84c6ab0 100644 --- a/eth/common/utils.nim +++ b/eth/common/utils.nim @@ -10,5 +10,5 @@ proc parseAddress*(hexString: string): EthAddress = proc `$`*(a: EthAddress): string = a.toHex() -var peerGauge* = newGauge("connected_peers", "number of peers in the pool") +newPublicGauge(connected_peers, "number of peers in the pool") diff --git a/eth/p2p/peer_pool.nim b/eth/p2p/peer_pool.nim index 9365587..3bd1bc5 100644 --- a/eth/p2p/peer_pool.nim +++ b/eth/p2p/peer_pool.nim @@ -110,8 +110,7 @@ proc getRandomBootnode(p: PeerPool): Option[Node] = proc addPeer*(pool: PeerPool, peer: Peer) {.gcsafe.} = doAssert(peer.remote notin pool.connectedNodes) pool.connectedNodes[peer.remote] = peer - {.gcsafe.}: - peerGauge.inc() + connected_peers.inc() for o in pool.observers.values: if not o.onPeerConnected.isNil: if o.protocol.isNil or peer.supports(o.protocol): diff --git a/eth/p2p/rlpx.nim b/eth/p2p/rlpx.nim index ba0e538..fbfbfe4 100644 --- a/eth/p2p/rlpx.nim +++ b/eth/p2p/rlpx.nim @@ -795,8 +795,7 @@ proc removePeer(network: EthereumNode, peer: Peer) = # between which side disconnects first. if network.peerPool != nil and not peer.remote.isNil and peer.remote in network.peerPool.connectedNodes: network.peerPool.connectedNodes.del(peer.remote) - {.gcsafe.}: - peerGauge.dec() + connected_peers.dec() # Note: we need to do this check as disconnect (and thus removePeer) # currently can get called before the dispatcher is initialized.