[#1294] neofs-adm: Check persisted tx status

Signed-off-by: Evgenii Stratonikov <evgeniy@nspcc.ru>
This commit is contained in:
Evgenii Stratonikov 2022-04-05 17:01:59 +03:00 committed by fyrchik
parent 629a4f79cd
commit 55362f0607

View file

@ -14,6 +14,7 @@ import (
"github.com/nspcc-dev/neo-go/pkg/rpc/client" "github.com/nspcc-dev/neo-go/pkg/rpc/client"
"github.com/nspcc-dev/neo-go/pkg/smartcontract/trigger" "github.com/nspcc-dev/neo-go/pkg/smartcontract/trigger"
"github.com/nspcc-dev/neo-go/pkg/util" "github.com/nspcc-dev/neo-go/pkg/util"
"github.com/nspcc-dev/neo-go/pkg/vm"
"github.com/nspcc-dev/neo-go/pkg/wallet" "github.com/nspcc-dev/neo-go/pkg/wallet"
"github.com/nspcc-dev/neofs-node/cmd/neofs-adm/internal/modules/config" "github.com/nspcc-dev/neofs-node/cmd/neofs-adm/internal/modules/config"
"github.com/nspcc-dev/neofs-node/pkg/innerring" "github.com/nspcc-dev/neofs-node/pkg/innerring"
@ -292,17 +293,27 @@ func (c *clientContext) awaitTx(cmd *cobra.Command) error {
at := trigger.Application at := trigger.Application
var retErr error
loop: loop:
for i := range c.Hashes { for i := range c.Hashes {
_, err := c.Client.GetApplicationLog(c.Hashes[i], &at) res, err := c.Client.GetApplicationLog(c.Hashes[i], &at)
if err == nil { if err == nil {
if retErr == nil && len(res.Executions) > 0 && res.Executions[0].VMState != vm.HaltState {
retErr = fmt.Errorf("tx persisted in %s state: %s",
res.Executions[0].VMState, res.Executions[0].FaultException)
}
continue loop continue loop
} }
for { for {
select { select {
case <-tick.C: case <-tick.C:
_, err := c.Client.GetApplicationLog(c.Hashes[i], &at) res, err := c.Client.GetApplicationLog(c.Hashes[i], &at)
if err == nil { if err == nil {
if retErr == nil && len(res.Executions) > 0 && res.Executions[0].VMState != vm.HaltState {
retErr = fmt.Errorf("tx persisted in %s state: %s",
res.Executions[0].VMState, res.Executions[0].FaultException)
}
continue loop continue loop
} }
case <-timer.C: case <-timer.C:
@ -311,7 +322,7 @@ loop:
} }
} }
return nil return retErr
} }
func (c *initializeContext) sendCommitteeTx(script []byte, sysFee int64) error { func (c *initializeContext) sendCommitteeTx(script []byte, sysFee int64) error {