forked from TrueCloudLab/frostfs-node
[#902] adm: Do not create session when dumping hashes
Unless the total number of domains is too big, there is no need to consume resources in neo-go. Signed-off-by: Evgenii Stratonikov <e.stratonikov@yadro.com>
This commit is contained in:
parent
be8607a1f6
commit
a601391719
1 changed files with 11 additions and 1 deletions
|
@ -13,6 +13,7 @@ import (
|
|||
"github.com/nspcc-dev/neo-go/pkg/rpcclient/invoker"
|
||||
"github.com/nspcc-dev/neo-go/pkg/rpcclient/management"
|
||||
"github.com/nspcc-dev/neo-go/pkg/rpcclient/unwrap"
|
||||
"github.com/nspcc-dev/neo-go/pkg/smartcontract"
|
||||
"github.com/nspcc-dev/neo-go/pkg/smartcontract/callflag"
|
||||
"github.com/nspcc-dev/neo-go/pkg/util"
|
||||
"github.com/nspcc-dev/neo-go/pkg/vm/emit"
|
||||
|
@ -143,7 +144,12 @@ func dumpCustomZoneHashes(cmd *cobra.Command, nnsHash util.Uint160, zone string,
|
|||
})
|
||||
}
|
||||
|
||||
sessionID, iter, err := unwrap.SessionIterator(inv.Call(nnsHash, "tokens"))
|
||||
script, err := smartcontract.CreateCallAndPrefetchIteratorScript(nnsHash, "tokens", nnsMaxTokens)
|
||||
if err != nil {
|
||||
return fmt.Errorf("create prefetch script: %w", err)
|
||||
}
|
||||
|
||||
arr, sessionID, iter, err := unwrap.ArrayAndSessionIterator(inv.Run(script))
|
||||
if err != nil {
|
||||
if errors.Is(err, unwrap.ErrNoSessionID) {
|
||||
items, err := unwrap.Array(inv.CallAndExpandIterator(nnsHash, "tokens", nnsMaxTokens))
|
||||
|
@ -160,6 +166,10 @@ func dumpCustomZoneHashes(cmd *cobra.Command, nnsHash util.Uint160, zone string,
|
|||
return err
|
||||
}
|
||||
} else {
|
||||
for i := range arr {
|
||||
processItem(arr[i])
|
||||
}
|
||||
|
||||
defer func() {
|
||||
_ = inv.TerminateSession(sessionID)
|
||||
}()
|
||||
|
|
Loading…
Reference in a new issue