From b405ad180c44fd2e8c507b66f240fee215ad2a32 Mon Sep 17 00:00:00 2001 From: Csaba Kiraly Date: Wed, 7 May 2025 11:14:11 +0200 Subject: [PATCH] fixup: use RLock on txFromPeer Signed-off-by: Csaba Kiraly --- eth/fetcher/tx_fetcher.go | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/eth/fetcher/tx_fetcher.go b/eth/fetcher/tx_fetcher.go index 8388fb4170..2b7ddb6dd8 100644 --- a/eth/fetcher/tx_fetcher.go +++ b/eth/fetcher/tx_fetcher.go @@ -203,7 +203,7 @@ type TxFetcher struct { // txFromPeer stores where we received a transaction from txFromPeer map[common.Hash]string // should be protected by mutex - txFromPeerMutex sync.Mutex + txFromPeerMutex sync.RWMutex // Callbacks hasTx func(common.Hash) bool // Retrieves a tx from the local txpool @@ -1047,6 +1047,8 @@ func rotateStrings(slice []string, n int) { } func (f *TxFetcher) TxFromPeer(hash common.Hash) (string, bool) { + f.txFromPeerMutex.RLock() + defer f.txFromPeerMutex.RUnlock() provenance, ok := f.txFromPeer[hash] return provenance, ok }