From f44fa5d96f9ff6199476e45db0e091f91141413e Mon Sep 17 00:00:00 2001 From: Fridrik Asmundsson Date: Wed, 29 Mar 2023 13:15:42 +0200 Subject: [PATCH] Use MessageIndex in WaitForMessage --- chain/stmgr/searchwait.go | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/chain/stmgr/searchwait.go b/chain/stmgr/searchwait.go index 6b9adff71..34ecc8fae 100644 --- a/chain/stmgr/searchwait.go +++ b/chain/stmgr/searchwait.go @@ -57,10 +57,15 @@ func (sm *StateManager) WaitForMessage(ctx context.Context, mcid cid.Cid, confid var backFm cid.Cid backSearchWait := make(chan struct{}) go func() { - fts, r, foundMsg, err := sm.searchBackForMsg(ctx, head[0].Val, msg, lookbackLimit, allowReplaced) - if err != nil { - log.Warnf("failed to look back through chain for message: %v", err) - return + fts, r, foundMsg, err := sm.searchForIndexedMsg(ctx, mcid, msg) + + found := (err == nil && r != nil && foundMsg.Defined()) + if !found { + fts, r, foundMsg, err = sm.searchBackForMsg(ctx, head[0].Val, msg, lookbackLimit, allowReplaced) + if err != nil { + log.Warnf("failed to look back through chain for message: %v", err) + return + } } backTs = fts