From 43b30a80c19ecc4dda50e81570bf31c9cf37548f Mon Sep 17 00:00:00 2001 From: vyzo Date: Wed, 12 Aug 2020 20:32:41 +0300 Subject: [PATCH] retry PushWithNonce if it fails with ErrTryAgain --- node/impl/full/mpool.go | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/node/impl/full/mpool.go b/node/impl/full/mpool.go index cd6adef6d..33478a176 100644 --- a/node/impl/full/mpool.go +++ b/node/impl/full/mpool.go @@ -148,7 +148,7 @@ func (a *MpoolAPI) MpoolPushMessage(ctx context.Context, msg *types.Message) (*t msg.GasFeeCap = feeCap } - return a.Mpool.PushWithNonce(ctx, msg.From, func(from address.Address, nonce uint64) (*types.SignedMessage, error) { + sign := func(from address.Address, nonce uint64) (*types.SignedMessage, error) { msg.Nonce = nonce if msg.From.Protocol() == address.ID { log.Warnf("Push from ID address (%s), adjusting to %s", msg.From, from) @@ -165,7 +165,17 @@ func (a *MpoolAPI) MpoolPushMessage(ctx context.Context, msg *types.Message) (*t } return a.WalletSignMessage(ctx, from, msg) - }) + } + + var m *types.SignedMessage + var err error +again: + m, err = a.Mpool.PushWithNonce(ctx, msg.From, sign) + if err == messagepool.ErrTryAgain { + log.Debugf("temporary failure while pushing message: %s; retrying", err) + goto again + } + return m, err } func (a *MpoolAPI) MpoolGetNonce(ctx context.Context, addr address.Address) (uint64, error) {