diff options
author | Javier Peletier <jm@epiclabs.io> | 2018-03-05 23:00:03 +0800 |
---|---|---|
committer | Javier Peletier <jm@epiclabs.io> | 2018-03-05 23:00:03 +0800 |
commit | 13b566e06e9aae28bddde431c7d53a335272411a (patch) | |
tree | b649ab64ca2c00327500aed5c826d5a6f454a6cf /swarm/network/hive.go | |
parent | 1e72271f571f916691c5c18b8f0c4c5f7e0445c3 (diff) | |
parent | 1548518644071c8fa8eb98a8cb8a8c4603400acb (diff) | |
download | dexon-13b566e06e9aae28bddde431c7d53a335272411a.tar dexon-13b566e06e9aae28bddde431c7d53a335272411a.tar.gz dexon-13b566e06e9aae28bddde431c7d53a335272411a.tar.bz2 dexon-13b566e06e9aae28bddde431c7d53a335272411a.tar.lz dexon-13b566e06e9aae28bddde431c7d53a335272411a.tar.xz dexon-13b566e06e9aae28bddde431c7d53a335272411a.tar.zst dexon-13b566e06e9aae28bddde431c7d53a335272411a.zip |
accounts/abi: Add one-parameter event test case from enriquefynn/unpack_one_arg_event
Diffstat (limited to 'swarm/network/hive.go')
-rw-r--r-- | swarm/network/hive.go | 10 |
1 files changed, 10 insertions, 0 deletions
diff --git a/swarm/network/hive.go b/swarm/network/hive.go index 2504a4610..8404ffcc2 100644 --- a/swarm/network/hive.go +++ b/swarm/network/hive.go @@ -24,6 +24,7 @@ import ( "github.com/ethereum/go-ethereum/common" "github.com/ethereum/go-ethereum/log" + "github.com/ethereum/go-ethereum/metrics" "github.com/ethereum/go-ethereum/p2p/discover" "github.com/ethereum/go-ethereum/p2p/netutil" "github.com/ethereum/go-ethereum/swarm/network/kademlia" @@ -39,6 +40,12 @@ import ( // connections and disconnections are reported and relayed // to keep the nodetable uptodate +var ( + peersNumGauge = metrics.NewRegisteredGauge("network.peers.num", nil) + addPeerCounter = metrics.NewRegisteredCounter("network.addpeer.count", nil) + removePeerCounter = metrics.NewRegisteredCounter("network.removepeer.count", nil) +) + type Hive struct { listenAddr func() string callInterval uint64 @@ -192,6 +199,7 @@ func (self *Hive) Start(id discover.NodeID, listenAddr func() string, connectPee func (self *Hive) keepAlive() { alarm := time.NewTicker(time.Duration(self.callInterval)).C for { + peersNumGauge.Update(int64(self.kad.Count())) select { case <-alarm: if self.kad.DBCount() > 0 { @@ -223,6 +231,7 @@ func (self *Hive) Stop() error { // called at the end of a successful protocol handshake func (self *Hive) addPeer(p *peer) error { + addPeerCounter.Inc(1) defer func() { select { case self.more <- true: @@ -247,6 +256,7 @@ func (self *Hive) addPeer(p *peer) error { // called after peer disconnected func (self *Hive) removePeer(p *peer) { + removePeerCounter.Inc(1) log.Debug(fmt.Sprintf("bee %v removed", p)) self.kad.Off(p, saveSync) select { |