Skip to content

Commit

Permalink
Complete with old blocks, then subscribe for new
Browse files Browse the repository at this point in the history
  • Loading branch information
khssnv committed Mar 15, 2024
1 parent 2ae98a8 commit 792dd79
Showing 1 changed file with 6 additions and 4 deletions.
10 changes: 6 additions & 4 deletions blockchain/client.go
Original file line number Diff line number Diff line change
Expand Up @@ -116,10 +116,6 @@ func (c *Client) RegisterEventsListener(begin types.BlockNumber, callback Events
}
}

c.mu.Lock()
c.eventsListeners[idx] = callback
c.mu.Unlock()

stopped := false

go func() {
Expand Down Expand Up @@ -189,6 +185,12 @@ func (c *Client) RegisterEventsListener(begin types.BlockNumber, callback Events
callback(events, header.Number, set.Block)
}
}

c.mu.Lock()
if !stopped {
c.eventsListeners[idx] = callback
}
c.mu.Unlock()
}()

once := sync.Once{}
Expand Down

0 comments on commit 792dd79

Please sign in to comment.