mirror of
https://github.com/ethereum/go-ethereum.git
synced 2026-07-25 06:06:44 +00:00
fixup: use RLock on txFromPeer
Signed-off-by: Csaba Kiraly <csaba.kiraly@gmail.com>
This commit is contained in:
parent
041ba30ae3
commit
b405ad180c
1 changed files with 3 additions and 1 deletions
|
|
@ -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
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in a new issue