2020-09-19 03:46:03 +00:00
|
|
|
package miner
|
|
|
|
|
|
|
|
import (
|
|
|
|
"bytes"
|
|
|
|
"errors"
|
|
|
|
|
|
|
|
"github.com/filecoin-project/go-address"
|
|
|
|
"github.com/filecoin-project/go-bitfield"
|
|
|
|
"github.com/filecoin-project/go-state-types/abi"
|
|
|
|
"github.com/filecoin-project/go-state-types/dline"
|
2020-09-24 00:40:29 +00:00
|
|
|
"github.com/ipfs/go-cid"
|
2020-09-19 03:46:03 +00:00
|
|
|
"github.com/libp2p/go-libp2p-core/peer"
|
|
|
|
cbg "github.com/whyrusleeping/cbor-gen"
|
2020-10-05 17:52:32 +00:00
|
|
|
"golang.org/x/xerrors"
|
2020-09-19 03:46:03 +00:00
|
|
|
|
2020-09-24 00:40:29 +00:00
|
|
|
"github.com/filecoin-project/lotus/chain/actors/adt"
|
|
|
|
|
2020-09-28 20:13:18 +00:00
|
|
|
miner2 "github.com/filecoin-project/specs-actors/v2/actors/builtin/miner"
|
|
|
|
adt2 "github.com/filecoin-project/specs-actors/v2/actors/util/adt"
|
2020-09-19 03:46:03 +00:00
|
|
|
)
|
|
|
|
|
2020-09-28 20:13:18 +00:00
|
|
|
var _ State = (*state2)(nil)
|
2020-09-19 03:46:03 +00:00
|
|
|
|
2020-09-28 20:13:18 +00:00
|
|
|
func load2(store adt.Store, root cid.Cid) (State, error) {
|
|
|
|
out := state2{store: store}
|
2020-09-24 00:40:29 +00:00
|
|
|
err := store.Get(store.Context(), root, &out)
|
|
|
|
if err != nil {
|
|
|
|
return nil, err
|
|
|
|
}
|
|
|
|
return &out, nil
|
|
|
|
}
|
|
|
|
|
2020-09-28 20:13:18 +00:00
|
|
|
type state2 struct {
|
|
|
|
miner2.State
|
2020-09-19 03:46:03 +00:00
|
|
|
store adt.Store
|
|
|
|
}
|
|
|
|
|
2020-09-28 20:13:18 +00:00
|
|
|
type deadline2 struct {
|
|
|
|
miner2.Deadline
|
2020-09-19 03:46:03 +00:00
|
|
|
store adt.Store
|
|
|
|
}
|
|
|
|
|
2020-09-28 20:13:18 +00:00
|
|
|
type partition2 struct {
|
|
|
|
miner2.Partition
|
2020-09-19 03:46:03 +00:00
|
|
|
store adt.Store
|
|
|
|
}
|
|
|
|
|
2020-10-11 22:17:28 +00:00
|
|
|
func (s *state2) AvailableBalance(bal abi.TokenAmount) (available abi.TokenAmount, err error) {
|
|
|
|
defer func() {
|
|
|
|
if r := recover(); r != nil {
|
|
|
|
err = xerrors.Errorf("failed to get available balance: %w", r)
|
|
|
|
available = abi.NewTokenAmount(0)
|
|
|
|
}
|
|
|
|
}()
|
|
|
|
// this panics if the miner doesnt have enough funds to cover their locked pledge
|
|
|
|
available, err = s.GetAvailableBalance(bal)
|
|
|
|
return available, err
|
2020-09-19 03:46:03 +00:00
|
|
|
}
|
|
|
|
|
2020-09-28 20:13:18 +00:00
|
|
|
func (s *state2) VestedFunds(epoch abi.ChainEpoch) (abi.TokenAmount, error) {
|
2020-09-19 03:46:03 +00:00
|
|
|
return s.CheckVestedFunds(s.store, epoch)
|
|
|
|
}
|
|
|
|
|
2020-09-28 20:13:18 +00:00
|
|
|
func (s *state2) LockedFunds() (LockedFunds, error) {
|
2020-09-19 03:46:03 +00:00
|
|
|
return LockedFunds{
|
|
|
|
VestingFunds: s.State.LockedFunds,
|
|
|
|
InitialPledgeRequirement: s.State.InitialPledge,
|
|
|
|
PreCommitDeposits: s.State.PreCommitDeposits,
|
|
|
|
}, nil
|
|
|
|
}
|
|
|
|
|
2020-10-06 08:33:55 +00:00
|
|
|
func (s *state2) FeeDebt() (abi.TokenAmount, error) {
|
|
|
|
return s.State.FeeDebt, nil
|
|
|
|
}
|
|
|
|
|
2020-09-28 20:13:18 +00:00
|
|
|
func (s *state2) InitialPledge() (abi.TokenAmount, error) {
|
2020-09-19 03:46:03 +00:00
|
|
|
return s.State.InitialPledge, nil
|
|
|
|
}
|
|
|
|
|
2020-09-28 20:13:18 +00:00
|
|
|
func (s *state2) PreCommitDeposits() (abi.TokenAmount, error) {
|
2020-09-19 03:46:03 +00:00
|
|
|
return s.State.PreCommitDeposits, nil
|
|
|
|
}
|
|
|
|
|
2020-09-28 20:13:18 +00:00
|
|
|
func (s *state2) GetSector(num abi.SectorNumber) (*SectorOnChainInfo, error) {
|
2020-09-19 03:46:03 +00:00
|
|
|
info, ok, err := s.State.GetSector(s.store, num)
|
|
|
|
if !ok || err != nil {
|
|
|
|
return nil, err
|
|
|
|
}
|
|
|
|
|
2020-09-28 20:13:18 +00:00
|
|
|
ret := fromV2SectorOnChainInfo(*info)
|
2020-09-19 03:46:03 +00:00
|
|
|
return &ret, nil
|
|
|
|
}
|
|
|
|
|
2020-09-28 20:13:18 +00:00
|
|
|
func (s *state2) FindSector(num abi.SectorNumber) (*SectorLocation, error) {
|
2020-09-19 03:46:03 +00:00
|
|
|
dlIdx, partIdx, err := s.State.FindSector(s.store, num)
|
|
|
|
if err != nil {
|
|
|
|
return nil, err
|
|
|
|
}
|
|
|
|
return &SectorLocation{
|
|
|
|
Deadline: dlIdx,
|
|
|
|
Partition: partIdx,
|
|
|
|
}, nil
|
|
|
|
}
|
|
|
|
|
2020-09-28 20:13:18 +00:00
|
|
|
func (s *state2) NumLiveSectors() (uint64, error) {
|
2020-09-23 22:36:56 +00:00
|
|
|
dls, err := s.State.LoadDeadlines(s.store)
|
|
|
|
if err != nil {
|
|
|
|
return 0, err
|
|
|
|
}
|
|
|
|
var total uint64
|
2020-09-28 20:13:18 +00:00
|
|
|
if err := dls.ForEach(s.store, func(dlIdx uint64, dl *miner2.Deadline) error {
|
2020-09-23 22:36:56 +00:00
|
|
|
total += dl.LiveSectors
|
|
|
|
return nil
|
|
|
|
}); err != nil {
|
|
|
|
return 0, err
|
|
|
|
}
|
|
|
|
return total, nil
|
|
|
|
}
|
|
|
|
|
2020-09-19 03:46:03 +00:00
|
|
|
// GetSectorExpiration returns the effective expiration of the given sector.
|
|
|
|
//
|
2020-10-05 17:52:32 +00:00
|
|
|
// If the sector does not expire early, the Early expiration field is 0.
|
2020-09-28 20:13:18 +00:00
|
|
|
func (s *state2) GetSectorExpiration(num abi.SectorNumber) (*SectorExpiration, error) {
|
2020-09-19 03:46:03 +00:00
|
|
|
dls, err := s.State.LoadDeadlines(s.store)
|
|
|
|
if err != nil {
|
|
|
|
return nil, err
|
|
|
|
}
|
|
|
|
// NOTE: this can be optimized significantly.
|
|
|
|
// 1. If the sector is non-faulty, it will either expire on-time (can be
|
|
|
|
// learned from the sector info), or in the next quantized expiration
|
|
|
|
// epoch (i.e., the first element in the partition's expiration queue.
|
|
|
|
// 2. If it's faulty, it will expire early within the first 14 entries
|
|
|
|
// of the expiration queue.
|
|
|
|
stopErr := errors.New("stop")
|
|
|
|
out := SectorExpiration{}
|
2020-09-28 20:13:18 +00:00
|
|
|
err = dls.ForEach(s.store, func(dlIdx uint64, dl *miner2.Deadline) error {
|
2020-09-19 03:46:03 +00:00
|
|
|
partitions, err := dl.PartitionsArray(s.store)
|
|
|
|
if err != nil {
|
|
|
|
return err
|
|
|
|
}
|
|
|
|
quant := s.State.QuantSpecForDeadline(dlIdx)
|
2020-09-28 20:13:18 +00:00
|
|
|
var part miner2.Partition
|
2020-09-19 03:46:03 +00:00
|
|
|
return partitions.ForEach(&part, func(partIdx int64) error {
|
|
|
|
if found, err := part.Sectors.IsSet(uint64(num)); err != nil {
|
|
|
|
return err
|
|
|
|
} else if !found {
|
|
|
|
return nil
|
|
|
|
}
|
|
|
|
if found, err := part.Terminated.IsSet(uint64(num)); err != nil {
|
|
|
|
return err
|
|
|
|
} else if found {
|
|
|
|
// already terminated
|
|
|
|
return stopErr
|
|
|
|
}
|
|
|
|
|
2020-09-28 20:13:18 +00:00
|
|
|
q, err := miner2.LoadExpirationQueue(s.store, part.ExpirationsEpochs, quant)
|
2020-09-19 03:46:03 +00:00
|
|
|
if err != nil {
|
|
|
|
return err
|
|
|
|
}
|
2020-09-28 20:13:18 +00:00
|
|
|
var exp miner2.ExpirationSet
|
2020-09-19 03:46:03 +00:00
|
|
|
return q.ForEach(&exp, func(epoch int64) error {
|
|
|
|
if early, err := exp.EarlySectors.IsSet(uint64(num)); err != nil {
|
|
|
|
return err
|
|
|
|
} else if early {
|
|
|
|
out.Early = abi.ChainEpoch(epoch)
|
|
|
|
return nil
|
|
|
|
}
|
|
|
|
if onTime, err := exp.OnTimeSectors.IsSet(uint64(num)); err != nil {
|
|
|
|
return err
|
|
|
|
} else if onTime {
|
|
|
|
out.OnTime = abi.ChainEpoch(epoch)
|
|
|
|
return stopErr
|
|
|
|
}
|
|
|
|
return nil
|
|
|
|
})
|
|
|
|
})
|
|
|
|
})
|
|
|
|
if err == stopErr {
|
|
|
|
err = nil
|
|
|
|
}
|
|
|
|
if err != nil {
|
|
|
|
return nil, err
|
|
|
|
}
|
|
|
|
if out.Early == 0 && out.OnTime == 0 {
|
2020-10-05 17:52:32 +00:00
|
|
|
return nil, xerrors.Errorf("failed to find sector %d", num)
|
2020-09-19 03:46:03 +00:00
|
|
|
}
|
|
|
|
return &out, nil
|
|
|
|
}
|
|
|
|
|
2020-09-28 20:13:18 +00:00
|
|
|
func (s *state2) GetPrecommittedSector(num abi.SectorNumber) (*SectorPreCommitOnChainInfo, error) {
|
2020-09-19 03:46:03 +00:00
|
|
|
info, ok, err := s.State.GetPrecommittedSector(s.store, num)
|
|
|
|
if !ok || err != nil {
|
|
|
|
return nil, err
|
|
|
|
}
|
|
|
|
|
2020-09-28 20:13:18 +00:00
|
|
|
ret := fromV2SectorPreCommitOnChainInfo(*info)
|
2020-09-19 03:46:03 +00:00
|
|
|
|
|
|
|
return &ret, nil
|
|
|
|
}
|
|
|
|
|
2020-09-28 20:13:18 +00:00
|
|
|
func (s *state2) LoadSectors(snos *bitfield.BitField) ([]*SectorOnChainInfo, error) {
|
|
|
|
sectors, err := miner2.LoadSectors(s.store, s.State.Sectors)
|
2020-09-19 03:46:03 +00:00
|
|
|
if err != nil {
|
|
|
|
return nil, err
|
|
|
|
}
|
|
|
|
|
2020-09-23 22:36:56 +00:00
|
|
|
// If no sector numbers are specified, load all.
|
|
|
|
if snos == nil {
|
|
|
|
infos := make([]*SectorOnChainInfo, 0, sectors.Length())
|
2020-09-28 20:13:18 +00:00
|
|
|
var info2 miner2.SectorOnChainInfo
|
|
|
|
if err := sectors.ForEach(&info2, func(_ int64) error {
|
|
|
|
info := fromV2SectorOnChainInfo(info2)
|
2020-09-23 22:36:56 +00:00
|
|
|
infos = append(infos, &info)
|
|
|
|
return nil
|
|
|
|
}); err != nil {
|
|
|
|
return nil, err
|
2020-09-19 03:46:03 +00:00
|
|
|
}
|
2020-09-23 22:36:56 +00:00
|
|
|
return infos, nil
|
|
|
|
}
|
2020-09-19 03:46:03 +00:00
|
|
|
|
2020-09-23 22:36:56 +00:00
|
|
|
// Otherwise, load selected.
|
2020-09-28 20:13:18 +00:00
|
|
|
infos2, err := sectors.Load(*snos)
|
2020-09-23 22:36:56 +00:00
|
|
|
if err != nil {
|
2020-09-19 03:46:03 +00:00
|
|
|
return nil, err
|
|
|
|
}
|
2020-09-28 20:13:18 +00:00
|
|
|
infos := make([]*SectorOnChainInfo, len(infos2))
|
|
|
|
for i, info2 := range infos2 {
|
|
|
|
info := fromV2SectorOnChainInfo(*info2)
|
2020-09-23 22:36:56 +00:00
|
|
|
infos[i] = &info
|
|
|
|
}
|
|
|
|
return infos, nil
|
2020-09-19 03:46:03 +00:00
|
|
|
}
|
|
|
|
|
2020-09-28 20:13:18 +00:00
|
|
|
func (s *state2) IsAllocated(num abi.SectorNumber) (bool, error) {
|
2020-09-19 03:46:03 +00:00
|
|
|
var allocatedSectors bitfield.BitField
|
|
|
|
if err := s.store.Get(s.store.Context(), s.State.AllocatedSectors, &allocatedSectors); err != nil {
|
|
|
|
return false, err
|
|
|
|
}
|
|
|
|
|
|
|
|
return allocatedSectors.IsSet(uint64(num))
|
|
|
|
}
|
|
|
|
|
2020-09-28 20:13:18 +00:00
|
|
|
func (s *state2) LoadDeadline(idx uint64) (Deadline, error) {
|
2020-09-19 03:46:03 +00:00
|
|
|
dls, err := s.State.LoadDeadlines(s.store)
|
|
|
|
if err != nil {
|
|
|
|
return nil, err
|
|
|
|
}
|
|
|
|
dl, err := dls.LoadDeadline(s.store, idx)
|
|
|
|
if err != nil {
|
|
|
|
return nil, err
|
|
|
|
}
|
2020-09-28 20:13:18 +00:00
|
|
|
return &deadline2{*dl, s.store}, nil
|
2020-09-19 03:46:03 +00:00
|
|
|
}
|
|
|
|
|
2020-09-28 20:13:18 +00:00
|
|
|
func (s *state2) ForEachDeadline(cb func(uint64, Deadline) error) error {
|
2020-09-19 03:46:03 +00:00
|
|
|
dls, err := s.State.LoadDeadlines(s.store)
|
|
|
|
if err != nil {
|
|
|
|
return err
|
|
|
|
}
|
2020-09-28 20:13:18 +00:00
|
|
|
return dls.ForEach(s.store, func(i uint64, dl *miner2.Deadline) error {
|
|
|
|
return cb(i, &deadline2{*dl, s.store})
|
2020-09-19 03:46:03 +00:00
|
|
|
})
|
|
|
|
}
|
|
|
|
|
2020-09-28 20:13:18 +00:00
|
|
|
func (s *state2) NumDeadlines() (uint64, error) {
|
|
|
|
return miner2.WPoStPeriodDeadlines, nil
|
2020-09-19 03:46:03 +00:00
|
|
|
}
|
|
|
|
|
2020-09-28 20:13:18 +00:00
|
|
|
func (s *state2) DeadlinesChanged(other State) (bool, error) {
|
|
|
|
other2, ok := other.(*state2)
|
2020-09-19 03:46:03 +00:00
|
|
|
if !ok {
|
|
|
|
// treat an upgrade as a change, always
|
2020-09-23 22:36:56 +00:00
|
|
|
return true, nil
|
2020-09-19 03:46:03 +00:00
|
|
|
}
|
|
|
|
|
2020-10-14 21:27:35 +00:00
|
|
|
return !s.State.Deadlines.Equals(other2.Deadlines), nil
|
2020-09-19 03:46:03 +00:00
|
|
|
}
|
|
|
|
|
2020-10-26 21:20:25 +00:00
|
|
|
func (s *state2) MinerInfoChanged(other State) (bool, error) {
|
|
|
|
other0, ok := other.(*state2)
|
|
|
|
if !ok {
|
|
|
|
// treat an upgrade as a change, always
|
|
|
|
return true, nil
|
|
|
|
}
|
|
|
|
return !s.State.Info.Equals(other0.State.Info), nil
|
|
|
|
}
|
|
|
|
|
2020-09-28 20:13:18 +00:00
|
|
|
func (s *state2) Info() (MinerInfo, error) {
|
2020-09-19 03:46:03 +00:00
|
|
|
info, err := s.State.GetInfo(s.store)
|
|
|
|
if err != nil {
|
|
|
|
return MinerInfo{}, err
|
|
|
|
}
|
|
|
|
|
|
|
|
var pid *peer.ID
|
|
|
|
if peerID, err := peer.IDFromBytes(info.PeerId); err == nil {
|
|
|
|
pid = &peerID
|
|
|
|
}
|
|
|
|
|
2021-01-16 06:42:56 +00:00
|
|
|
wpp, err := info.SealProofType.RegisteredWindowPoStProof()
|
|
|
|
if err != nil {
|
|
|
|
return MinerInfo{}, err
|
|
|
|
}
|
|
|
|
|
2020-09-19 03:46:03 +00:00
|
|
|
mi := MinerInfo{
|
|
|
|
Owner: info.Owner,
|
|
|
|
Worker: info.Worker,
|
|
|
|
ControlAddresses: info.ControlAddresses,
|
|
|
|
|
|
|
|
NewWorker: address.Undef,
|
|
|
|
WorkerChangeEpoch: -1,
|
|
|
|
|
|
|
|
PeerId: pid,
|
|
|
|
Multiaddrs: info.Multiaddrs,
|
2021-01-16 06:42:56 +00:00
|
|
|
WindowPoStProofType: wpp,
|
2020-09-19 03:46:03 +00:00
|
|
|
SectorSize: info.SectorSize,
|
|
|
|
WindowPoStPartitionSectors: info.WindowPoStPartitionSectors,
|
2020-10-06 08:33:55 +00:00
|
|
|
ConsensusFaultElapsed: info.ConsensusFaultElapsed,
|
2020-09-19 03:46:03 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
if info.PendingWorkerKey != nil {
|
|
|
|
mi.NewWorker = info.PendingWorkerKey.NewWorker
|
|
|
|
mi.WorkerChangeEpoch = info.PendingWorkerKey.EffectiveAt
|
|
|
|
}
|
|
|
|
|
|
|
|
return mi, nil
|
|
|
|
}
|
|
|
|
|
2020-09-28 20:13:18 +00:00
|
|
|
func (s *state2) DeadlineInfo(epoch abi.ChainEpoch) (*dline.Info, error) {
|
2020-09-23 22:36:56 +00:00
|
|
|
return s.State.DeadlineInfo(epoch), nil
|
2020-09-19 03:46:03 +00:00
|
|
|
}
|
|
|
|
|
2020-09-28 20:13:18 +00:00
|
|
|
func (s *state2) sectors() (adt.Array, error) {
|
|
|
|
return adt2.AsArray(s.store, s.Sectors)
|
2020-09-19 03:46:03 +00:00
|
|
|
}
|
|
|
|
|
2020-09-28 20:13:18 +00:00
|
|
|
func (s *state2) decodeSectorOnChainInfo(val *cbg.Deferred) (SectorOnChainInfo, error) {
|
|
|
|
var si miner2.SectorOnChainInfo
|
2020-09-19 03:46:03 +00:00
|
|
|
err := si.UnmarshalCBOR(bytes.NewReader(val.Raw))
|
|
|
|
if err != nil {
|
|
|
|
return SectorOnChainInfo{}, err
|
|
|
|
}
|
|
|
|
|
2020-09-28 20:13:18 +00:00
|
|
|
return fromV2SectorOnChainInfo(si), nil
|
2020-09-19 03:46:03 +00:00
|
|
|
}
|
|
|
|
|
2020-09-28 20:13:18 +00:00
|
|
|
func (s *state2) precommits() (adt.Map, error) {
|
|
|
|
return adt2.AsMap(s.store, s.PreCommittedSectors)
|
2020-09-19 03:46:03 +00:00
|
|
|
}
|
|
|
|
|
2020-09-28 20:13:18 +00:00
|
|
|
func (s *state2) decodeSectorPreCommitOnChainInfo(val *cbg.Deferred) (SectorPreCommitOnChainInfo, error) {
|
|
|
|
var sp miner2.SectorPreCommitOnChainInfo
|
2020-09-19 03:46:03 +00:00
|
|
|
err := sp.UnmarshalCBOR(bytes.NewReader(val.Raw))
|
|
|
|
if err != nil {
|
|
|
|
return SectorPreCommitOnChainInfo{}, err
|
|
|
|
}
|
|
|
|
|
2020-09-28 20:13:18 +00:00
|
|
|
return fromV2SectorPreCommitOnChainInfo(sp), nil
|
2020-09-19 03:46:03 +00:00
|
|
|
}
|
|
|
|
|
2020-09-28 20:13:18 +00:00
|
|
|
func (d *deadline2) LoadPartition(idx uint64) (Partition, error) {
|
2020-09-19 03:46:03 +00:00
|
|
|
p, err := d.Deadline.LoadPartition(d.store, idx)
|
|
|
|
if err != nil {
|
|
|
|
return nil, err
|
|
|
|
}
|
2020-09-28 20:13:18 +00:00
|
|
|
return &partition2{*p, d.store}, nil
|
2020-09-19 03:46:03 +00:00
|
|
|
}
|
|
|
|
|
2020-09-28 20:13:18 +00:00
|
|
|
func (d *deadline2) ForEachPartition(cb func(uint64, Partition) error) error {
|
2020-09-19 03:46:03 +00:00
|
|
|
ps, err := d.Deadline.PartitionsArray(d.store)
|
|
|
|
if err != nil {
|
|
|
|
return err
|
|
|
|
}
|
2020-09-28 20:13:18 +00:00
|
|
|
var part miner2.Partition
|
2020-09-19 03:46:03 +00:00
|
|
|
return ps.ForEach(&part, func(i int64) error {
|
2020-09-28 20:13:18 +00:00
|
|
|
return cb(uint64(i), &partition2{part, d.store})
|
2020-09-19 03:46:03 +00:00
|
|
|
})
|
|
|
|
}
|
|
|
|
|
2020-09-28 20:13:18 +00:00
|
|
|
func (d *deadline2) PartitionsChanged(other Deadline) (bool, error) {
|
|
|
|
other2, ok := other.(*deadline2)
|
2020-09-19 03:46:03 +00:00
|
|
|
if !ok {
|
|
|
|
// treat an upgrade as a change, always
|
2020-09-23 22:36:56 +00:00
|
|
|
return true, nil
|
2020-09-19 03:46:03 +00:00
|
|
|
}
|
|
|
|
|
2020-10-14 21:37:33 +00:00
|
|
|
return !d.Deadline.Partitions.Equals(other2.Deadline.Partitions), nil
|
2020-09-19 03:46:03 +00:00
|
|
|
}
|
|
|
|
|
2021-01-16 05:53:27 +00:00
|
|
|
func (d *deadline2) PartitionsPoSted() (bitfield.BitField, error) {
|
2020-09-19 03:46:03 +00:00
|
|
|
return d.Deadline.PostSubmissions, nil
|
|
|
|
}
|
|
|
|
|
2020-09-28 20:13:18 +00:00
|
|
|
func (p *partition2) AllSectors() (bitfield.BitField, error) {
|
2020-09-19 03:46:03 +00:00
|
|
|
return p.Partition.Sectors, nil
|
|
|
|
}
|
|
|
|
|
2020-09-28 20:13:18 +00:00
|
|
|
func (p *partition2) FaultySectors() (bitfield.BitField, error) {
|
2020-09-19 03:46:03 +00:00
|
|
|
return p.Partition.Faults, nil
|
|
|
|
}
|
|
|
|
|
2020-09-28 20:13:18 +00:00
|
|
|
func (p *partition2) RecoveringSectors() (bitfield.BitField, error) {
|
2020-09-19 03:46:03 +00:00
|
|
|
return p.Partition.Recoveries, nil
|
|
|
|
}
|
|
|
|
|
2020-09-28 20:13:18 +00:00
|
|
|
func fromV2SectorOnChainInfo(v2 miner2.SectorOnChainInfo) SectorOnChainInfo {
|
2020-09-19 03:46:03 +00:00
|
|
|
return SectorOnChainInfo{
|
2020-09-28 20:13:18 +00:00
|
|
|
SectorNumber: v2.SectorNumber,
|
|
|
|
SealProof: v2.SealProof,
|
|
|
|
SealedCID: v2.SealedCID,
|
|
|
|
DealIDs: v2.DealIDs,
|
|
|
|
Activation: v2.Activation,
|
|
|
|
Expiration: v2.Expiration,
|
|
|
|
DealWeight: v2.DealWeight,
|
|
|
|
VerifiedDealWeight: v2.VerifiedDealWeight,
|
|
|
|
InitialPledge: v2.InitialPledge,
|
|
|
|
ExpectedDayReward: v2.ExpectedDayReward,
|
|
|
|
ExpectedStoragePledge: v2.ExpectedStoragePledge,
|
2020-09-19 03:46:03 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2020-09-28 20:13:18 +00:00
|
|
|
func fromV2SectorPreCommitOnChainInfo(v2 miner2.SectorPreCommitOnChainInfo) SectorPreCommitOnChainInfo {
|
2020-09-19 03:46:03 +00:00
|
|
|
return SectorPreCommitOnChainInfo{
|
2020-09-28 20:13:18 +00:00
|
|
|
Info: (SectorPreCommitInfo)(v2.Info),
|
|
|
|
PreCommitDeposit: v2.PreCommitDeposit,
|
|
|
|
PreCommitEpoch: v2.PreCommitEpoch,
|
|
|
|
DealWeight: v2.DealWeight,
|
|
|
|
VerifiedDealWeight: v2.VerifiedDealWeight,
|
2020-09-19 03:46:03 +00:00
|
|
|
}
|
|
|
|
}
|