Commit 56313e39 authored by David Vorick's avatar David Vorick

display host score breakdown in contract viewer

parent b742e1e5
......@@ -35,6 +35,21 @@ var (
}
)
// printScoreBreakdown prints the score breakdown of a host, provided the info.
func printScoreBreakdown(info *api.HostdbHostsGET) {
fmt.Println("\n Score Breakdown:")
w := tabwriter.NewWriter(os.Stdout, 0, 0, 2, ' ', 0)
fmt.Fprintf(w, "\t\tAge:\t %.3f\n", info.ScoreBreakdown.AgeAdjustment)
fmt.Fprintf(w, "\t\tBurn:\t %.3f\n", info.ScoreBreakdown.BurnAdjustment)
fmt.Fprintf(w, "\t\tCollateral:\t %.3f\n", info.ScoreBreakdown.CollateralAdjustment)
fmt.Fprintf(w, "\t\tInteraction:\t %.3f\n", info.ScoreBreakdown.InteractionAdjustment)
fmt.Fprintf(w, "\t\tPrice:\t %.3f\n", info.ScoreBreakdown.PriceAdjustment*1e6)
fmt.Fprintf(w, "\t\tStorage:\t %.3f\n", info.ScoreBreakdown.StorageRemainingAdjustment)
fmt.Fprintf(w, "\t\tUptime:\t %.3f\n", info.ScoreBreakdown.UptimeAdjustment)
fmt.Fprintf(w, "\t\tVersion:\t %.3f\n", info.ScoreBreakdown.VersionAdjustment)
w.Flush()
}
func hostdbcmd() {
if !hostdbVerbose {
info := new(api.HostdbActiveGET)
......@@ -285,17 +300,7 @@ func hostdbviewcmd(pubkey string) {
fmt.Fprintln(w, "\t\tVersion:\t", info.Entry.Version)
w.Flush()
fmt.Println("\n Score Breakdown:")
w = tabwriter.NewWriter(os.Stdout, 0, 0, 2, ' ', 0)
fmt.Fprintf(w, "\t\tAge:\t %.3f\n", info.ScoreBreakdown.AgeAdjustment)
fmt.Fprintf(w, "\t\tBurn:\t %.3f\n", info.ScoreBreakdown.BurnAdjustment)
fmt.Fprintf(w, "\t\tCollateral:\t %.3f\n", info.ScoreBreakdown.CollateralAdjustment)
fmt.Fprintf(w, "\t\tInteraction:\t %.3f\n", info.ScoreBreakdown.InteractionAdjustment)
fmt.Fprintf(w, "\t\tPrice:\t %.3f\n", info.ScoreBreakdown.PriceAdjustment*1e6)
fmt.Fprintf(w, "\t\tStorage:\t %.3f\n", info.ScoreBreakdown.StorageRemainingAdjustment)
fmt.Fprintf(w, "\t\tUptime:\t %.3f\n", info.ScoreBreakdown.UptimeAdjustment)
fmt.Fprintf(w, "\t\tVersion:\t %.3f\n", info.ScoreBreakdown.VersionAdjustment)
w.Flush()
printScoreBreakdown(info)
// Compute the total measured uptime and total measured downtime for this
// host.
......
......@@ -335,22 +335,27 @@ func rentercontractsviewcmd(cid string) {
for _, rc := range rc.Contracts {
if rc.ID.String() == cid {
fmt.Printf(`
var hostInfo api.HostdbHostsGET
err = getAPI("/hostdb/hosts/"+rc.HostPublicKey.String(), &hostInfo)
if err != nil {
die("Could not fetch details of host: ", err)
}
fmt.Printf(`
Contract %v
Host: %v (Public Key: %v)
Host: %v (Public Key: %v)
Start Height: %v
End Height: %v
Start Height: %v
End Height: %v
Total cost: %v (Fees: %v)
Funds Allocated: %v
Upload Spending: %v
Storage Spending: %v
Download Spending: %v
Remaining Funds: %v
Total cost: %v (Fees: %v)
Funds Allocated: %v
Upload Spending: %v
Storage Spending: %v
Download Spending: %v
Remaining Funds: %v
File Size: %v
`, rc.ID, rc.NetAddress, rc.HostPublicKey, rc.StartHeight, rc.EndHeight,
File Size: %v
`, rc.ID, rc.NetAddress, rc.HostPublicKey.String(), rc.StartHeight, rc.EndHeight,
currencyUnits(rc.TotalCost),
currencyUnits(rc.Fees),
currencyUnits(rc.TotalCost.Sub(rc.Fees)),
......@@ -359,6 +364,8 @@ File Size: %v
currencyUnits(rc.DownloadSpending),
currencyUnits(rc.RenterFunds),
filesizeUnits(int64(rc.Size)))
printScoreBreakdown(&hostInfo)
return
}
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment