forked from TrueCloudLab/frostfs-node
[#584] pkg/innerring: Stop using deprecated methods
Signed-off-by: Pavel Karpy <carpawell@nspcc.ru>
This commit is contained in:
parent
91f010e0a9
commit
057ebf9d51
11 changed files with 65 additions and 44 deletions
|
@ -100,14 +100,7 @@ func newEpochTimer(args *epochTimerArgs) *timer.BlockTimer {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
var err error
|
err := args.cnrWrapper.StopEstimation(epochN - 1)
|
||||||
|
|
||||||
if args.notaryDisabled {
|
|
||||||
err = args.cnrWrapper.StopEstimation(epochN - 1)
|
|
||||||
} else {
|
|
||||||
err = args.cnrWrapper.StopEstimationNotary(epochN - 1)
|
|
||||||
}
|
|
||||||
|
|
||||||
if err != nil {
|
if err != nil {
|
||||||
args.l.Warn("can't stop epoch estimation",
|
args.l.Warn("can't stop epoch estimation",
|
||||||
zap.Uint64("epoch", epochN),
|
zap.Uint64("epoch", epochN),
|
||||||
|
|
|
@ -374,12 +374,12 @@ func New(ctx context.Context, log *zap.Logger, cfg *viper.Viper) (*Server, error
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
|
||||||
balClient, err := balanceWrapper.NewFromMorph(server.morphClient, server.contracts.balance, fee)
|
balClient, err := balanceWrapper.NewFromMorph(server.morphClient, server.contracts.balance, fee, balanceWrapper.TryNotary())
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
|
||||||
repClient, err := repWrapper.NewFromMorph(server.morphClient, server.contracts.reputation, fee)
|
repClient, err := repWrapper.NewFromMorph(server.morphClient, server.contracts.reputation, fee, repWrapper.TryNotary())
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
|
|
@ -29,11 +29,7 @@ func (np *Processor) processNewEpoch(epoch uint64) {
|
||||||
}
|
}
|
||||||
|
|
||||||
if epoch > 0 { // estimates are invalid in genesis epoch
|
if epoch > 0 { // estimates are invalid in genesis epoch
|
||||||
if np.notaryDisabled {
|
|
||||||
err = np.containerWrp.StartEstimation(epoch - 1)
|
err = np.containerWrp.StartEstimation(epoch - 1)
|
||||||
} else {
|
|
||||||
err = np.containerWrp.StartEstimationNotary(epoch - 1)
|
|
||||||
}
|
|
||||||
|
|
||||||
if err != nil {
|
if err != nil {
|
||||||
np.log.Warn("can't start container size estimation",
|
np.log.Warn("can't start container size estimation",
|
||||||
|
|
|
@ -41,14 +41,7 @@ func (rp *Processor) processPut(epoch uint64, id reputation.PeerID, value reputa
|
||||||
args.SetPeerID(id)
|
args.SetPeerID(id)
|
||||||
args.SetValue(value)
|
args.SetValue(value)
|
||||||
|
|
||||||
var err error
|
err := rp.reputationWrp.Put(args)
|
||||||
|
|
||||||
if rp.notaryDisabled {
|
|
||||||
err = rp.reputationWrp.Put(args)
|
|
||||||
} else {
|
|
||||||
err = rp.reputationWrp.PutViaNotary(args)
|
|
||||||
}
|
|
||||||
|
|
||||||
if err != nil {
|
if err != nil {
|
||||||
rp.log.Warn("can't send approval tx for reputation value",
|
rp.log.Warn("can't send approval tx for reputation value",
|
||||||
zap.String("peer_id", hex.EncodeToString(id.ToV2().GetPublicKey())),
|
zap.String("peer_id", hex.EncodeToString(id.ToV2().GetPublicKey())),
|
||||||
|
|
|
@ -215,14 +215,7 @@ func (s settlementDeps) Transfer(sender, recipient *owner.ID, amount *big.Int, d
|
||||||
Details: details,
|
Details: details,
|
||||||
}
|
}
|
||||||
|
|
||||||
var err error
|
err := s.balanceClient.TransferX(params)
|
||||||
|
|
||||||
if s.notaryDisabled {
|
|
||||||
err = s.balanceClient.TransferX(params)
|
|
||||||
} else {
|
|
||||||
err = s.balanceClient.TransferXNotary(params)
|
|
||||||
}
|
|
||||||
|
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.Error("could not send transfer transaction for audit",
|
log.Error("could not send transfer transaction for audit",
|
||||||
zap.String("error", err.Error()),
|
zap.String("error", err.Error()),
|
||||||
|
|
|
@ -18,6 +18,8 @@ type TransferPrm struct {
|
||||||
|
|
||||||
// TransferX transfers p.Amount of GASe-12 from p.From to p.To
|
// TransferX transfers p.Amount of GASe-12 from p.From to p.To
|
||||||
// with details p.Details through direct smart contract call.
|
// with details p.Details through direct smart contract call.
|
||||||
|
//
|
||||||
|
// If TryNotary is provided, calls notary contract.
|
||||||
func (w *Wrapper) TransferX(p TransferPrm) error {
|
func (w *Wrapper) TransferX(p TransferPrm) error {
|
||||||
return w.transferX(false, p)
|
return w.transferX(false, p)
|
||||||
}
|
}
|
||||||
|
@ -46,11 +48,5 @@ func (w *Wrapper) transferX(notary bool, p TransferPrm) error {
|
||||||
args.SetAmount(p.Amount)
|
args.SetAmount(p.Amount)
|
||||||
args.SetDetails(p.Details)
|
args.SetDetails(p.Details)
|
||||||
|
|
||||||
// invoke smart contract call
|
return w.client.TransferX(args)
|
||||||
f := w.client.TransferX
|
|
||||||
if notary {
|
|
||||||
f = w.client.TransferXNotary
|
|
||||||
}
|
|
||||||
|
|
||||||
return f(args)
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -22,9 +22,33 @@ type Wrapper struct {
|
||||||
client *balance.Client
|
client *balance.Client
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Option allows to set an optional
|
||||||
|
// parameter of ClientWrapper.
|
||||||
|
type Option func(*opts)
|
||||||
|
|
||||||
|
type opts []client.StaticClientOption
|
||||||
|
|
||||||
|
func defaultOpts() *opts {
|
||||||
|
return new(opts)
|
||||||
|
}
|
||||||
|
|
||||||
|
// TryNotaryInvoke returns option to enable
|
||||||
|
// notary invocation tries.
|
||||||
|
func TryNotary() Option {
|
||||||
|
return func(o *opts) {
|
||||||
|
*o = append(*o, client.TryNotary())
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// NewFromMorph returns the wrapper instance from the raw morph client.
|
// NewFromMorph returns the wrapper instance from the raw morph client.
|
||||||
func NewFromMorph(cli *client.Client, contract util.Uint160, fee fixedn.Fixed8) (*Wrapper, error) {
|
func NewFromMorph(cli *client.Client, contract util.Uint160, fee fixedn.Fixed8, opts ...Option) (*Wrapper, error) {
|
||||||
staticClient, err := client.NewStatic(cli, contract, fee)
|
o := defaultOpts()
|
||||||
|
|
||||||
|
for i := range opts {
|
||||||
|
opts[i](o)
|
||||||
|
}
|
||||||
|
|
||||||
|
staticClient, err := client.NewStatic(cli, contract, fee, ([]client.StaticClientOption)(*o)...)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, fmt.Errorf("could not create static client of Balance contract: %w", err)
|
return nil, fmt.Errorf("could not create static client of Balance contract: %w", err)
|
||||||
}
|
}
|
||||||
|
|
|
@ -58,7 +58,7 @@ func Put(w *Wrapper, cnr *container.Container) (*cid.ID, error) {
|
||||||
// Returns calculated container identifier and any error
|
// Returns calculated container identifier and any error
|
||||||
// encountered that caused the saving to interrupt.
|
// encountered that caused the saving to interrupt.
|
||||||
//
|
//
|
||||||
// If TryNotary is provided, call notary contract.
|
// If TryNotary is provided, calls notary contract.
|
||||||
func (w *Wrapper) Put(cnr, key, sig, token []byte) error {
|
func (w *Wrapper) Put(cnr, key, sig, token []byte) error {
|
||||||
if len(sig) == 0 || len(key) == 0 {
|
if len(sig) == 0 || len(key) == 0 {
|
||||||
return errNilArgument
|
return errNilArgument
|
||||||
|
|
|
@ -32,6 +32,8 @@ func (p *PutArgs) SetValue(v reputation.GlobalTrust) {
|
||||||
}
|
}
|
||||||
|
|
||||||
// Put invokes direct call of "put reputation value" method of reputation contract.
|
// Put invokes direct call of "put reputation value" method of reputation contract.
|
||||||
|
//
|
||||||
|
// If TryNotary is provided, calls notary contract.
|
||||||
func (w *ClientWrapper) Put(v PutArgs) error {
|
func (w *ClientWrapper) Put(v PutArgs) error {
|
||||||
args, err := preparePutArgs(v)
|
args, err := preparePutArgs(v)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
|
|
@ -13,9 +13,33 @@ import (
|
||||||
// client which implements storage of reputation values.
|
// client which implements storage of reputation values.
|
||||||
type ClientWrapper reputation.Client
|
type ClientWrapper reputation.Client
|
||||||
|
|
||||||
|
// Option allows to set an optional
|
||||||
|
// parameter of ClientWrapper.
|
||||||
|
type Option func(*opts)
|
||||||
|
|
||||||
|
type opts []client.StaticClientOption
|
||||||
|
|
||||||
|
func defaultOpts() *opts {
|
||||||
|
return new(opts)
|
||||||
|
}
|
||||||
|
|
||||||
|
// TryNotaryInvoke returns option to enable
|
||||||
|
// notary invocation tries.
|
||||||
|
func TryNotary() Option {
|
||||||
|
return func(o *opts) {
|
||||||
|
*o = append(*o, client.TryNotary())
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// NewFromMorph returns the wrapper instance from the raw morph client.
|
// NewFromMorph returns the wrapper instance from the raw morph client.
|
||||||
func NewFromMorph(cli *client.Client, contract util.Uint160, fee fixedn.Fixed8) (*ClientWrapper, error) {
|
func NewFromMorph(cli *client.Client, contract util.Uint160, fee fixedn.Fixed8, opts ...Option) (*ClientWrapper, error) {
|
||||||
staticClient, err := client.NewStatic(cli, contract, fee)
|
o := defaultOpts()
|
||||||
|
|
||||||
|
for i := range opts {
|
||||||
|
opts[i](o)
|
||||||
|
}
|
||||||
|
|
||||||
|
staticClient, err := client.NewStatic(cli, contract, fee, ([]client.StaticClientOption)(*o)...)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, fmt.Errorf("could not create static client of reputation contract: %w", err)
|
return nil, fmt.Errorf("could not create static client of reputation contract: %w", err)
|
||||||
}
|
}
|
||||||
|
|
|
@ -99,7 +99,7 @@ func (s StaticClient) TestInvoke(method string, args ...interface{}) ([]stackite
|
||||||
|
|
||||||
// NotaryInvoke calls NotaryInvoke method of Client with static internal
|
// NotaryInvoke calls NotaryInvoke method of Client with static internal
|
||||||
// script hash. Panics if notary support was not enabled in underlying
|
// script hash. Panics if notary support was not enabled in underlying
|
||||||
// moprh client.
|
// morph client.
|
||||||
//
|
//
|
||||||
// Deprecated: provide TryNotary() option to NewStatic and use Invoke.
|
// Deprecated: provide TryNotary() option to NewStatic and use Invoke.
|
||||||
func (s StaticClient) NotaryInvoke(method string, args ...interface{}) error {
|
func (s StaticClient) NotaryInvoke(method string, args ...interface{}) error {
|
||||||
|
|
Loading…
Reference in a new issue