forked from TrueCloudLab/frostfs-node
[#995] neofs-adm: split out tx context
Signed-off-by: Evgenii Stratonikov <evgeniy@nspcc.ru>
This commit is contained in:
parent
02be6c83a6
commit
fba8890224
4 changed files with 38 additions and 15 deletions
|
@ -3,11 +3,22 @@ package morph
|
|||
import (
|
||||
"context"
|
||||
"errors"
|
||||
"time"
|
||||
|
||||
"github.com/nspcc-dev/neo-go/pkg/core/transaction"
|
||||
"github.com/nspcc-dev/neo-go/pkg/rpc/client"
|
||||
"github.com/nspcc-dev/neo-go/pkg/util"
|
||||
"github.com/spf13/cobra"
|
||||
"github.com/spf13/viper"
|
||||
)
|
||||
|
||||
type clientContext struct {
|
||||
Client *client.Client
|
||||
Hashes []util.Uint256
|
||||
WaitDuration time.Duration
|
||||
PollInterval time.Duration
|
||||
}
|
||||
|
||||
func getN3Client(v *viper.Viper) (*client.Client, error) {
|
||||
ctx := context.Background() // FIXME(@fyrchik): timeout context
|
||||
endpoint := v.GetString(endpointFlag)
|
||||
|
@ -23,3 +34,17 @@ func getN3Client(v *viper.Viper) (*client.Client, error) {
|
|||
}
|
||||
return c, nil
|
||||
}
|
||||
|
||||
func (c *clientContext) sendTx(tx *transaction.Transaction, cmd *cobra.Command, await bool) error {
|
||||
h, err := c.Client.SendRawTransaction(tx)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
c.Hashes = append(c.Hashes, h)
|
||||
|
||||
if await {
|
||||
return c.awaitTx(cmd)
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue