From 8dc088b4dd159b984c3238b6ac963c6fb1de81a5 Mon Sep 17 00:00:00 2001 From: Jakub Sztandera Date: Wed, 9 Oct 2019 22:02:08 +0200 Subject: [PATCH 1/3] Clear up confusion around arguments Signed-off-by: Jakub Sztandera --- cli/net.go | 5 +++-- cli/send.go | 5 +++-- cli/wallet.go | 10 ++++++---- 3 files changed, 12 insertions(+), 8 deletions(-) diff --git a/cli/net.go b/cli/net.go index b48b81413..22d3b0a3a 100644 --- a/cli/net.go +++ b/cli/net.go @@ -66,8 +66,9 @@ var netListen = &cli.Command{ } var netConnect = &cli.Command{ - Name: "connect", - Usage: "Connect to a peer", + Name: "connect", + Usage: "Connect to a peer", + ArgsUsage: "", Action: func(cctx *cli.Context) error { api, closer, err := GetAPI(cctx) if err != nil { diff --git a/cli/send.go b/cli/send.go index 81e40e750..4727af706 100644 --- a/cli/send.go +++ b/cli/send.go @@ -9,8 +9,9 @@ import ( ) var sendCmd = &cli.Command{ - Name: "send", - Usage: "send funds between accounts", + Name: "send", + Usage: "Send funds between accounts", + ArgsUsage: " ", Flags: []cli.Flag{ &cli.StringFlag{ Name: "source", diff --git a/cli/wallet.go b/cli/wallet.go index 2752a8f1e..6361f5c69 100644 --- a/cli/wallet.go +++ b/cli/wallet.go @@ -26,8 +26,9 @@ var walletCmd = &cli.Command{ } var walletNew = &cli.Command{ - Name: "new", - Usage: "Generate a new key of the given type (bls or secp256k1)", + Name: "new", + Usage: "Generate a new key of the given type", + ArgsUsage: "[bls|secp256k1]", Action: func(cctx *cli.Context) error { api, closer, err := GetFullNodeAPI(cctx) if err != nil { @@ -76,8 +77,9 @@ var walletList = &cli.Command{ } var walletBalance = &cli.Command{ - Name: "balance", - Usage: "get account balance", + Name: "balance", + Usage: "Get account balance", + ArgsUsage: "[account address]", Action: func(cctx *cli.Context) error { api, closer, err := GetFullNodeAPI(cctx) if err != nil { From 2a9ab727c8203faae1a58ba39b9d1e6bf01bd336 Mon Sep 17 00:00:00 2001 From: Jakub Sztandera Date: Wed, 9 Oct 2019 22:18:53 +0200 Subject: [PATCH 2/3] Make version print nicely License: MIT Signed-off-by: Jakub Sztandera --- api/api.go | 7 +++++++ build/version.go | 5 +++++ node/impl/common.go | 3 ++- 3 files changed, 14 insertions(+), 1 deletion(-) diff --git a/api/api.go b/api/api.go index 13e564818..ccdcb0313 100644 --- a/api/api.go +++ b/api/api.go @@ -2,6 +2,7 @@ package api import ( "context" + "fmt" "github.com/ipfs/go-cid" "github.com/ipfs/go-filestore" @@ -9,6 +10,7 @@ import ( "github.com/libp2p/go-libp2p-core/network" "github.com/libp2p/go-libp2p-core/peer" + "github.com/filecoin-project/go-lotus/build" "github.com/filecoin-project/go-lotus/chain/address" "github.com/filecoin-project/go-lotus/chain/store" "github.com/filecoin-project/go-lotus/chain/types" @@ -173,6 +175,11 @@ type Version struct { // TODO: git commit / os / genesis cid? } +func (v Version) String() string { + vM, vm, vp := build.VersionInts(v.APIVersion) + return fmt.Sprintf("%s+api%d.%d.%d", v.Version, vM, vm, vp) +} + type Import struct { Status filestore.Status Key cid.Cid diff --git a/build/version.go b/build/version.go index 339a6bf8a..33109762d 100644 --- a/build/version.go +++ b/build/version.go @@ -19,3 +19,8 @@ const ( MinorMask = 0xffff00 PatchMask = 0xffffff ) + +// VersionInts returns (major, minor, patch) versions +func VersionInts(version uint32) (uint32, uint32, uint32) { + return (version & MajorMask) >> 16, (version & MinorMask) >> 8, version & PatchMask +} diff --git a/node/impl/common.go b/node/impl/common.go index 571760c5e..0e2080212 100644 --- a/node/impl/common.go +++ b/node/impl/common.go @@ -85,7 +85,8 @@ func (a *CommonAPI) ID(context.Context) (peer.ID, error) { func (a *CommonAPI) Version(context.Context) (api.Version, error) { return api.Version{ - Version: build.Version, + Version: build.Version, + APIVersion: build.APIVersion, }, nil } From 79ee959a90a24ace657986b55f577753d89cc308 Mon Sep 17 00:00:00 2001 From: Jakub Sztandera Date: Wed, 9 Oct 2019 22:23:04 +0200 Subject: [PATCH 3/3] Use log.Warn License: MIT Signed-off-by: Jakub Sztandera --- node/modules/lp2p/pnet.go | 4 ++-- storage/miner.go | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/node/modules/lp2p/pnet.go b/node/modules/lp2p/pnet.go index c388448c2..ffae463f8 100644 --- a/node/modules/lp2p/pnet.go +++ b/node/modules/lp2p/pnet.go @@ -43,8 +43,8 @@ func PNetChecker(repo repo.Repo, ph host.Host, lc fx.Lifecycle) error { select { case <-t.C: if len(ph.Network().Peers()) == 0 { - log.Warning("We are in private network and have no peers.") - log.Warning("This might be configuration mistake.") + log.Warn("We are in private network and have no peers.") + log.Warn("This might be configuration mistake.") } case <-done: return diff --git a/storage/miner.go b/storage/miner.go index 3ade17757..ef8045231 100644 --- a/storage/miner.go +++ b/storage/miner.go @@ -102,7 +102,7 @@ func (m *Miner) handlePostingSealedSectors(ctx context.Context) { if !ok { // TODO: set some state variable so that this state can be // visible via some status command - log.Warning("sealed sector channel closed, aborting process") + log.Warn("sealed sector channel closed, aborting process") return } @@ -112,7 +112,7 @@ func (m *Miner) handlePostingSealedSectors(ctx context.Context) { } case <-ctx.Done(): - log.Warning("exiting seal posting routine") + log.Warn("exiting seal posting routine") return } }