Skip to content

Commit e740064

Browse files
committed
eth: modify logging output of tx broadcast
1 parent dda4412 commit e740064

File tree

1 file changed

+13
-4
lines changed

1 file changed

+13
-4
lines changed

eth/handler.go

Lines changed: 13 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -462,8 +462,14 @@ func (h *handler) BroadcastBlock(block *types.Block, propagate bool) {
462462
// already have the given transaction.
463463
func (h *handler) BroadcastTransactions(txs types.Transactions) {
464464
var (
465+
annoCount int // Count of announcements made
466+
annoPeers int
467+
directCount int // Count of the txs sent directly to peers
468+
directPeers int // Count of the peers that were sent transactions directly
469+
465470
txset = make(map[*ethPeer][]common.Hash) // Set peer->hash to transfer directly
466471
annos = make(map[*ethPeer][]common.Hash) // Set peer->hash to announce
472+
467473
)
468474
// Broadcast transactions to a batch of peers not knowing about it
469475
for _, tx := range txs {
@@ -477,19 +483,24 @@ func (h *handler) BroadcastTransactions(txs types.Transactions) {
477483
for _, peer := range peers[numDirect:] {
478484
annos[peer] = append(annos[peer], tx.Hash())
479485
}
480-
log.Trace("Broadcast transaction", "hash", tx.Hash(), "direct", numDirect,
481-
"announce", len(peers)-numDirect)
482486
}
483487
for peer, hashes := range txset {
488+
directPeers++
489+
directCount += len(hashes)
484490
peer.AsyncSendTransactions(hashes)
485491
}
486492
for peer, hashes := range annos {
493+
annoPeers++
494+
annoCount += len(hashes)
487495
if peer.Version() >= eth.ETH65 {
488496
peer.AsyncSendPooledTransactionHashes(hashes)
489497
} else {
490498
peer.AsyncSendTransactions(hashes)
491499
}
492500
}
501+
log.Debug("Transaction broadcast", "txs", len(txs),
502+
"announce packs", annoPeers, "announced hashes", annoCount,
503+
"tx packs", directPeers, "broadcast txs", directCount)
493504
}
494505

495506
// minedBroadcastLoop sends mined blocks to connected peers.
@@ -507,12 +518,10 @@ func (h *handler) minedBroadcastLoop() {
507518
// txBroadcastLoop announces new transactions to connected peers.
508519
func (h *handler) txBroadcastLoop() {
509520
defer h.wg.Done()
510-
511521
for {
512522
select {
513523
case event := <-h.txsCh:
514524
h.BroadcastTransactions(event.Txs)
515-
516525
case <-h.txsSub.Err():
517526
return
518527
}

0 commit comments

Comments
 (0)