From 61c20798dbcb614cb419bd36f838528d89539bdc Mon Sep 17 00:00:00 2001 From: Alex Sharov Date: Wed, 5 May 2021 10:16:57 +0700 Subject: [PATCH] fix concurrent map write (#1882) --- ethdb/remote/remotedbserver/events.go | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/ethdb/remote/remotedbserver/events.go b/ethdb/remote/remotedbserver/events.go index 490bae56f..b4f1de16c 100644 --- a/ethdb/remote/remotedbserver/events.go +++ b/ethdb/remote/remotedbserver/events.go @@ -56,8 +56,8 @@ func (e *Events) AddPendingTxsSubscription(s PendingTxsSubscription) { } func (e *Events) OnNewHeader(newHeader *types.Header) { - e.lock.RLock() - defer e.lock.RUnlock() + e.lock.Lock() + defer e.lock.Unlock() for i, sub := range e.headerSubscriptions { if err := sub(newHeader); err != nil { delete(e.headerSubscriptions, i) @@ -66,8 +66,8 @@ func (e *Events) OnNewHeader(newHeader *types.Header) { } func (e *Events) OnNewPendingLogs(logs types.Logs) { - e.lock.RLock() - defer e.lock.RUnlock() + e.lock.Lock() + defer e.lock.Unlock() for i, sub := range e.pendingLogsSubscriptions { if err := sub(logs); err != nil { delete(e.pendingLogsSubscriptions, i) @@ -76,8 +76,8 @@ func (e *Events) OnNewPendingLogs(logs types.Logs) { } func (e *Events) OnNewPendingBlock(block *types.Block) { - e.lock.RLock() - defer e.lock.RUnlock() + e.lock.Lock() + defer e.lock.Unlock() for i, sub := range e.pendingBlockSubscriptions { if err := sub(block); err != nil { delete(e.pendingBlockSubscriptions, i) @@ -86,8 +86,8 @@ func (e *Events) OnNewPendingBlock(block *types.Block) { } func (e *Events) OnNewPendingTxs(txs []types.Transaction) { - e.lock.RLock() - defer e.lock.RUnlock() + e.lock.Lock() + defer e.lock.Unlock() for i, sub := range e.pendingTxsSubscriptions { if err := sub(txs); err != nil { delete(e.pendingTxsSubscriptions, i)