[#902] adm: Do not create session when dumping hashes
Some checks failed
Vulncheck / Vulncheck (pull_request) Successful in 2m37s
DCO action / DCO (pull_request) Successful in 2m35s
Tests and linters / Lint (pull_request) Successful in 4m33s
Tests and linters / Tests (1.20) (pull_request) Failing after 4m31s
Build / Build Components (1.20) (pull_request) Successful in 4m21s
Build / Build Components (1.21) (pull_request) Successful in 4m17s
Tests and linters / Staticcheck (pull_request) Successful in 4m39s
Tests and linters / Tests (1.21) (pull_request) Successful in 9m1s
Tests and linters / Tests with -race (pull_request) Successful in 9m24s
Some checks failed
Vulncheck / Vulncheck (pull_request) Successful in 2m37s
DCO action / DCO (pull_request) Successful in 2m35s
Tests and linters / Lint (pull_request) Successful in 4m33s
Tests and linters / Tests (1.20) (pull_request) Failing after 4m31s
Build / Build Components (1.20) (pull_request) Successful in 4m21s
Build / Build Components (1.21) (pull_request) Successful in 4m17s
Tests and linters / Staticcheck (pull_request) Successful in 4m39s
Tests and linters / Tests (1.21) (pull_request) Successful in 9m1s
Tests and linters / Tests with -race (pull_request) Successful in 9m24s
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
631fff17a3
commit
f43bfb01a8
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