migrate storage miner info
This commit is contained in:
parent
e60027c00a
commit
8285eda8e5
@ -35,8 +35,12 @@ func Load(store adt.Store, act *types.Actor) (st State, err error) {
|
|||||||
type State interface {
|
type State interface {
|
||||||
cbor.Marshaler
|
cbor.Marshaler
|
||||||
|
|
||||||
|
// Total available balance to spend.
|
||||||
AvailableBalance(abi.TokenAmount) (abi.TokenAmount, error)
|
AvailableBalance(abi.TokenAmount) (abi.TokenAmount, error)
|
||||||
|
// Funds that will vest by the given epoch.
|
||||||
VestedFunds(abi.ChainEpoch) (abi.TokenAmount, error)
|
VestedFunds(abi.ChainEpoch) (abi.TokenAmount, error)
|
||||||
|
// Funds locked for various reasons.
|
||||||
|
LockedFunds() (LockedFunds, error)
|
||||||
|
|
||||||
GetSector(abi.SectorNumber) (*SectorOnChainInfo, error)
|
GetSector(abi.SectorNumber) (*SectorOnChainInfo, error)
|
||||||
FindSector(abi.SectorNumber) (*SectorLocation, error)
|
FindSector(abi.SectorNumber) (*SectorLocation, error)
|
||||||
@ -138,3 +142,9 @@ type PreCommitChanges struct {
|
|||||||
Added []SectorPreCommitOnChainInfo
|
Added []SectorPreCommitOnChainInfo
|
||||||
Removed []SectorPreCommitOnChainInfo
|
Removed []SectorPreCommitOnChainInfo
|
||||||
}
|
}
|
||||||
|
|
||||||
|
type LockedFunds struct {
|
||||||
|
VestingFunds abi.TokenAmount
|
||||||
|
InitialPledgeRequirement abi.TokenAmount
|
||||||
|
PreCommitDeposits abi.TokenAmount
|
||||||
|
}
|
||||||
|
@ -40,6 +40,22 @@ func (s *v0State) VestedFunds(epoch abi.ChainEpoch) (abi.TokenAmount, error) {
|
|||||||
return s.CheckVestedFunds(s.store, epoch)
|
return s.CheckVestedFunds(s.store, epoch)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (s *v0State) LockedFunds() (LockedFunds, error) {
|
||||||
|
return LockedFunds{
|
||||||
|
VestingFunds: s.State.LockedFunds,
|
||||||
|
InitialPledgeRequirement: s.State.InitialPledgeRequirement,
|
||||||
|
PreCommitDeposits: s.State.PreCommitDeposits,
|
||||||
|
}, nil
|
||||||
|
}
|
||||||
|
|
||||||
|
func (s *v0State) InitialPledge() (abi.TokenAmount, error) {
|
||||||
|
return s.State.InitialPledgeRequirement, nil
|
||||||
|
}
|
||||||
|
|
||||||
|
func (s *v0State) PreCommitDeposits() (abi.TokenAmount, error) {
|
||||||
|
return s.State.PreCommitDeposits, nil
|
||||||
|
}
|
||||||
|
|
||||||
func (s *v0State) GetSector(num abi.SectorNumber) (*SectorOnChainInfo, error) {
|
func (s *v0State) GetSector(num abi.SectorNumber) (*SectorOnChainInfo, error) {
|
||||||
info, ok, err := s.State.GetSector(s.store, num)
|
info, ok, err := s.State.GetSector(s.store, num)
|
||||||
if !ok || err != nil {
|
if !ok || err != nil {
|
||||||
|
@ -1,7 +1,6 @@
|
|||||||
package main
|
package main
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"bytes"
|
|
||||||
"context"
|
"context"
|
||||||
"fmt"
|
"fmt"
|
||||||
"sort"
|
"sort"
|
||||||
@ -16,12 +15,12 @@ import (
|
|||||||
"github.com/filecoin-project/go-fil-markets/storagemarket"
|
"github.com/filecoin-project/go-fil-markets/storagemarket"
|
||||||
"github.com/filecoin-project/go-state-types/abi"
|
"github.com/filecoin-project/go-state-types/abi"
|
||||||
sealing "github.com/filecoin-project/lotus/extern/storage-sealing"
|
sealing "github.com/filecoin-project/lotus/extern/storage-sealing"
|
||||||
"github.com/filecoin-project/specs-actors/actors/builtin/miner"
|
|
||||||
"github.com/filecoin-project/specs-actors/actors/util/adt"
|
|
||||||
|
|
||||||
"github.com/filecoin-project/lotus/api"
|
"github.com/filecoin-project/lotus/api"
|
||||||
"github.com/filecoin-project/lotus/api/apibstore"
|
"github.com/filecoin-project/lotus/api/apibstore"
|
||||||
"github.com/filecoin-project/lotus/build"
|
"github.com/filecoin-project/lotus/build"
|
||||||
|
"github.com/filecoin-project/lotus/chain/actors/adt"
|
||||||
|
"github.com/filecoin-project/lotus/chain/actors/builtin/miner"
|
||||||
"github.com/filecoin-project/lotus/chain/types"
|
"github.com/filecoin-project/lotus/chain/types"
|
||||||
lcli "github.com/filecoin-project/lotus/cli"
|
lcli "github.com/filecoin-project/lotus/cli"
|
||||||
"github.com/filecoin-project/lotus/lib/blockstore"
|
"github.com/filecoin-project/lotus/lib/blockstore"
|
||||||
@ -54,11 +53,6 @@ func infoCmdAct(cctx *cli.Context) error {
|
|||||||
|
|
||||||
ctx := lcli.ReqContext(cctx)
|
ctx := lcli.ReqContext(cctx)
|
||||||
|
|
||||||
head, err := api.ChainHead(ctx)
|
|
||||||
if err != nil {
|
|
||||||
return xerrors.Errorf("getting chain head: %w", err)
|
|
||||||
}
|
|
||||||
|
|
||||||
maddr, err := getActorAddress(ctx, nodeApi, cctx.String("actor"))
|
maddr, err := getActorAddress(ctx, nodeApi, cctx.String("actor"))
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
@ -68,16 +62,12 @@ func infoCmdAct(cctx *cli.Context) error {
|
|||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
var mas miner.State
|
|
||||||
{
|
tbs := bufbstore.NewTieredBstore(apibstore.NewAPIBlockstore(api), blockstore.NewTemporary())
|
||||||
rmas, err := api.ChainReadObj(ctx, mact.Head)
|
mas, err := miner.Load(adt.WrapStore(ctx, cbor.NewCborStore(tbs)), mact)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
if err := mas.UnmarshalCBOR(bytes.NewReader(rmas)); err != nil {
|
|
||||||
return err
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
fmt.Printf("Miner: %s\n", color.BlueString("%s", maddr))
|
fmt.Printf("Miner: %s\n", color.BlueString("%s", maddr))
|
||||||
|
|
||||||
@ -172,17 +162,21 @@ func infoCmdAct(cctx *cli.Context) error {
|
|||||||
fmt.Printf("\tActive: %d, %s (Verified: %d, %s)\n", nactiveDeals, types.SizeStr(types.NewInt(uint64(activeDealBytes))), nVerifDeals, types.SizeStr(types.NewInt(uint64(activeVerifDealBytes))))
|
fmt.Printf("\tActive: %d, %s (Verified: %d, %s)\n", nactiveDeals, types.SizeStr(types.NewInt(uint64(activeDealBytes))), nVerifDeals, types.SizeStr(types.NewInt(uint64(activeVerifDealBytes))))
|
||||||
fmt.Println()
|
fmt.Println()
|
||||||
|
|
||||||
tbs := bufbstore.NewTieredBstore(apibstore.NewAPIBlockstore(api), blockstore.NewTemporary())
|
// NOTE: there's no need to unlock anything here. Funds only
|
||||||
_, err = mas.UnlockVestedFunds(adt.WrapStore(ctx, cbor.NewCborStore(tbs)), head.Height())
|
// vest on deadline boundaries, and they're unlocked by cron.
|
||||||
|
lockedFunds, err := mas.LockedFunds()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return xerrors.Errorf("calculating vested funds: %w", err)
|
return xerrors.Errorf("getting locked funds: %w", err)
|
||||||
|
}
|
||||||
|
availBalance, err := mas.AvailableBalance(mact.Balance)
|
||||||
|
if err != nil {
|
||||||
|
return xerrors.Errorf("getting available balance: %w", err)
|
||||||
}
|
}
|
||||||
|
|
||||||
fmt.Printf("Miner Balance: %s\n", color.YellowString("%s", types.FIL(mact.Balance)))
|
fmt.Printf("Miner Balance: %s\n", color.YellowString("%s", types.FIL(mact.Balance)))
|
||||||
fmt.Printf("\tPreCommit: %s\n", types.FIL(mas.PreCommitDeposits))
|
fmt.Printf("\tPreCommit: %s\n", types.FIL(lockedFunds.PreCommitDeposits))
|
||||||
fmt.Printf("\tPledge: %s\n", types.FIL(mas.InitialPledgeRequirement))
|
fmt.Printf("\tPledge: %s\n", types.FIL(lockedFunds.InitialPledgeRequirement))
|
||||||
fmt.Printf("\tLocked: %s\n", types.FIL(mas.LockedFunds))
|
fmt.Printf("\tVesting: %s\n", types.FIL(lockedFunds.VestingFunds))
|
||||||
color.Green("\tAvailable: %s", types.FIL(mas.GetAvailableBalance(mact.Balance)))
|
color.Green("\tAvailable: %s", types.FIL(availBalance))
|
||||||
wb, err := api.WalletBalance(ctx, mi.Worker)
|
wb, err := api.WalletBalance(ctx, mi.Worker)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return xerrors.Errorf("getting worker balance: %w", err)
|
return xerrors.Errorf("getting worker balance: %w", err)
|
||||||
|
Loading…
Reference in New Issue
Block a user