Skip to content

Commit

Permalink
feat: mempool: reintroduce ForEachPendingMessage
Browse files Browse the repository at this point in the history
  • Loading branch information
arajasek committed May 5, 2023
1 parent 854945a commit a73e520
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 7 deletions.
8 changes: 2 additions & 6 deletions chain/messagepool/messagepool.go
Original file line number Diff line number Diff line change
Expand Up @@ -448,12 +448,8 @@ func New(ctx context.Context, api Provider, ds dtypes.MetadataDS, us stmgr.Upgra
return mp, nil
}

func (mp *MessagePool) TryForEachPendingMessage(f func(cid.Cid) error) error {
// avoid deadlocks in splitstore compaction when something else needs to access the blockstore
// while holding the mpool lock
if !mp.lk.TryLock() {
return xerrors.Errorf("mpool TryForEachPendingMessage: could not acquire lock")
}
func (mp *MessagePool) ForEachPendingMessage(f func(cid.Cid) error) error {
mp.lk.Lock()
defer mp.lk.Unlock()

for _, mset := range mp.pending {
Expand Down
2 changes: 1 addition & 1 deletion node/modules/chain.go
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ func MessagePool(lc fx.Lifecycle, mctx helpers.MetricsCtx, us stmgr.UpgradeSched
return mp.Close()
},
})
protector.AddProtector(mp.TryForEachPendingMessage)
protector.AddProtector(mp.ForEachPendingMessage)
return mp, nil
}

Expand Down

0 comments on commit a73e520

Please sign in to comment.