From fcc53c7a0d825d788dcfe7b45d5ad4485700041c Mon Sep 17 00:00:00 2001 From: Csaba Kiraly Date: Tue, 29 Apr 2025 14:49:18 +0200 Subject: [PATCH] eth/handler: fix unaligned 64-bit atomic operation error Signed-off-by: Csaba Kiraly --- eth/handler.go | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/eth/handler.go b/eth/handler.go index 099d4c963b..6404104a79 100644 --- a/eth/handler.go +++ b/eth/handler.go @@ -121,7 +121,7 @@ type handler struct { txpool txPool chain *core.BlockChain maxPeers int - lastDirect int64 // Last number of peers we sent transactions to, used to stabilize the randomness + lastDirect atomic.Int64 // Last number of peers we sent transactions to, used to stabilize the randomness downloader *downloader.Downloader txFetcher *fetcher.TxFetcher @@ -491,13 +491,13 @@ func (h *handler) BroadcastTransactions(txs types.Transactions) { // Use some hysteresis to avoid oscillating between two values, stabilising the modulus in the peer selection // If the number of peers is small, use a minimum of 1 peer var directInt int64 - lastDirect := atomic.LoadInt64(&h.lastDirect) + lastDirect := h.lastDirect.Load() if int64(sqrtPeers) >= lastDirect { directInt = max(int64(sqrtPeers), 1) } else { directInt = max(min(int64(sqrtPeers+directPeersHysteresis), lastDirect), 1) } - atomic.StoreInt64(&h.lastDirect, directInt) + h.lastDirect.Store(directInt) direct := big.NewInt(directInt) // Number of peers to send directly to total := big.NewInt(directInt * directInt) // Stabilise total peer count a bit based on sqrt peers