2022-05-31 06:53:54 +00:00
|
|
|
package netmap
|
2020-08-04 14:46:12 +00:00
|
|
|
|
|
|
|
import (
|
2020-11-06 13:23:31 +00:00
|
|
|
"encoding/hex"
|
2021-10-14 08:27:08 +00:00
|
|
|
"time"
|
2021-06-22 19:48:33 +00:00
|
|
|
|
2021-02-19 08:03:34 +00:00
|
|
|
"github.com/nspcc-dev/neo-go/pkg/config/netmode"
|
2021-10-28 14:48:46 +00:00
|
|
|
internalclient "github.com/nspcc-dev/neofs-node/cmd/neofs-cli/internal/client"
|
2022-05-18 11:03:40 +00:00
|
|
|
"github.com/nspcc-dev/neofs-node/cmd/neofs-cli/internal/common"
|
2022-05-18 09:22:02 +00:00
|
|
|
"github.com/nspcc-dev/neofs-node/cmd/neofs-cli/internal/commonflags"
|
2022-05-31 06:53:54 +00:00
|
|
|
"github.com/nspcc-dev/neofs-node/cmd/neofs-cli/internal/key"
|
2020-08-04 14:46:12 +00:00
|
|
|
"github.com/spf13/cobra"
|
|
|
|
)
|
|
|
|
|
2022-05-31 06:53:54 +00:00
|
|
|
var netInfoCmd = &cobra.Command{
|
|
|
|
Use: "netinfo",
|
|
|
|
Short: "Get information about NeoFS network",
|
|
|
|
Long: "Get information about NeoFS network",
|
2021-06-20 23:02:56 +00:00
|
|
|
Run: func(cmd *cobra.Command, args []string) {
|
2022-05-31 06:53:54 +00:00
|
|
|
p := key.GetOrGenerate(cmd)
|
|
|
|
cli := internalclient.GetSDKClientByFlag(cmd, p, commonflags.RPC)
|
2021-04-21 12:27:32 +00:00
|
|
|
|
2022-05-31 06:53:54 +00:00
|
|
|
var prm internalclient.NetworkInfoPrm
|
|
|
|
prm.SetClient(cli)
|
2020-08-04 14:46:12 +00:00
|
|
|
|
2021-10-28 14:48:46 +00:00
|
|
|
res, err := internalclient.NetworkInfo(prm)
|
2022-05-18 11:03:40 +00:00
|
|
|
common.ExitOnErr(cmd, "rpc error: %w", err)
|
2020-08-04 14:46:12 +00:00
|
|
|
|
2021-10-28 14:48:46 +00:00
|
|
|
netInfo := res.NetworkInfo()
|
|
|
|
|
2022-05-31 06:53:54 +00:00
|
|
|
cmd.Printf("Epoch: %d\n", netInfo.CurrentEpoch())
|
2020-11-06 10:36:32 +00:00
|
|
|
|
2022-05-31 06:53:54 +00:00
|
|
|
magic := netInfo.MagicNumber()
|
|
|
|
cmd.Printf("Network magic: [%s] %d\n", netmode.Magic(magic), magic)
|
2021-04-21 12:27:32 +00:00
|
|
|
|
2022-05-31 06:53:54 +00:00
|
|
|
cmd.Printf("Time per block: %s\n", time.Duration(netInfo.MsPerBlock())*time.Millisecond)
|
2020-11-06 10:36:32 +00:00
|
|
|
|
2022-06-08 23:18:26 +00:00
|
|
|
const format = " %s: %v\n"
|
|
|
|
|
|
|
|
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())
|
2022-09-19 15:31:56 +00:00
|
|
|
cmd.Printf(format, "Homomorphic hashing disabled", netInfo.HomomorphicHashingDisabled())
|
2022-06-08 23:18:26 +00:00
|
|
|
|
|
|
|
cmd.Println("NeoFS network configuration (other)")
|
|
|
|
netInfo.IterateRawNetworkParameters(func(name string, value []byte) {
|
|
|
|
cmd.Printf(format, name, hex.EncodeToString(value))
|
2022-05-31 06:53:54 +00:00
|
|
|
})
|
2020-11-06 10:36:32 +00:00
|
|
|
},
|
|
|
|
}
|
|
|
|
|
2022-05-31 06:53:54 +00:00
|
|
|
func initNetInfoCmd() {
|
|
|
|
commonflags.Init(netInfoCmd)
|
|
|
|
commonflags.InitAPI(netInfoCmd)
|
|
|
|
}
|