Skip to content

Commit

Permalink
Merge pull request #597 from libotony/fix-tx-sub
Browse files Browse the repository at this point in the history
fix unexpected race in tx subscription
  • Loading branch information
libotony committed Jul 19, 2023
2 parents b2704f3 + 81b5997 commit f4d2f2a
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions api/subscriptions/pending_tx.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ import (
type pendingTx struct {
txPool *txpool.TxPool
listeners map[chan *tx.Transaction]struct{}
mu sync.RWMutex
mu sync.Mutex
}

func newPendingTx(txPool *txpool.TxPool) *pendingTx {
Expand Down Expand Up @@ -71,7 +71,7 @@ func (p *pendingTx) DispatchLoop(done <-chan struct{}) {
}

func (p *pendingTx) dispatch(tx *tx.Transaction, done <-chan struct{}) {
p.mu.RLock()
p.mu.Lock()
defer p.mu.Unlock()

for lsn := range p.listeners {
Expand Down

0 comments on commit f4d2f2a

Please sign in to comment.