forked from TrueCloudLab/frostfs-node
[#475] morph/client: Ignore "already on chain"
Add checking if returned error contains "already on chain" substring. Do not consider that behavior to be erroneous. Signed-off-by: Pavel Karpy <carpawell@nspcc.ru>
This commit is contained in:
parent
7a25d45f02
commit
bd5ce4535a
1 changed files with 15 additions and 1 deletions
|
@ -1,6 +1,8 @@
|
||||||
package client
|
package client
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
"strings"
|
||||||
|
|
||||||
"github.com/nspcc-dev/neo-go/pkg/core/native/nativenames"
|
"github.com/nspcc-dev/neo-go/pkg/core/native/nativenames"
|
||||||
"github.com/nspcc-dev/neo-go/pkg/core/native/noderoles"
|
"github.com/nspcc-dev/neo-go/pkg/core/native/noderoles"
|
||||||
"github.com/nspcc-dev/neo-go/pkg/core/transaction"
|
"github.com/nspcc-dev/neo-go/pkg/core/transaction"
|
||||||
|
@ -284,7 +286,7 @@ func (c *Client) notaryInvoke(committee bool, contract util.Uint160, method stri
|
||||||
0,
|
0,
|
||||||
c.notary.fallbackTime,
|
c.notary.fallbackTime,
|
||||||
c.acc)
|
c.acc)
|
||||||
if err != nil {
|
if err != nil && !alreadyOnChainError(err) {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -466,3 +468,15 @@ func WithFallbackTime(t uint32) NotaryOption {
|
||||||
c.fallbackTime = t
|
c.fallbackTime = t
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const alreadyOnChainErrorMessage = "already on chain"
|
||||||
|
|
||||||
|
// Neo RPC node can return `core.ErrInvalidAttribute` error with
|
||||||
|
// `conflicting transaction <> is already on chain` message. This
|
||||||
|
// error is expected and ignored. As soon as main tx persisted on
|
||||||
|
// chain everything is fine. This happens because notary contract
|
||||||
|
// requires 5 out of 7 signatures to send main tx, thus last two
|
||||||
|
// notary requests may be processed after main tx appeared on chain.
|
||||||
|
func alreadyOnChainError(err error) bool {
|
||||||
|
return strings.Contains(err.Error(), alreadyOnChainErrorMessage)
|
||||||
|
}
|
||||||
|
|
Loading…
Reference in a new issue