dont print fil suffix in lotus shed audit balances

This commit is contained in:
whyrusleeping 2020-10-07 16:00:52 -07:00
parent 7c7e0d73d5
commit 8f4911ac0d
2 changed files with 8 additions and 4 deletions

View File

@ -12,11 +12,15 @@ import (
type FIL BigInt
func (f FIL) String() string {
return f.Unitless() + " FIL"
}
func (f FIL) Unitless() string {
r := new(big.Rat).SetFrac(f.Int, big.NewInt(int64(build.FilecoinPrecision)))
if r.Sign() == 0 {
return "0 FIL"
}
return strings.TrimRight(strings.TrimRight(r.FloatString(18), "0"), ".") + " FIL"
return strings.TrimRight(strings.TrimRight(r.FloatString(18), "0"), ".")
}
func (f FIL) Format(s fmt.State, ch rune) {

View File

@ -117,7 +117,7 @@ var chainBalanceCmd = &cli.Command{
fmt.Printf("Address,Balance,Type,Power,Worker,Owner\n")
for _, acc := range infos {
fmt.Printf("%s,%s,%s,%s,%s,%s\n", acc.Address, acc.Balance, acc.Type, acc.Power, acc.Worker, acc.Owner)
fmt.Printf("%s,%s,%s,%s,%s,%s\n", acc.Address, acc.Balance.Unitless(), acc.Type, acc.Power, acc.Worker, acc.Owner)
}
return nil
},
@ -244,12 +244,12 @@ var chainBalanceStateCmd = &cli.Command{
if minerInfo {
fmt.Printf("Address,Balance,Type,Sectors,Worker,Owner,InitialPledge,Locked,PreCommits\n")
for _, acc := range infos {
fmt.Printf("%s,%s,%s,%d,%s,%s,%s,%s,%s\n", acc.Address, acc.Balance, acc.Type, acc.Sectors, acc.Worker, acc.Owner, acc.InitialPledge, acc.LockedFunds, acc.PreCommits)
fmt.Printf("%s,%s,%s,%d,%s,%s,%s,%s,%s\n", acc.Address, acc.Balance.Unitless(), acc.Type, acc.Sectors, acc.Worker, acc.Owner, acc.InitialPledge, acc.LockedFunds, acc.PreCommits)
}
} else {
fmt.Printf("Address,Balance,Type\n")
for _, acc := range infos {
fmt.Printf("%s,%s,%s\n", acc.Address, acc.Balance, acc.Type)
fmt.Printf("%s,%s,%s\n", acc.Address, acc.Balance.Unitless(), acc.Type)
}
}