@@ -462,8 +462,14 @@ func (h *handler) BroadcastBlock(block *types.Block, propagate bool) {
462
462
// already have the given transaction.
463
463
func (h * handler ) BroadcastTransactions (txs types.Transactions ) {
464
464
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
+
465
470
txset = make (map [* ethPeer ][]common.Hash ) // Set peer->hash to transfer directly
466
471
annos = make (map [* ethPeer ][]common.Hash ) // Set peer->hash to announce
472
+
467
473
)
468
474
// Broadcast transactions to a batch of peers not knowing about it
469
475
for _ , tx := range txs {
@@ -477,19 +483,24 @@ func (h *handler) BroadcastTransactions(txs types.Transactions) {
477
483
for _ , peer := range peers [numDirect :] {
478
484
annos [peer ] = append (annos [peer ], tx .Hash ())
479
485
}
480
- log .Trace ("Broadcast transaction" , "hash" , tx .Hash (), "direct" , numDirect ,
481
- "announce" , len (peers )- numDirect )
482
486
}
483
487
for peer , hashes := range txset {
488
+ directPeers ++
489
+ directCount += len (hashes )
484
490
peer .AsyncSendTransactions (hashes )
485
491
}
486
492
for peer , hashes := range annos {
493
+ annoPeers ++
494
+ annoCount += len (hashes )
487
495
if peer .Version () >= eth .ETH65 {
488
496
peer .AsyncSendPooledTransactionHashes (hashes )
489
497
} else {
490
498
peer .AsyncSendTransactions (hashes )
491
499
}
492
500
}
501
+ log .Debug ("Transaction broadcast" , "txs" , len (txs ),
502
+ "announce packs" , annoPeers , "announced hashes" , annoCount ,
503
+ "tx packs" , directPeers , "broadcast txs" , directCount )
493
504
}
494
505
495
506
// minedBroadcastLoop sends mined blocks to connected peers.
@@ -507,12 +518,10 @@ func (h *handler) minedBroadcastLoop() {
507
518
// txBroadcastLoop announces new transactions to connected peers.
508
519
func (h * handler ) txBroadcastLoop () {
509
520
defer h .wg .Done ()
510
-
511
521
for {
512
522
select {
513
523
case event := <- h .txsCh :
514
524
h .BroadcastTransactions (event .Txs )
515
-
516
525
case <- h .txsSub .Err ():
517
526
return
518
527
}
0 commit comments