[#2075] morph/client: Ignore error if a transaction already exists

Signed-off-by: Evgenii Stratonikov <evgeniy@morphbits.ru>
This commit is contained in:
Evgenii Stratonikov 2022-11-18 12:44:53 +03:00 committed by fyrchik
parent 71853348b9
commit 816c74d185
2 changed files with 14 additions and 1 deletions

View file

@ -37,6 +37,7 @@ Changelog for NeoFS Node
- Concurrent mode changes in the metabase and blobstor (#2057) - Concurrent mode changes in the metabase and blobstor (#2057)
- Panic in IR when performing HEAD requests (#2069) - Panic in IR when performing HEAD requests (#2069)
- Write-cache flush duplication (#2074) - Write-cache flush duplication (#2074)
- Ignore error if a transaction already exists in a morph client (#2075)
### Removed ### Removed
### Updated ### Updated

View file

@ -13,6 +13,7 @@ import (
"github.com/nspcc-dev/neo-go/pkg/crypto/hash" "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/crypto/keys"
"github.com/nspcc-dev/neo-go/pkg/encoding/fixedn" "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" "github.com/nspcc-dev/neo-go/pkg/smartcontract"
sc "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" "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)), big.NewInt(int64(amount)),
[]interface{}{c.acc.PrivateKey().GetScriptHash(), till}) []interface{}{c.acc.PrivateKey().GetScriptHash(), till})
if err != nil { 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", c.logger.Debug("notary deposit invoke",