From 816c74d1857f2f0940af27da029413b3716c2eeb Mon Sep 17 00:00:00 2001 From: Evgenii Stratonikov Date: Fri, 18 Nov 2022 12:44:53 +0300 Subject: [PATCH] [#2075] morph/client: Ignore error if a transaction already exists Signed-off-by: Evgenii Stratonikov --- CHANGELOG.md | 1 + pkg/morph/client/notary.go | 14 +++++++++++++- 2 files changed, 14 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 999dd151..d602b0e6 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -37,6 +37,7 @@ Changelog for NeoFS Node - Concurrent mode changes in the metabase and blobstor (#2057) - Panic in IR when performing HEAD requests (#2069) - Write-cache flush duplication (#2074) +- Ignore error if a transaction already exists in a morph client (#2075) ### Removed ### Updated diff --git a/pkg/morph/client/notary.go b/pkg/morph/client/notary.go index 26d57171..2c0cbed5 100644 --- a/pkg/morph/client/notary.go +++ b/pkg/morph/client/notary.go @@ -13,6 +13,7 @@ import ( "github.com/nspcc-dev/neo-go/pkg/crypto/hash" "github.com/nspcc-dev/neo-go/pkg/crypto/keys" "github.com/nspcc-dev/neo-go/pkg/encoding/fixedn" + "github.com/nspcc-dev/neo-go/pkg/neorpc" "github.com/nspcc-dev/neo-go/pkg/smartcontract" sc "github.com/nspcc-dev/neo-go/pkg/smartcontract" "github.com/nspcc-dev/neo-go/pkg/util" @@ -175,7 +176,18 @@ func (c *Client) DepositNotary(amount fixedn.Fixed8, delta uint32) (res util.Uin big.NewInt(int64(amount)), []interface{}{c.acc.PrivateKey().GetScriptHash(), till}) if err != nil { - return util.Uint256{}, fmt.Errorf("can't make notary deposit: %w", err) + if !errors.Is(err, neorpc.ErrAlreadyExists) { + return util.Uint256{}, fmt.Errorf("can't make notary deposit: %w", err) + } + + // Transaction is already in mempool waiting to be processed. + // This is an expected situation if we restart the service. + c.logger.Debug("notary deposit has already been made", + zap.Int64("amount", int64(amount)), + zap.Int64("expire_at", till), + zap.Uint32("vub", vub), + zap.Error(err)) + return util.Uint256{}, nil } c.logger.Debug("notary deposit invoke",