mirror of
https://gitlab.com/pulsechaincom/erigon-pulse.git
synced 2025-01-03 09:37:38 +00:00
fix concurrent map write (#1882)
This commit is contained in:
parent
7c60ec3ec0
commit
61c20798db
@ -56,8 +56,8 @@ func (e *Events) AddPendingTxsSubscription(s PendingTxsSubscription) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (e *Events) OnNewHeader(newHeader *types.Header) {
|
func (e *Events) OnNewHeader(newHeader *types.Header) {
|
||||||
e.lock.RLock()
|
e.lock.Lock()
|
||||||
defer e.lock.RUnlock()
|
defer e.lock.Unlock()
|
||||||
for i, sub := range e.headerSubscriptions {
|
for i, sub := range e.headerSubscriptions {
|
||||||
if err := sub(newHeader); err != nil {
|
if err := sub(newHeader); err != nil {
|
||||||
delete(e.headerSubscriptions, i)
|
delete(e.headerSubscriptions, i)
|
||||||
@ -66,8 +66,8 @@ func (e *Events) OnNewHeader(newHeader *types.Header) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (e *Events) OnNewPendingLogs(logs types.Logs) {
|
func (e *Events) OnNewPendingLogs(logs types.Logs) {
|
||||||
e.lock.RLock()
|
e.lock.Lock()
|
||||||
defer e.lock.RUnlock()
|
defer e.lock.Unlock()
|
||||||
for i, sub := range e.pendingLogsSubscriptions {
|
for i, sub := range e.pendingLogsSubscriptions {
|
||||||
if err := sub(logs); err != nil {
|
if err := sub(logs); err != nil {
|
||||||
delete(e.pendingLogsSubscriptions, i)
|
delete(e.pendingLogsSubscriptions, i)
|
||||||
@ -76,8 +76,8 @@ func (e *Events) OnNewPendingLogs(logs types.Logs) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (e *Events) OnNewPendingBlock(block *types.Block) {
|
func (e *Events) OnNewPendingBlock(block *types.Block) {
|
||||||
e.lock.RLock()
|
e.lock.Lock()
|
||||||
defer e.lock.RUnlock()
|
defer e.lock.Unlock()
|
||||||
for i, sub := range e.pendingBlockSubscriptions {
|
for i, sub := range e.pendingBlockSubscriptions {
|
||||||
if err := sub(block); err != nil {
|
if err := sub(block); err != nil {
|
||||||
delete(e.pendingBlockSubscriptions, i)
|
delete(e.pendingBlockSubscriptions, i)
|
||||||
@ -86,8 +86,8 @@ func (e *Events) OnNewPendingBlock(block *types.Block) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (e *Events) OnNewPendingTxs(txs []types.Transaction) {
|
func (e *Events) OnNewPendingTxs(txs []types.Transaction) {
|
||||||
e.lock.RLock()
|
e.lock.Lock()
|
||||||
defer e.lock.RUnlock()
|
defer e.lock.Unlock()
|
||||||
for i, sub := range e.pendingTxsSubscriptions {
|
for i, sub := range e.pendingTxsSubscriptions {
|
||||||
if err := sub(txs); err != nil {
|
if err := sub(txs); err != nil {
|
||||||
delete(e.pendingTxsSubscriptions, i)
|
delete(e.pendingTxsSubscriptions, i)
|
||||||
|
Loading…
Reference in New Issue
Block a user