diff options
Diffstat (limited to 'dex/handler.go')
-rw-r--r-- | dex/handler.go | 17 |
1 files changed, 16 insertions, 1 deletions
diff --git a/dex/handler.go b/dex/handler.go index 21322e4e0..3c8d25ea3 100644 --- a/dex/handler.go +++ b/dex/handler.go @@ -1037,10 +1037,25 @@ func (pm *ProtocolManager) BroadcastPullVotes( } func (pm *ProtocolManager) txBroadcastLoop() { + queueSizeMax := common.StorageSize(100 * 1024) // 100 KB + currentSize := common.StorageSize(0) + txs := make(types.Transactions, 0) for { select { + case <-time.After(500 * time.Millisecond): + pm.BroadcastTxs(txs) + txs = txs[:0] + currentSize = 0 case event := <-pm.txsCh: - pm.BroadcastTxs(event.Txs) + txs = append(txs, event.Txs...) + for _, tx := range event.Txs { + currentSize += tx.Size() + } + if currentSize >= queueSizeMax { + pm.BroadcastTxs(txs) + txs = txs[:0] + currentSize = 0 + } // Err() channel will be closed when unsubscribing. case <-pm.txsSub.Err(): |