diff --git a/pkg/morph/client/container/wrapper/container.go b/pkg/morph/client/container/wrapper/container.go index e9c68cc6..aa49a58e 100644 --- a/pkg/morph/client/container/wrapper/container.go +++ b/pkg/morph/client/container/wrapper/container.go @@ -48,6 +48,8 @@ func Put(w *Wrapper, cnr *container.Container, sig *pkg.Signature) (*container.I // // Returns calculated container identifier and any error // encountered that caused the saving to interrupt. +// +// If TryNotary is provided, call notary contract. func (w *Wrapper) Put(cnr, key, sig []byte) error { if len(sig) == 0 || len(key) == 0 { return errNilArgument @@ -136,6 +138,8 @@ func Delete(w *Wrapper, cid *container.ID, sig *pkg.Signature) error { // // Returns any error encountered that caused // the removal to interrupt. +// +// If TryNotary is provided, calls notary contract. func (w *Wrapper) Delete(cid, signature []byte) error { if len(signature) == 0 { return errNilArgument diff --git a/pkg/morph/client/container/wrapper/eacl.go b/pkg/morph/client/container/wrapper/eacl.go index 7a23d347..e63702eb 100644 --- a/pkg/morph/client/container/wrapper/eacl.go +++ b/pkg/morph/client/container/wrapper/eacl.go @@ -56,6 +56,8 @@ func (w *Wrapper) GetEACL(cid *containerSDK.ID) (*eacl.Table, *pkg.Signature, er // along with sig.Key() and sig.Sign(). // // Returns error if table is nil. +// +// If TryNotary is provided, calls notary contract. func PutEACL(w *Wrapper, table *eacl.Table, sig *pkg.Signature) error { if table == nil { return errNilArgument diff --git a/pkg/morph/client/container/wrapper/estimations.go b/pkg/morph/client/container/wrapper/estimations.go index 0c17c2b5..4ab76fe2 100644 --- a/pkg/morph/client/container/wrapper/estimations.go +++ b/pkg/morph/client/container/wrapper/estimations.go @@ -14,6 +14,9 @@ func (w *Wrapper) StartEstimation(epoch uint64) error { // StartEstimationNotary votes to produce start estimation notification through // notary contract. +// +// Deprecated: provide TryNotary() option to NewFromMorph +// and use StartEstimation. func (w *Wrapper) StartEstimationNotary(epoch uint64) error { args := container.StartEstimation{} args.SetEpoch(int64(epoch)) @@ -31,6 +34,9 @@ func (w *Wrapper) StopEstimation(epoch uint64) error { // StopEstimationNotary votes to produce stop estimation notification through // notary contract. +// +// Deprecated: provide TryNotary() option to NewFromMorph +// and use StopEstimation. func (w *Wrapper) StopEstimationNotary(epoch uint64) error { args := container.StopEstimation{} args.SetEpoch(int64(epoch)) diff --git a/pkg/morph/client/container/wrapper/wrapper.go b/pkg/morph/client/container/wrapper/wrapper.go index 32ff7e1e..5db748d9 100644 --- a/pkg/morph/client/container/wrapper/wrapper.go +++ b/pkg/morph/client/container/wrapper/wrapper.go @@ -21,9 +21,33 @@ type Wrapper struct { client *container.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. -func NewFromMorph(cli *client.Client, contract util.Uint160, fee fixedn.Fixed8) (*Wrapper, error) { - staticClient, err := client.NewStatic(cli, contract, fee) +func NewFromMorph(cli *client.Client, contract util.Uint160, fee fixedn.Fixed8, opts ...Option) (*Wrapper, error) { + o := defaultOpts() + + for i := range opts { + opts[i](o) + } + + staticClient, err := client.NewStatic(cli, contract, fee, ([]client.StaticClientOption)(*o)...) if err != nil { return nil, fmt.Errorf("can't create container static client: %w", err) }