forked from TrueCloudLab/frostfs-node
[#1513] Upgrade NeoFS SDK Go with changed netmap
package
Signed-off-by: Leonard Lyubich <leonard@nspcc.ru>
This commit is contained in:
parent
24b4c1ecf4
commit
21d2f8f861
70 changed files with 878 additions and 992 deletions
|
@ -9,13 +9,9 @@ import (
|
|||
"github.com/nspcc-dev/neofs-node/cmd/neofs-cli/internal/common"
|
||||
"github.com/nspcc-dev/neofs-node/cmd/neofs-cli/internal/commonflags"
|
||||
"github.com/nspcc-dev/neofs-node/cmd/neofs-cli/internal/key"
|
||||
nmClient "github.com/nspcc-dev/neofs-node/pkg/morph/client/netmap"
|
||||
"github.com/nspcc-dev/neofs-sdk-go/netmap"
|
||||
"github.com/spf13/cobra"
|
||||
)
|
||||
|
||||
type netCfgWriter cobra.Command
|
||||
|
||||
var netInfoCmd = &cobra.Command{
|
||||
Use: "netinfo",
|
||||
Short: "Get information about NeoFS network",
|
||||
|
@ -39,21 +35,23 @@ var netInfoCmd = &cobra.Command{
|
|||
|
||||
cmd.Printf("Time per block: %s\n", time.Duration(netInfo.MsPerBlock())*time.Millisecond)
|
||||
|
||||
netCfg := netInfo.NetworkConfig()
|
||||
const format = " %s: %v\n"
|
||||
|
||||
cmd.Println("NeoFS network configuration")
|
||||
cmd.Println("NeoFS network configuration (system)")
|
||||
cmd.Printf(format, "Audit fee", netInfo.AuditFee())
|
||||
cmd.Printf(format, "Storage price", netInfo.StoragePrice())
|
||||
cmd.Printf(format, "Container fee", netInfo.ContainerFee())
|
||||
cmd.Printf(format, "EigenTrust alpha", netInfo.EigenTrustAlpha())
|
||||
cmd.Printf(format, "Number of EigenTrust iterations", netInfo.NumberOfEigenTrustIterations())
|
||||
cmd.Printf(format, "Epoch duration", netInfo.EpochDuration())
|
||||
cmd.Printf(format, "Inner Ring candidate fee", netInfo.IRCandidateFee())
|
||||
cmd.Printf(format, "Maximum object size", netInfo.MaxObjectSize())
|
||||
cmd.Printf(format, "Withdrawal fee", netInfo.WithdrawalFee())
|
||||
|
||||
err = nmClient.WriteConfig((*netCfgWriter)(cmd), func(f func(key []byte, val []byte) error) error {
|
||||
var err error
|
||||
|
||||
netCfg.IterateParameters(func(prm *netmap.NetworkParameter) bool {
|
||||
err = f(prm.Key(), prm.Value())
|
||||
return err != nil
|
||||
})
|
||||
|
||||
return err
|
||||
cmd.Println("NeoFS network configuration (other)")
|
||||
netInfo.IterateRawNetworkParameters(func(name string, value []byte) {
|
||||
cmd.Printf(format, name, hex.EncodeToString(value))
|
||||
})
|
||||
common.ExitOnErr(cmd, "read config: %w", err)
|
||||
},
|
||||
}
|
||||
|
||||
|
@ -61,57 +59,3 @@ func initNetInfoCmd() {
|
|||
commonflags.Init(netInfoCmd)
|
||||
commonflags.InitAPI(netInfoCmd)
|
||||
}
|
||||
|
||||
func (x *netCfgWriter) print(name string, v interface{}, unknown bool) {
|
||||
var sUnknown string
|
||||
|
||||
if unknown {
|
||||
sUnknown = " (unknown)"
|
||||
}
|
||||
|
||||
(*cobra.Command)(x).Printf(" %s%s: %v\n", name, sUnknown, v)
|
||||
}
|
||||
|
||||
func (x *netCfgWriter) UnknownParameter(k string, v []byte) {
|
||||
x.print(k, hex.EncodeToString(v), true)
|
||||
}
|
||||
|
||||
func (x *netCfgWriter) MaxObjectSize(v uint64) {
|
||||
x.print("Maximum object size", v, false)
|
||||
}
|
||||
|
||||
func (x *netCfgWriter) BasicIncomeRate(v uint64) {
|
||||
x.print("Basic income rate", v, false)
|
||||
}
|
||||
|
||||
func (x *netCfgWriter) AuditFee(v uint64) {
|
||||
x.print("Audit fee", v, false)
|
||||
}
|
||||
|
||||
func (x *netCfgWriter) EpochDuration(v uint64) {
|
||||
x.print("Epoch duration", v, false)
|
||||
}
|
||||
|
||||
func (x *netCfgWriter) ContainerFee(v uint64) {
|
||||
x.print("Container fee", v, false)
|
||||
}
|
||||
|
||||
func (x *netCfgWriter) ContainerAliasFee(v uint64) {
|
||||
x.print("Container alias fee", v, false)
|
||||
}
|
||||
|
||||
func (x *netCfgWriter) EigenTrustIterations(v uint64) {
|
||||
x.print("Number EigenTrust of iterations", v, false)
|
||||
}
|
||||
|
||||
func (x *netCfgWriter) EigenTrustAlpha(v float64) {
|
||||
x.print("EigenTrust α", v, false)
|
||||
}
|
||||
|
||||
func (x *netCfgWriter) InnerRingCandidateFee(v uint64) {
|
||||
x.print("Inner Ring candidate fee", v, false)
|
||||
}
|
||||
|
||||
func (x *netCfgWriter) WithdrawFee(v uint64) {
|
||||
x.print("Withdraw fee", v, false)
|
||||
}
|
||||
|
|
|
@ -37,7 +37,7 @@ func initNodeInfoCmd() {
|
|||
nodeInfoCmd.Flags().Bool(nodeInfoJSONFlag, false, "print node info in JSON format")
|
||||
}
|
||||
|
||||
func prettyPrintNodeInfo(cmd *cobra.Command, i *netmap.NodeInfo) {
|
||||
func prettyPrintNodeInfo(cmd *cobra.Command, i netmap.NodeInfo) {
|
||||
isJSON, _ := cmd.Flags().GetBool(nodeInfoJSONFlag)
|
||||
if isJSON {
|
||||
common.PrettyPrintJSON(cmd, i, "node info")
|
||||
|
@ -45,12 +45,24 @@ func prettyPrintNodeInfo(cmd *cobra.Command, i *netmap.NodeInfo) {
|
|||
}
|
||||
|
||||
cmd.Println("key:", hex.EncodeToString(i.PublicKey()))
|
||||
cmd.Println("state:", i.State())
|
||||
netmap.IterateAllAddresses(i, func(s string) {
|
||||
|
||||
var stateWord string
|
||||
switch {
|
||||
default:
|
||||
stateWord = "<undefined>"
|
||||
case i.IsOnline():
|
||||
stateWord = "online"
|
||||
case i.IsOffline():
|
||||
stateWord = "offline"
|
||||
}
|
||||
|
||||
cmd.Println("state:", stateWord)
|
||||
|
||||
netmap.IterateNetworkEndpoints(i, func(s string) {
|
||||
cmd.Println("address:", s)
|
||||
})
|
||||
|
||||
for _, attribute := range i.Attributes() {
|
||||
cmd.Printf("attribute: %s=%s\n", attribute.Key(), attribute.Value())
|
||||
}
|
||||
i.IterateAttributes(func(key, value string) {
|
||||
cmd.Printf("attribute: %s=%s\n", key, value)
|
||||
})
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue