eth/catalyst: pull feed Send out of mutex lock

This commit is contained in:
lightclient 2024-08-19 07:18:31 -06:00
parent 4cd6aa2809
commit bc9f01c3a5
No known key found for this signature in database
GPG key ID: 75C916AFEE20183E
2 changed files with 4 additions and 4 deletions

View file

@ -54,11 +54,10 @@ type newWithdrawalsEvent struct{ Withdrawals types.Withdrawals }
// add queues a withdrawal for future inclusion. // add queues a withdrawal for future inclusion.
func (w *withdrawalQueue) add(withdrawal *types.Withdrawal) error { func (w *withdrawalQueue) add(withdrawal *types.Withdrawal) error {
w.mu.Lock() w.mu.Lock()
defer w.mu.Unlock()
w.pending = append(w.pending, withdrawal) w.pending = append(w.pending, withdrawal)
w.feed.Send(newWithdrawalsEvent{types.Withdrawals{withdrawal}}) w.mu.Unlock()
w.feed.Send(newWithdrawalsEvent{types.Withdrawals{withdrawal}})
return nil return nil
} }

View file

@ -54,7 +54,8 @@ func (a *simulatedBeaconAPI) loop() {
) )
defer newTxsSub.Unsubscribe() defer newTxsSub.Unsubscribe()
defer newWxsSub.Unsubscribe() defer newWxsSub.Unsubscribe()
// a background thread which signals to the simulator when to commit
// A background thread which signals to the simulator when to commit
// based on messages over doCommit. // based on messages over doCommit.
go func() { go func() {
for _ = range doCommit { for _ = range doCommit {