Log the number of channels broadcasts are sent to

indexv1
Martin Boehm 2018-02-22 23:32:47 +01:00
parent 26c726c771
commit 2260ff61b5
1 changed files with 6 additions and 4 deletions

View File

@ -670,12 +670,14 @@ func (s *SocketIoServer) onSubscribe(c *gosocketio.Channel, req []byte) interfac
// OnNewBlockHash notifies users subscribed to bitcoind/hashblock about new block
func (s *SocketIoServer) OnNewBlockHash(hash string) {
glog.Info("broadcasting new block hash ", hash)
s.server.BroadcastTo("bitcoind/hashblock", "bitcoind/hashblock", hash)
c := s.server.BroadcastTo("bitcoind/hashblock", "bitcoind/hashblock", hash)
glog.Info("broadcasting new block hash ", hash, " to ", c, " channels")
}
// OnNewTxAddr notifies users subscribed to bitcoind/addresstxid about new block
func (s *SocketIoServer) OnNewTxAddr(txid string, addr string) {
glog.Info("broadcasting new txid ", txid, " for addr ", addr)
s.server.BroadcastTo("bitcoind/addresstxid-"+addr, "bitcoind/addresstxid", map[string]string{"address": addr, "txid": txid})
c := s.server.BroadcastTo("bitcoind/addresstxid-"+addr, "bitcoind/addresstxid", map[string]string{"address": addr, "txid": txid})
if c > 0 {
glog.Info("broadcasting new txid ", txid, " for addr ", addr, " to ", c, " channels")
}
}