Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

mpool: Don't block node startup loading messages #4411

Merged
merged 1 commit into from
Oct 15, 2020
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
26 changes: 16 additions & 10 deletions chain/messagepool/messagepool.go
Original file line number Diff line number Diff line change
Expand Up @@ -370,11 +370,23 @@ func New(api Provider, ds dtypes.MetadataDS, netName dtypes.NetworkName, j journ
return err
})

if err := mp.loadLocal(); err != nil {
log.Errorf("loading local messages: %+v", err)
}
mp.curTsLk.Lock()
mp.lk.Lock()

go func() {
err := mp.loadLocal()

go mp.runLoop()
mp.lk.Unlock()
mp.curTsLk.Unlock()

if err != nil {
log.Errorf("loading local messages: %+v", err)
}

log.Info("mpool ready")

mp.runLoop()
}()

return mp, nil
}
Expand Down Expand Up @@ -667,9 +679,6 @@ func (mp *MessagePool) addLoaded(m *types.SignedMessage) error {
return err
}

mp.curTsLk.Lock()
defer mp.curTsLk.Unlock()

curTs := mp.curTs

if curTs == nil {
Expand All @@ -685,9 +694,6 @@ func (mp *MessagePool) addLoaded(m *types.SignedMessage) error {
return xerrors.Errorf("minimum expected nonce is %d: %w", snonce, ErrNonceTooLow)
}

mp.lk.Lock()
defer mp.lk.Unlock()

_, err = mp.verifyMsgBeforeAdd(m, curTs, true)
if err != nil {
return err
Expand Down