github.com/avahowell/sia@v0.5.1-beta.0.20160524050156-83dcc3d37c94/siac/consensuscmd.go (about) 1 package main 2 3 import ( 4 "fmt" 5 6 "github.com/spf13/cobra" 7 8 "github.com/NebulousLabs/Sia/api" 9 ) 10 11 var ( 12 consensusCmd = &cobra.Command{ 13 Use: "consensus", 14 Short: "Print the current state of consensus", 15 Long: "Print the current state of consensus such as current block, block height, and target.", 16 Run: wrap(consensuscmd), 17 } 18 ) 19 20 // consensuscmd is the handler for the command `siac consensus`. 21 // Prints the current state of consensus. 22 func consensuscmd() { 23 var cg api.ConsensusGET 24 err := getAPI("/consensus", &cg) 25 if err != nil { 26 die("Could not get current consensus state:", err) 27 } 28 fmt.Printf(`Synced: %v 29 Block: %v 30 Height: %v 31 Target: %v 32 `, yesNo(cg.Synced), cg.CurrentBlock, cg.Height, cg.Target) 33 }