Abstract SectorOnChainInfo and SectorPreCommitOnChainInfo
This commit is contained in:
parent
b25dd2a00d
commit
ed285f1114
@ -3,7 +3,7 @@ package builtin
|
|||||||
import (
|
import (
|
||||||
"fmt"
|
"fmt"
|
||||||
|
|
||||||
"github.com/filecoin-project/go-state-types/big"
|
smoothing0 "github.com/filecoin-project/specs-actors/actors/util/smoothing"
|
||||||
|
|
||||||
"github.com/filecoin-project/go-state-types/network"
|
"github.com/filecoin-project/go-state-types/network"
|
||||||
)
|
)
|
||||||
@ -25,7 +25,8 @@ func VersionForNetwork(version network.Version) Version {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// TODO: Why does actors have 2 different versions of this?
|
// TODO: Why does actors have 2 different versions of this?
|
||||||
type FilterEstimate struct {
|
type FilterEstimate = smoothing0.FilterEstimate
|
||||||
PositionEstimate big.Int
|
|
||||||
VelocityEstimate big.Int
|
func FromV0FilterEstimate(v0 smoothing0.FilterEstimate) FilterEstimate {
|
||||||
|
return (FilterEstimate)(v0)
|
||||||
}
|
}
|
||||||
|
@ -26,7 +26,7 @@ func (s *state0) TotalLocked() (abi.TokenAmount, error) {
|
|||||||
func (s *state0) BalancesChanged(otherState State) bool {
|
func (s *state0) BalancesChanged(otherState State) bool {
|
||||||
otherState0, ok := otherState.(*state0)
|
otherState0, ok := otherState.(*state0)
|
||||||
if !ok {
|
if !ok {
|
||||||
// there's no way to compare differnt versions of the state, so let's
|
// there's no way to compare different versions of the state, so let's
|
||||||
// just say that means the state of balances has changed
|
// just say that means the state of balances has changed
|
||||||
return true
|
return true
|
||||||
}
|
}
|
||||||
@ -36,7 +36,7 @@ func (s *state0) BalancesChanged(otherState State) bool {
|
|||||||
func (s *state0) StatesChanged(otherState State) bool {
|
func (s *state0) StatesChanged(otherState State) bool {
|
||||||
otherState0, ok := otherState.(*state0)
|
otherState0, ok := otherState.(*state0)
|
||||||
if !ok {
|
if !ok {
|
||||||
// there's no way to compare differnt versions of the state, so let's
|
// there's no way to compare different versions of the state, so let's
|
||||||
// just say that means the state of balances has changed
|
// just say that means the state of balances has changed
|
||||||
return true
|
return true
|
||||||
}
|
}
|
||||||
@ -54,7 +54,7 @@ func (s *state0) States() (DealStates, error) {
|
|||||||
func (s *state0) ProposalsChanged(otherState State) bool {
|
func (s *state0) ProposalsChanged(otherState State) bool {
|
||||||
otherState0, ok := otherState.(*state0)
|
otherState0, ok := otherState.(*state0)
|
||||||
if !ok {
|
if !ok {
|
||||||
// there's no way to compare differnt versions of the state, so let's
|
// there's no way to compare different versions of the state, so let's
|
||||||
// just say that means the state of balances has changed
|
// just say that means the state of balances has changed
|
||||||
return true
|
return true
|
||||||
}
|
}
|
||||||
|
@ -2,6 +2,7 @@ package miner
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
"github.com/filecoin-project/go-state-types/dline"
|
"github.com/filecoin-project/go-state-types/dline"
|
||||||
|
"github.com/ipfs/go-cid"
|
||||||
"github.com/libp2p/go-libp2p-core/peer"
|
"github.com/libp2p/go-libp2p-core/peer"
|
||||||
cbg "github.com/whyrusleeping/cbor-gen"
|
cbg "github.com/whyrusleeping/cbor-gen"
|
||||||
"golang.org/x/xerrors"
|
"golang.org/x/xerrors"
|
||||||
@ -81,9 +82,30 @@ type Partition interface {
|
|||||||
ActiveSectors() (bitfield.BitField, error)
|
ActiveSectors() (bitfield.BitField, error)
|
||||||
}
|
}
|
||||||
|
|
||||||
type SectorOnChainInfo = miner0.SectorOnChainInfo
|
type SectorOnChainInfo struct {
|
||||||
|
SectorNumber abi.SectorNumber
|
||||||
|
SealProof abi.RegisteredSealProof
|
||||||
|
SealedCID cid.Cid
|
||||||
|
DealIDs []abi.DealID
|
||||||
|
Activation abi.ChainEpoch
|
||||||
|
Expiration abi.ChainEpoch
|
||||||
|
DealWeight abi.DealWeight
|
||||||
|
VerifiedDealWeight abi.DealWeight
|
||||||
|
InitialPledge abi.TokenAmount
|
||||||
|
ExpectedDayReward abi.TokenAmount
|
||||||
|
ExpectedStoragePledge abi.TokenAmount
|
||||||
|
}
|
||||||
|
|
||||||
type SectorPreCommitInfo = miner0.SectorPreCommitInfo
|
type SectorPreCommitInfo = miner0.SectorPreCommitInfo
|
||||||
type SectorPreCommitOnChainInfo = miner0.SectorPreCommitOnChainInfo
|
|
||||||
|
type SectorPreCommitOnChainInfo struct {
|
||||||
|
Info SectorPreCommitInfo
|
||||||
|
PreCommitDeposit abi.TokenAmount
|
||||||
|
PreCommitEpoch abi.ChainEpoch
|
||||||
|
DealWeight abi.DealWeight
|
||||||
|
VerifiedDealWeight abi.DealWeight
|
||||||
|
}
|
||||||
|
|
||||||
type PoStPartition = miner0.PoStPartition
|
type PoStPartition = miner0.PoStPartition
|
||||||
type RecoveryDeclaration = miner0.RecoveryDeclaration
|
type RecoveryDeclaration = miner0.RecoveryDeclaration
|
||||||
type FaultDeclaration = miner0.FaultDeclaration
|
type FaultDeclaration = miner0.FaultDeclaration
|
||||||
|
@ -62,7 +62,8 @@ func (s *state0) GetSector(num abi.SectorNumber) (*SectorOnChainInfo, error) {
|
|||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
|
||||||
return info, nil
|
ret := fromV0SectorOnChainInfo(*info)
|
||||||
|
return &ret, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func (s *state0) FindSector(num abi.SectorNumber) (*SectorLocation, error) {
|
func (s *state0) FindSector(num abi.SectorNumber) (*SectorLocation, error) {
|
||||||
@ -154,7 +155,8 @@ func (s *state0) GetPrecommittedSector(num abi.SectorNumber) (*SectorPreCommitOn
|
|||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
|
||||||
return info, nil
|
ret := fromV0SectorPreCommitOnChainInfo(*info)
|
||||||
|
return &ret, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func (s *state0) LoadSectorsFromSet(filter *bitfield.BitField, filterOut bool) (adt.Array, error) {
|
func (s *state0) LoadSectorsFromSet(filter *bitfield.BitField, filterOut bool) (adt.Array, error) {
|
||||||
@ -279,7 +281,11 @@ func (s *state0) sectors() (adt.Array, error) {
|
|||||||
func (s *state0) decodeSectorOnChainInfo(val *cbg.Deferred) (SectorOnChainInfo, error) {
|
func (s *state0) decodeSectorOnChainInfo(val *cbg.Deferred) (SectorOnChainInfo, error) {
|
||||||
var si miner0.SectorOnChainInfo
|
var si miner0.SectorOnChainInfo
|
||||||
err := si.UnmarshalCBOR(bytes.NewReader(val.Raw))
|
err := si.UnmarshalCBOR(bytes.NewReader(val.Raw))
|
||||||
return si, err
|
if err != nil {
|
||||||
|
return SectorOnChainInfo{}, err
|
||||||
|
}
|
||||||
|
|
||||||
|
return fromV0SectorOnChainInfo(si), nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func (s *state0) precommits() (adt.Map, error) {
|
func (s *state0) precommits() (adt.Map, error) {
|
||||||
@ -289,7 +295,11 @@ func (s *state0) precommits() (adt.Map, error) {
|
|||||||
func (s *state0) decodeSectorPreCommitOnChainInfo(val *cbg.Deferred) (SectorPreCommitOnChainInfo, error) {
|
func (s *state0) decodeSectorPreCommitOnChainInfo(val *cbg.Deferred) (SectorPreCommitOnChainInfo, error) {
|
||||||
var sp miner0.SectorPreCommitOnChainInfo
|
var sp miner0.SectorPreCommitOnChainInfo
|
||||||
err := sp.UnmarshalCBOR(bytes.NewReader(val.Raw))
|
err := sp.UnmarshalCBOR(bytes.NewReader(val.Raw))
|
||||||
return sp, err
|
if err != nil {
|
||||||
|
return SectorPreCommitOnChainInfo{}, err
|
||||||
|
}
|
||||||
|
|
||||||
|
return fromV0SectorPreCommitOnChainInfo(sp), nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func (d *deadline0) LoadPartition(idx uint64) (Partition, error) {
|
func (d *deadline0) LoadPartition(idx uint64) (Partition, error) {
|
||||||
@ -336,3 +346,11 @@ func (p *partition0) FaultySectors() (bitfield.BitField, error) {
|
|||||||
func (p *partition0) RecoveringSectors() (bitfield.BitField, error) {
|
func (p *partition0) RecoveringSectors() (bitfield.BitField, error) {
|
||||||
return p.Partition.Recoveries, nil
|
return p.Partition.Recoveries, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func fromV0SectorOnChainInfo(v0 miner0.SectorOnChainInfo) SectorOnChainInfo {
|
||||||
|
return (SectorOnChainInfo)(v0)
|
||||||
|
}
|
||||||
|
|
||||||
|
func fromV0SectorPreCommitOnChainInfo(v0 miner0.SectorPreCommitOnChainInfo) SectorPreCommitOnChainInfo {
|
||||||
|
return (SectorPreCommitOnChainInfo)(v0)
|
||||||
|
}
|
||||||
|
@ -53,10 +53,7 @@ func (s *state0) MinerNominalPowerMeetsConsensusMinimum(a address.Address) (bool
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (s *state0) TotalPowerSmoothed() (builtin.FilterEstimate, error) {
|
func (s *state0) TotalPowerSmoothed() (builtin.FilterEstimate, error) {
|
||||||
return builtin.FilterEstimate{
|
return builtin.FromV0FilterEstimate(*s.State.ThisEpochQAPowerSmoothed), nil
|
||||||
PositionEstimate: s.State.ThisEpochQAPowerSmoothed.PositionEstimate,
|
|
||||||
VelocityEstimate: s.State.ThisEpochQAPowerSmoothed.VelocityEstimate,
|
|
||||||
}, nil
|
|
||||||
}
|
}
|
||||||
|
|
||||||
func (s *state0) MinerCounts() (uint64, uint64, error) {
|
func (s *state0) MinerCounts() (uint64, uint64, error) {
|
||||||
|
@ -19,10 +19,7 @@ func (s *state0) ThisEpochReward() (abi.StoragePower, error) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (s *state0) ThisEpochRewardSmoothed() (builtin.FilterEstimate, error) {
|
func (s *state0) ThisEpochRewardSmoothed() (builtin.FilterEstimate, error) {
|
||||||
return builtin.FilterEstimate{
|
return builtin.FromV0FilterEstimate(*s.State.ThisEpochRewardSmoothed), nil
|
||||||
PositionEstimate: s.State.ThisEpochRewardSmoothed.PositionEstimate,
|
|
||||||
VelocityEstimate: s.State.ThisEpochRewardSmoothed.VelocityEstimate,
|
|
||||||
}, nil
|
|
||||||
}
|
}
|
||||||
|
|
||||||
func (s *state0) ThisEpochBaselinePower() (abi.StoragePower, error) {
|
func (s *state0) ThisEpochBaselinePower() (abi.StoragePower, error) {
|
||||||
|
Loading…
Reference in New Issue
Block a user