diff --git a/chain/actors/builtin/reward/reward.go b/chain/actors/builtin/reward/reward.go index 25ab3ef6b..ebec85517 100644 --- a/chain/actors/builtin/reward/reward.go +++ b/chain/actors/builtin/reward/reward.go @@ -123,7 +123,7 @@ type State interface { cbor.Marshaler ThisEpochBaselinePower() (abi.StoragePower, error) - ThisEpochReward() (abi.TokenAmount, error) + ThisEpochReward() (abi.StoragePower, error) ThisEpochRewardSmoothed() (builtin.FilterEstimate, error) EffectiveBaselinePower() (abi.StoragePower, error) diff --git a/cmd/lotus-miner/info.go b/cmd/lotus-miner/info.go index 14af8a27d..7be9e1fe1 100644 --- a/cmd/lotus-miner/info.go +++ b/cmd/lotus-miner/info.go @@ -12,6 +12,7 @@ import ( "time" "github.com/fatih/color" + "github.com/mattn/go-isatty" "github.com/urfave/cli/v2" "golang.org/x/xerrors" @@ -567,13 +568,23 @@ func producedBlocks(ctx context.Context, count int, maddr address.Address, napi tbs := blockstore.NewTieredBstore(blockstore.NewAPIBlockstore(napi), blockstore.NewMemory()) + tty := isatty.IsTerminal(os.Stderr.Fd()) + ts := head fmt.Printf(" Epoch | Block ID | Reward\n") for count > 0 { tsk := ts.Key() bhs := ts.Blocks() for _, bh := range bhs { + if ctx.Err() != nil { + return ctx.Err() + } + if bh.Miner == maddr { + if tty { + _, _ = fmt.Fprint(os.Stderr, "\r\x1b[0K") + } + rewardActor, err := napi.StateGetActor(ctx, reward.Address, tsk) if err != nil { return err @@ -587,10 +598,14 @@ func producedBlocks(ctx context.Context, count int, maddr address.Address, napi if err != nil { return err } - fmt.Printf("%8d | %s | %s\n", ts.Height(), bh.Cid(), - types.BigDiv(types.BigMul(types.NewInt(uint64(bh.ElectionProof.WinCount)), - blockReward), types.NewInt(uint64(builtin.ExpectedLeadersPerEpoch)))) + + minerReward := types.BigDiv(types.BigMul(types.NewInt(uint64(bh.ElectionProof.WinCount)), + blockReward), types.NewInt(uint64(builtin.ExpectedLeadersPerEpoch))) + + fmt.Printf("%8d | %s | %s\n", ts.Height(), bh.Cid(), types.FIL(minerReward)) count-- + } else if tty && bh.Height%120 == 0 { + _, _ = fmt.Fprintf(os.Stderr, "\r\x1b[0KChecking epoch %s", lcli.EpochTime(head.Height(), bh.Height)) } } tsk = ts.Parents() @@ -599,5 +614,10 @@ func producedBlocks(ctx context.Context, count int, maddr address.Address, napi return err } } + + if tty { + _, _ = fmt.Fprint(os.Stderr, "\r\x1b[0K") + } + return nil } diff --git a/documentation/en/cli-lotus-miner.md b/documentation/en/cli-lotus-miner.md index f69c8b144..c96b3140e 100644 --- a/documentation/en/cli-lotus-miner.md +++ b/documentation/en/cli-lotus-miner.md @@ -430,6 +430,7 @@ COMMANDS: OPTIONS: --hide-sectors-info hide sectors info (default: false) + --blocks value Log of produced newest blocks and rewards(Miner Fee excluded) (default: 0) --help, -h show help (default: false) --version, -v print the version (default: false)