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
|
|
|
|
2023-03-07 13:38:26 +00:00
|
|
|
internalclient "git.frostfs.info/TrueCloudLab/frostfs-node/cmd/frostfs-cli/internal/client"
|
|
|
|
"git.frostfs.info/TrueCloudLab/frostfs-node/cmd/frostfs-cli/internal/commonflags"
|
|
|
|
"git.frostfs.info/TrueCloudLab/frostfs-node/cmd/frostfs-cli/internal/key"
|
|
|
|
commonCmd "git.frostfs.info/TrueCloudLab/frostfs-node/cmd/internal/common"
|
2021-02-19 08:03:34 +00:00
|
|
|
"github.com/nspcc-dev/neo-go/pkg/config/netmode"
|
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",
|
2023-01-27 10:44:39 +00:00
|
|
|
Short: "Get information about FrostFS network",
|
|
|
|
Long: "Get information about FrostFS 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)
|
2023-01-16 09:20:16 +00:00
|
|
|
commonCmd.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"
|
|
|
|
|
2023-02-03 16:29:25 +00:00
|
|
|
cmd.Println("FrostFS network configuration (system)")
|
2022-06-08 23:18:26 +00:00
|
|
|
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-09-19 15:45:45 +00:00
|
|
|
cmd.Printf(format, "Maintenance mode allowed", netInfo.MaintenanceModeAllowed())
|
2022-06-08 23:18:26 +00:00
|
|
|
|
2023-02-03 16:29:25 +00:00
|
|
|
cmd.Println("FrostFS network configuration (other)")
|
2022-06-08 23:18:26 +00:00
|
|
|
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)
|
|
|
|
}
|