github.com/avahowell/sia@v0.5.1-beta.0.20160524050156-83dcc3d37c94/siac/hostdbcmd.go (about) 1 package main 2 3 import ( 4 "fmt" 5 6 "github.com/spf13/cobra" 7 8 "github.com/NebulousLabs/Sia/api" 9 "github.com/NebulousLabs/Sia/modules" 10 ) 11 12 var ( 13 hostdbCmd = &cobra.Command{ 14 Use: "hostdb", 15 Short: "View or modify the host database", 16 Long: "Add and remove hosts, or list active hosts on the network.", 17 Run: wrap(hostdbcmd), 18 } 19 ) 20 21 func hostdbcmd() { 22 info := new(api.ActiveHosts) 23 err := getAPI("/renter/hosts/active", info) 24 if err != nil { 25 die("Could not fetch host list:", err) 26 } 27 if len(info.Hosts) == 0 { 28 fmt.Println("No known active hosts") 29 return 30 } 31 fmt.Println("Active hosts:") 32 for _, host := range info.Hosts { 33 price := host.StoragePrice.Mul(modules.BlockBytesPerMonthTerabyte) 34 fmt.Printf("\t%v - %v / TB / Month\n", host.NetAddress, currencyUnits(price)) 35 } 36 }