forked from TrueCloudLab/frostfs-contract
[OBJECT-7758] Add ListFullSubjects method to Frostfsid client
Signed-off-by: d.zverev <d.zverev@yadro.com>
This commit is contained in:
parent
42344eaa69
commit
b4ca8cb3f9
1 changed files with 28 additions and 0 deletions
|
@ -8,12 +8,15 @@ import (
|
||||||
"github.com/nspcc-dev/neo-go/pkg/core/state"
|
"github.com/nspcc-dev/neo-go/pkg/core/state"
|
||||||
"github.com/nspcc-dev/neo-go/pkg/core/transaction"
|
"github.com/nspcc-dev/neo-go/pkg/core/transaction"
|
||||||
"github.com/nspcc-dev/neo-go/pkg/crypto/keys"
|
"github.com/nspcc-dev/neo-go/pkg/crypto/keys"
|
||||||
|
"github.com/nspcc-dev/neo-go/pkg/io"
|
||||||
"github.com/nspcc-dev/neo-go/pkg/neorpc/result"
|
"github.com/nspcc-dev/neo-go/pkg/neorpc/result"
|
||||||
"github.com/nspcc-dev/neo-go/pkg/rpcclient/actor"
|
"github.com/nspcc-dev/neo-go/pkg/rpcclient/actor"
|
||||||
"github.com/nspcc-dev/neo-go/pkg/rpcclient/notary"
|
"github.com/nspcc-dev/neo-go/pkg/rpcclient/notary"
|
||||||
"github.com/nspcc-dev/neo-go/pkg/rpcclient/unwrap"
|
"github.com/nspcc-dev/neo-go/pkg/rpcclient/unwrap"
|
||||||
"github.com/nspcc-dev/neo-go/pkg/rpcclient/waiter"
|
"github.com/nspcc-dev/neo-go/pkg/rpcclient/waiter"
|
||||||
|
"github.com/nspcc-dev/neo-go/pkg/smartcontract/callflag"
|
||||||
"github.com/nspcc-dev/neo-go/pkg/util"
|
"github.com/nspcc-dev/neo-go/pkg/util"
|
||||||
|
"github.com/nspcc-dev/neo-go/pkg/vm/emit"
|
||||||
"github.com/nspcc-dev/neo-go/pkg/vm/stackitem"
|
"github.com/nspcc-dev/neo-go/pkg/vm/stackitem"
|
||||||
"github.com/nspcc-dev/neo-go/pkg/vm/vmstate"
|
"github.com/nspcc-dev/neo-go/pkg/vm/vmstate"
|
||||||
"github.com/nspcc-dev/neo-go/pkg/wallet"
|
"github.com/nspcc-dev/neo-go/pkg/wallet"
|
||||||
|
@ -404,6 +407,31 @@ func (c Client) ListNamespaces() ([]*Namespace, error) {
|
||||||
return parseNamespaces(items)
|
return parseNamespaces(items)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (c Client) ListFullSubjects(hashes []util.Uint160) ([]*Subject, error) {
|
||||||
|
w := io.NewBufBinWriter()
|
||||||
|
|
||||||
|
for _, hash := range hashes {
|
||||||
|
emit.AppCall(w.BinWriter, c.contract, getSubjectMethod, callflag.All, hash)
|
||||||
|
}
|
||||||
|
|
||||||
|
inv, err := c.act.Run(w.Bytes())
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
subjects := make([]*Subject, 0)
|
||||||
|
|
||||||
|
for i := range inv.Stack {
|
||||||
|
val := inv.Stack[i].Value().([]stackitem.Item)
|
||||||
|
subject, err := parseSubject(val)
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
subjects = append(subjects, subject)
|
||||||
|
}
|
||||||
|
|
||||||
|
return subjects, nil
|
||||||
|
}
|
||||||
|
|
||||||
// ListNamespaceSubjects gets all subjects from namespace.
|
// ListNamespaceSubjects gets all subjects from namespace.
|
||||||
func (c Client) ListNamespaceSubjects(namespace string) ([]util.Uint160, error) {
|
func (c Client) ListNamespaceSubjects(namespace string) ([]util.Uint160, error) {
|
||||||
return unwrapArrayOfUint160(commonclient.ReadIteratorItems(c.act, iteratorBatchSize, c.contract, listNamespaceSubjectsMethod, namespace))
|
return unwrapArrayOfUint160(commonclient.ReadIteratorItems(c.act, iteratorBatchSize, c.contract, listNamespaceSubjectsMethod, namespace))
|
||||||
|
|
Loading…
Reference in a new issue