Merge pull request #1228 from steven004/statepower

better power show
This commit is contained in:
Łukasz Magiera 2020-02-06 19:34:46 +01:00 committed by GitHub
commit 44c1e3a347
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
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
},
}