Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

large tx count #1881

Merged
merged 1 commit into from
Jan 3, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 10 additions & 3 deletions ctxc/handler.go
Original file line number Diff line number Diff line change
Expand Up @@ -966,6 +966,8 @@ func (pm *ProtocolManager) BroadcastBlock(block *types.Block, propagate bool) {
// already have the given transaction.
func (pm *ProtocolManager) BroadcastTransactions(txs types.Transactions) {
var (
largeTxs int // Number of large transactions to announce only

annoCount int // Count of announcements made
annoPeers int
directCount int // Count of the txs sent directly to peers
Expand All @@ -979,9 +981,14 @@ func (pm *ProtocolManager) BroadcastTransactions(txs types.Transactions) {
peers := pm.peers.PeersWithoutTx(tx.Hash())
// Send the tx unconditionally to a subset of our peers
var numDirect int
if tx.Size() <= txMaxBroadcastSize {

switch {
case tx.Size() > txMaxBroadcastSize:
largeTxs++
default:
numDirect = int(math.Sqrt(float64(len(peers))))
}
// Send the tx unconditionally to a subset of our peers
for _, peer := range peers[:numDirect] {
txset[peer] = append(txset[peer], tx.Hash())
}
Expand All @@ -1004,7 +1011,7 @@ func (pm *ProtocolManager) BroadcastTransactions(txs types.Transactions) {
peer.AsyncSendTransactions(hashes)
}
}
log.Debug("Transaction broadcast", "txs", len(txs),
log.Debug("Transaction broadcast", "txs", len(txs)-largeTxs, "largetxs", largeTxs,
"announce packs", annoPeers, "announced hashes", annoCount,
"tx packs", directPeers, "broadcast txs", directCount)
}
Expand All @@ -1021,9 +1028,9 @@ func (pm *ProtocolManager) minedBroadcastLoop() {
}
}

// txBroadcastLoop announces new transactions to connected peers.
func (pm *ProtocolManager) txBroadcastLoop() {
defer pm.wg.Done()

for {
select {
case event := <-pm.txsCh:
Expand Down