-
Notifications
You must be signed in to change notification settings - Fork 38
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
neofs-adm: add new command morph netmap-candidates (#2529)
This command lists netmap candidates in the netmap contract. It allows checking if a node has been bootstrapped successfully. Closes #1889.
- Loading branch information
Showing
9 changed files
with
73 additions
and
8 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
2 changes: 1 addition & 1 deletion
2
cmd/neofs-cli/internal/common/netmap.go → cmd/internal/cmdprinter/netmap.go
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,4 @@ | ||
package common | ||
package cmdprinter | ||
|
||
import ( | ||
"encoding/hex" | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
package morph | ||
|
||
import ( | ||
"fmt" | ||
|
||
"github.com/nspcc-dev/neo-go/pkg/rpcclient/invoker" | ||
"github.com/nspcc-dev/neofs-node/cmd/internal/cmdprinter" | ||
"github.com/nspcc-dev/neofs-node/pkg/morph/client/netmap" | ||
"github.com/spf13/cobra" | ||
"github.com/spf13/viper" | ||
) | ||
|
||
func listNetmapCandidatesNodes(cmd *cobra.Command, _ []string) error { | ||
c, err := getN3Client(viper.GetViper()) | ||
if err != nil { | ||
return err | ||
} | ||
|
||
inv := invoker.New(c, nil) | ||
|
||
nnsCs, err := c.GetContractStateByID(1) | ||
if err != nil { | ||
return fmt.Errorf("can't get NNS contract info: %w", err) | ||
} | ||
|
||
nmHash, err := nnsResolveHash(inv, nnsCs.Hash, netmapContract+".neofs") | ||
if err != nil { | ||
return fmt.Errorf("can't get netmap contract hash: %w", err) | ||
} | ||
|
||
res, err := inv.Call(nmHash, "netmapCandidates") | ||
if err != nil { | ||
return fmt.Errorf("can't fetch list of network config keys from the netmap contract: %w", err) | ||
} | ||
if res.State != "HALT" { | ||
return fmt.Errorf("netmap contract returned unexpected exception: %s", res.FaultException) | ||
} | ||
|
||
nm, err := netmap.DecodeNetMap(res.Stack) | ||
|
||
if err != nil { | ||
return fmt.Errorf("unable to decode netmap: %w", err) | ||
} | ||
nodes := nm.Nodes() | ||
for i := range nodes { | ||
cmdprinter.PrettyPrintNodeInfo(cmd, nodes[i], i, "", false) | ||
} | ||
return nil | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters