api: Single method for static miner info

This commit is contained in:
Łukasz Magiera
2020-04-16 19:36:36 +02:00
parent 8338be3a6e
commit afdfc8807d
20 changed files with 84 additions and 140 deletions
+6 -6
View File
@@ -38,12 +38,12 @@ var infoCmd = &cli.Command{
fmt.Printf("Miner: %s\n", maddr)
// Sector size
sizeByte, err := api.StateMinerSectorSize(ctx, maddr, types.EmptyTSK)
mi, err := api.StateMinerInfo(ctx, maddr, types.EmptyTSK)
if err != nil {
return err
}
fmt.Printf("Sector Size: %s\n", types.SizeStr(types.NewInt(uint64(sizeByte))))
fmt.Printf("Sector Size: %s\n", types.SizeStr(types.NewInt(uint64(mi.SectorSize))))
pow, err := api.StateMinerPower(ctx, maddr, types.EmptyTSK)
if err != nil {
@@ -62,13 +62,13 @@ var infoCmd = &cli.Command{
return err
}
fmt.Printf("\tCommitted: %s\n", types.SizeStr(types.BigMul(types.NewInt(secCounts.Sset), types.NewInt(uint64(sizeByte)))))
fmt.Printf("\tCommitted: %s\n", types.SizeStr(types.BigMul(types.NewInt(secCounts.Sset), types.NewInt(uint64(mi.SectorSize)))))
if len(faults) == 0 {
fmt.Printf("\tProving: %s\n", types.SizeStr(types.BigMul(types.NewInt(secCounts.Pset), types.NewInt(uint64(sizeByte)))))
fmt.Printf("\tProving: %s\n", types.SizeStr(types.BigMul(types.NewInt(secCounts.Pset), types.NewInt(uint64(mi.SectorSize)))))
} else {
fmt.Printf("\tProving: %s (%s Faulty, %.2f%%)\n",
types.SizeStr(types.BigMul(types.NewInt(secCounts.Pset-uint64(len(faults))), types.NewInt(uint64(sizeByte)))),
types.SizeStr(types.BigMul(types.NewInt(uint64(len(faults))), types.NewInt(uint64(sizeByte)))),
types.SizeStr(types.BigMul(types.NewInt(secCounts.Pset-uint64(len(faults))), types.NewInt(uint64(mi.SectorSize)))),
types.SizeStr(types.BigMul(types.NewInt(uint64(len(faults))), types.NewInt(uint64(mi.SectorSize)))),
float64(10000*uint64(len(faults))/secCounts.Pset)/100.)
}
+2 -2
View File
@@ -544,7 +544,7 @@ func makeHostKey(lr repo.LockedRepo) (crypto.PrivKey, error) {
}
func configureStorageMiner(ctx context.Context, api lapi.FullNode, addr address.Address, peerid peer.ID, gasPrice types.BigInt) error {
waddr, err := api.StateMinerWorker(ctx, addr, types.EmptyTSK)
mi, err := api.StateMinerInfo(ctx, addr, types.EmptyTSK)
if err != nil {
return xerrors.Errorf("getWorkerAddr returned bad address: %w", err)
}
@@ -556,7 +556,7 @@ func configureStorageMiner(ctx context.Context, api lapi.FullNode, addr address.
msg := &types.Message{
To: addr,
From: waddr,
From: mi.Worker,
Method: builtin.MethodsMiner.ChangePeerID,
Params: enc,
Value: types.NewInt(0),
+4 -4
View File
@@ -42,7 +42,7 @@ var rewardsRedeemCmd = &cli.Command{
return err
}
worker, err := api.StateMinerWorker(ctx, maddr, types.EmptyTSK)
mi, err := api.StateMinerInfo(ctx, maddr, types.EmptyTSK)
if err != nil {
return err
}
@@ -52,16 +52,16 @@ var rewardsRedeemCmd = &cli.Command{
return err
}
workerNonce, err := api.MpoolGetNonce(ctx, worker)
workerNonce, err := api.MpoolGetNonce(ctx, mi.Worker)
if err != nil {
return err
}
panic("todo correct method; call miner actor")
smsg, err := api.WalletSignMessage(ctx, worker, &types.Message{
smsg, err := api.WalletSignMessage(ctx, mi.Worker, &types.Message{
To: builtin.RewardActorAddr,
From: worker,
From: mi.Worker,
Nonce: workerNonce,
Value: types.NewInt(0),
GasPrice: types.NewInt(1),