diff --git a/chain_commands.go b/chain_commands.go index 78f2ef2..c62040e 100644 --- a/chain_commands.go +++ b/chain_commands.go @@ -32,6 +32,7 @@ const chainExplorerExample = chainExplorerCommandPath + " --data-dir ~/.lethean/ const chainSyncExample = chainSyncCommandPath + "\n" + chainSyncCommandPath + " --daemon\n" + chainSyncCommandPath + " --stop" +const chainCommandExample = chainExplorerExample + "\n" + chainSyncExample // AddChainCommands registers the `chain` command group on a Cobra root. // @@ -54,7 +55,7 @@ func AddChainCommands(root *cobra.Command) { Use: ChainCommandName, Short: "Manage the Lethean blockchain node", Long: "Manage the Lethean blockchain node: sync and explore.", - Example: chainExplorerExample + "\n" + chainSyncExample, + Example: chainCommandExample, Args: cobra.NoArgs, } diff --git a/commands_test.go b/commands_test.go index ac715ec..becbc1e 100644 --- a/commands_test.go +++ b/commands_test.go @@ -22,7 +22,7 @@ func TestAddChainCommands_Good_RegistersParent(t *testing.T) { assert.Equal(t, ChainCommandName, chainCmd.Name()) assert.Equal(t, "Manage the Lethean blockchain node", chainCmd.Short) assert.Equal(t, "Manage the Lethean blockchain node: sync and explore.", chainCmd.Long) - assert.Equal(t, chainExplorerExample+"\n"+chainSyncExample, chainCmd.Example) + assert.Equal(t, chainCommandExample, chainCmd.Example) } func TestAddChainCommands_Good_HasSubcommands(t *testing.T) { diff --git a/sync_command.go b/sync_command.go index 2adbe74..47ba9a6 100644 --- a/sync_command.go +++ b/sync_command.go @@ -23,6 +23,8 @@ import ( "github.com/spf13/cobra" ) +const chainSyncDisplayName = ChainCommandName + " " + chainSyncCommandName + // newChainSyncCommand builds the `chain sync` command family. // // Example: @@ -82,9 +84,9 @@ func runChainSyncForeground(dataDir, seed string, testnet bool) error { ctx, cancel := signal.NotifyContext(context.Background(), os.Interrupt, syscall.SIGTERM) defer cancel() - log.Println("Starting headless P2P synchronisation...") + log.Printf("Starting %s in foreground...", chainSyncDisplayName) runChainSyncLoop(ctx, blockchain, &chainConfig, hardForks, resolvedSeed) - log.Println("Sync stopped.") + log.Printf("%s stopped.", chainSyncDisplayName) return nil } @@ -123,7 +125,7 @@ func runChainSyncDaemon(dataDir, seed string, testnet bool) error { defer cancel() syncDaemon.SetReady(true) - log.Println("Sync daemon started.") + log.Printf("%s daemon started.", chainSyncDisplayName) var wg sync.WaitGroup wg.Add(1) @@ -153,6 +155,6 @@ func stopChainSyncDaemon(dataDir string) error { return coreerr.E("stopChainSyncDaemon", fmt.Sprintf("signal process %d", pid), err) } - log.Printf("Sent SIGTERM to sync daemon (PID %d)", pid) + log.Printf("Sent SIGTERM to %s daemon (PID %d)", chainSyncDisplayName, pid) return nil } diff --git a/sync_loop.go b/sync_loop.go index da355a5..96a1270 100644 --- a/sync_loop.go +++ b/sync_loop.go @@ -36,7 +36,7 @@ func runChainSyncLoop(ctx context.Context, blockchain *chain.Chain, chainConfig } if err := runChainSyncOnce(ctx, blockchain, chainConfig, opts, seed); err != nil { - log.Printf("sync: %v (retrying in 10s)", err) + log.Printf("%s: %v (retrying in 10s)", chainSyncDisplayName, err) select { case <-ctx.Done(): return