From e9d22230254111474742ec694354c405dd07f3db Mon Sep 17 00:00:00 2001 From: Mikers Date: Tue, 28 Mar 2023 08:11:23 +0000 Subject: [PATCH] disallow infinite loop, since in testing this only runs once --- chain/messagepool/messagepool.go | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/chain/messagepool/messagepool.go b/chain/messagepool/messagepool.go index 70d15ee52..3af9b1572 100644 --- a/chain/messagepool/messagepool.go +++ b/chain/messagepool/messagepool.go @@ -770,8 +770,9 @@ func (mp *MessagePool) Add(ctx context.Context, m *types.SignedMessage) error { _, _ = mp.api.GetActorAfter(m.Message.From, tmpCurTs) _, _ = mp.getStateNonce(ctx, m.Message.From, tmpCurTs) + cacheSecondTime := true //if the newly acquired Ts is not the one we just cached, let go of the lock, cache it and open the lock again and repeat.... - for { + for cacheSecondTime { mp.curTsLk.Lock() writeCurTs := mp.curTs @@ -782,6 +783,7 @@ func (mp *MessagePool) Add(ctx context.Context, m *types.SignedMessage) error { tmpCurTs = writeCurTs _, _ = mp.api.GetActorAfter(m.Message.From, tmpCurTs) _, _ = mp.getStateNonce(ctx, m.Message.From, tmpCurTs) + cacheSecondTime = false }