better power show

This commit is contained in:
steven004 2020-02-06 14:25:30 +08:00
parent e7a1be4dde
commit 709fd12b7f
2 changed files with 8 additions and 4 deletions

View File

@ -475,7 +475,8 @@ func powerLookup(ctx context.Context, vmctx types.VMContext, self *StoragePowerS
}
if !has {
return types.EmptyInt, aerrors.New(1, "miner not registered with storage power actor")
// A miner could be registered with storage power actor, but removed for some reasons, e.g. consensus fault
return types.EmptyInt, aerrors.New(1, "miner not registered with storage power actor, or removed already")
}
// TODO: Use local amt

View File

@ -119,12 +119,15 @@ var statePowerCmd = &cli.Command{
return err
}
res := power.TotalPower
tp := power.TotalPower
if cctx.Args().Present() {
res = power.MinerPower
mp := power.MinerPower
percI := types.BigDiv(types.BigMul(mp, types.NewInt(1000000)), tp)
fmt.Printf("%s(%s) / %s(%s) ~= %0.4f%%\n", mp.String(), mp.SizeStr(), tp.String(), tp.SizeStr(), float64(percI.Int64())/10000)
} else {
fmt.Printf("%s(%s)\n", tp.String(), tp.SizeStr())
}
fmt.Println(res.String())
return nil
},
}