Skip to content

Commit

Permalink
readding mutex
Browse files Browse the repository at this point in the history
  • Loading branch information
srene committed May 2, 2024
1 parent b343287 commit a25d74b
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion block/manager.go
Original file line number Diff line number Diff line change
Expand Up @@ -238,6 +238,7 @@ func (m *Manager) onNodeHealthStatus(event pubsub.Message) {
// TODO: move to gossip.go
// onNewGossippedBlock will take a block and apply it
func (m *Manager) onNewGossipedBlock(event pubsub.Message) {
m.retrieverMutex.Lock() // needed to protect blockCache access
m.logger.Debug("Received new block event", "eventData", event.Data(), "cachedBlocks", len(m.blockCache))
eventData := event.Data().(p2p.GossipedBlock)
block := eventData.Block
Expand All @@ -251,7 +252,7 @@ func (m *Manager) onNewGossipedBlock(event pubsub.Message) {
}
m.logger.Debug("caching block", "block height", block.Header.Height, "store height", m.Store.Height())
}

m.retrieverMutex.Unlock() // have to give this up as it's locked again in attempt apply, and we're not re-entrant
if block.Header.Height == nextHeight {
err := m.attemptApplyCachedBlocks()
if err != nil {
Expand Down

0 comments on commit a25d74b

Please sign in to comment.