rename actors v1 -> actors v2
The actual actors version is v2, not v1. Using Version1 internally was really confusing.
This commit is contained in:
parent
2049daa008
commit
ca9448bc11
@ -11,7 +11,7 @@ import (
|
|||||||
"github.com/filecoin-project/lotus/chain/actors"
|
"github.com/filecoin-project/lotus/chain/actors"
|
||||||
|
|
||||||
adt0 "github.com/filecoin-project/specs-actors/actors/util/adt"
|
adt0 "github.com/filecoin-project/specs-actors/actors/util/adt"
|
||||||
adt1 "github.com/filecoin-project/specs-actors/v2/actors/util/adt"
|
adt2 "github.com/filecoin-project/specs-actors/v2/actors/util/adt"
|
||||||
)
|
)
|
||||||
|
|
||||||
type Map interface {
|
type Map interface {
|
||||||
@ -28,8 +28,8 @@ func AsMap(store Store, root cid.Cid, version actors.Version) (Map, error) {
|
|||||||
switch version {
|
switch version {
|
||||||
case actors.Version0:
|
case actors.Version0:
|
||||||
return adt0.AsMap(store, root)
|
return adt0.AsMap(store, root)
|
||||||
case actors.Version1:
|
case actors.Version2:
|
||||||
return adt1.AsMap(store, root)
|
return adt2.AsMap(store, root)
|
||||||
}
|
}
|
||||||
return nil, xerrors.Errorf("unknown network version: %d", version)
|
return nil, xerrors.Errorf("unknown network version: %d", version)
|
||||||
}
|
}
|
||||||
@ -38,8 +38,8 @@ func NewMap(store Store, version actors.Version) (Map, error) {
|
|||||||
switch version {
|
switch version {
|
||||||
case actors.Version0:
|
case actors.Version0:
|
||||||
return adt0.MakeEmptyMap(store), nil
|
return adt0.MakeEmptyMap(store), nil
|
||||||
case actors.Version1:
|
case actors.Version2:
|
||||||
return adt1.MakeEmptyMap(store), nil
|
return adt2.MakeEmptyMap(store), nil
|
||||||
}
|
}
|
||||||
return nil, xerrors.Errorf("unknown network version: %d", version)
|
return nil, xerrors.Errorf("unknown network version: %d", version)
|
||||||
}
|
}
|
||||||
@ -59,8 +59,8 @@ func AsArray(store Store, root cid.Cid, version network.Version) (Array, error)
|
|||||||
switch actors.VersionForNetwork(version) {
|
switch actors.VersionForNetwork(version) {
|
||||||
case actors.Version0:
|
case actors.Version0:
|
||||||
return adt0.AsArray(store, root)
|
return adt0.AsArray(store, root)
|
||||||
case actors.Version1:
|
case actors.Version2:
|
||||||
return adt1.AsArray(store, root)
|
return adt2.AsArray(store, root)
|
||||||
}
|
}
|
||||||
return nil, xerrors.Errorf("unknown network version: %d", version)
|
return nil, xerrors.Errorf("unknown network version: %d", version)
|
||||||
}
|
}
|
||||||
@ -69,8 +69,8 @@ func NewArray(store Store, version actors.Version) (Array, error) {
|
|||||||
switch version {
|
switch version {
|
||||||
case actors.Version0:
|
case actors.Version0:
|
||||||
return adt0.MakeEmptyArray(store), nil
|
return adt0.MakeEmptyArray(store), nil
|
||||||
case actors.Version1:
|
case actors.Version2:
|
||||||
return adt1.MakeEmptyArray(store), nil
|
return adt2.MakeEmptyArray(store), nil
|
||||||
}
|
}
|
||||||
return nil, xerrors.Errorf("unknown network version: %d", version)
|
return nil, xerrors.Errorf("unknown network version: %d", version)
|
||||||
}
|
}
|
||||||
|
@ -12,15 +12,15 @@ import (
|
|||||||
"github.com/filecoin-project/lotus/chain/types"
|
"github.com/filecoin-project/lotus/chain/types"
|
||||||
|
|
||||||
builtin0 "github.com/filecoin-project/specs-actors/actors/builtin"
|
builtin0 "github.com/filecoin-project/specs-actors/actors/builtin"
|
||||||
builtin1 "github.com/filecoin-project/specs-actors/v2/actors/builtin"
|
builtin2 "github.com/filecoin-project/specs-actors/v2/actors/builtin"
|
||||||
)
|
)
|
||||||
|
|
||||||
func init() {
|
func init() {
|
||||||
builtin.RegisterActorState(builtin0.AccountActorCodeID, func(store adt.Store, root cid.Cid) (cbor.Marshaler, error) {
|
builtin.RegisterActorState(builtin0.AccountActorCodeID, func(store adt.Store, root cid.Cid) (cbor.Marshaler, error) {
|
||||||
return load0(store, root)
|
return load0(store, root)
|
||||||
})
|
})
|
||||||
builtin.RegisterActorState(builtin1.AccountActorCodeID, func(store adt.Store, root cid.Cid) (cbor.Marshaler, error) {
|
builtin.RegisterActorState(builtin2.AccountActorCodeID, func(store adt.Store, root cid.Cid) (cbor.Marshaler, error) {
|
||||||
return load1(store, root)
|
return load2(store, root)
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -28,8 +28,8 @@ func Load(store adt.Store, act *types.Actor) (State, error) {
|
|||||||
switch act.Code {
|
switch act.Code {
|
||||||
case builtin0.AccountActorCodeID:
|
case builtin0.AccountActorCodeID:
|
||||||
return load0(store, act.Head)
|
return load0(store, act.Head)
|
||||||
case builtin1.AccountActorCodeID:
|
case builtin2.AccountActorCodeID:
|
||||||
return load1(store, act.Head)
|
return load2(store, act.Head)
|
||||||
}
|
}
|
||||||
return nil, xerrors.Errorf("unknown actor code %s", act.Code)
|
return nil, xerrors.Errorf("unknown actor code %s", act.Code)
|
||||||
}
|
}
|
||||||
|
@ -6,13 +6,13 @@ import (
|
|||||||
|
|
||||||
"github.com/filecoin-project/lotus/chain/actors/adt"
|
"github.com/filecoin-project/lotus/chain/actors/adt"
|
||||||
|
|
||||||
account1 "github.com/filecoin-project/specs-actors/v2/actors/builtin/account"
|
account2 "github.com/filecoin-project/specs-actors/v2/actors/builtin/account"
|
||||||
)
|
)
|
||||||
|
|
||||||
var _ State = (*state1)(nil)
|
var _ State = (*state2)(nil)
|
||||||
|
|
||||||
func load1(store adt.Store, root cid.Cid) (State, error) {
|
func load2(store adt.Store, root cid.Cid) (State, error) {
|
||||||
out := state1{store: store}
|
out := state2{store: store}
|
||||||
err := store.Get(store.Context(), root, &out)
|
err := store.Get(store.Context(), root, &out)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
@ -20,11 +20,11 @@ func load1(store adt.Store, root cid.Cid) (State, error) {
|
|||||||
return &out, nil
|
return &out, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
type state1 struct {
|
type state2 struct {
|
||||||
account1.State
|
account2.State
|
||||||
store adt.Store
|
store adt.Store
|
||||||
}
|
}
|
||||||
|
|
||||||
func (s *state1) PubkeyAddress() (address.Address, error) {
|
func (s *state2) PubkeyAddress() (address.Address, error) {
|
||||||
return s.Address, nil
|
return s.Address, nil
|
||||||
}
|
}
|
@ -14,8 +14,8 @@ import (
|
|||||||
miner0 "github.com/filecoin-project/specs-actors/actors/builtin/miner"
|
miner0 "github.com/filecoin-project/specs-actors/actors/builtin/miner"
|
||||||
proof0 "github.com/filecoin-project/specs-actors/actors/runtime/proof"
|
proof0 "github.com/filecoin-project/specs-actors/actors/runtime/proof"
|
||||||
smoothing0 "github.com/filecoin-project/specs-actors/actors/util/smoothing"
|
smoothing0 "github.com/filecoin-project/specs-actors/actors/util/smoothing"
|
||||||
builtin1 "github.com/filecoin-project/specs-actors/v2/actors/builtin"
|
builtin2 "github.com/filecoin-project/specs-actors/v2/actors/builtin"
|
||||||
smoothing1 "github.com/filecoin-project/specs-actors/v2/actors/util/smoothing"
|
smoothing2 "github.com/filecoin-project/specs-actors/v2/actors/util/smoothing"
|
||||||
)
|
)
|
||||||
|
|
||||||
// TODO: Why does actors have 2 different versions of this?
|
// TODO: Why does actors have 2 different versions of this?
|
||||||
@ -32,7 +32,7 @@ func QAPowerForWeight(size abi.SectorSize, duration abi.ChainEpoch, dealWeight,
|
|||||||
return miner0.QAPowerForWeight(size, duration, dealWeight, verifiedWeight)
|
return miner0.QAPowerForWeight(size, duration, dealWeight, verifiedWeight)
|
||||||
}
|
}
|
||||||
|
|
||||||
func FromV1FilterEstimate(v1 smoothing1.FilterEstimate) FilterEstimate {
|
func FromV2FilterEstimate(v1 smoothing2.FilterEstimate) FilterEstimate {
|
||||||
return (FilterEstimate)(v1)
|
return (FilterEstimate)(v1)
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -56,13 +56,13 @@ func ActorNameByCode(c cid.Cid) string {
|
|||||||
switch {
|
switch {
|
||||||
case builtin0.IsBuiltinActor(c):
|
case builtin0.IsBuiltinActor(c):
|
||||||
return builtin0.ActorNameByCode(c)
|
return builtin0.ActorNameByCode(c)
|
||||||
case builtin1.IsBuiltinActor(c):
|
case builtin2.IsBuiltinActor(c):
|
||||||
return builtin1.ActorNameByCode(c)
|
return builtin2.ActorNameByCode(c)
|
||||||
default:
|
default:
|
||||||
return "<unknown>"
|
return "<unknown>"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func IsBuiltinActor(c cid.Cid) bool {
|
func IsBuiltinActor(c cid.Cid) bool {
|
||||||
return builtin0.IsBuiltinActor(c) || builtin1.IsBuiltinActor(c)
|
return builtin0.IsBuiltinActor(c) || builtin2.IsBuiltinActor(c)
|
||||||
}
|
}
|
||||||
|
@ -14,15 +14,15 @@ import (
|
|||||||
"github.com/filecoin-project/lotus/node/modules/dtypes"
|
"github.com/filecoin-project/lotus/node/modules/dtypes"
|
||||||
|
|
||||||
builtin0 "github.com/filecoin-project/specs-actors/actors/builtin"
|
builtin0 "github.com/filecoin-project/specs-actors/actors/builtin"
|
||||||
builtin1 "github.com/filecoin-project/specs-actors/v2/actors/builtin"
|
builtin2 "github.com/filecoin-project/specs-actors/v2/actors/builtin"
|
||||||
)
|
)
|
||||||
|
|
||||||
func init() {
|
func init() {
|
||||||
builtin.RegisterActorState(builtin0.InitActorCodeID, func(store adt.Store, root cid.Cid) (cbor.Marshaler, error) {
|
builtin.RegisterActorState(builtin0.InitActorCodeID, func(store adt.Store, root cid.Cid) (cbor.Marshaler, error) {
|
||||||
return load0(store, root)
|
return load0(store, root)
|
||||||
})
|
})
|
||||||
builtin.RegisterActorState(builtin1.InitActorCodeID, func(store adt.Store, root cid.Cid) (cbor.Marshaler, error) {
|
builtin.RegisterActorState(builtin2.InitActorCodeID, func(store adt.Store, root cid.Cid) (cbor.Marshaler, error) {
|
||||||
return load1(store, root)
|
return load2(store, root)
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -32,8 +32,8 @@ func Load(store adt.Store, act *types.Actor) (State, error) {
|
|||||||
switch act.Code {
|
switch act.Code {
|
||||||
case builtin0.InitActorCodeID:
|
case builtin0.InitActorCodeID:
|
||||||
return load0(store, act.Head)
|
return load0(store, act.Head)
|
||||||
case builtin1.InitActorCodeID:
|
case builtin2.InitActorCodeID:
|
||||||
return load1(store, act.Head)
|
return load2(store, act.Head)
|
||||||
}
|
}
|
||||||
return nil, xerrors.Errorf("unknown actor code %s", act.Code)
|
return nil, xerrors.Errorf("unknown actor code %s", act.Code)
|
||||||
}
|
}
|
||||||
|
@ -10,14 +10,14 @@ import (
|
|||||||
"github.com/filecoin-project/lotus/chain/actors/adt"
|
"github.com/filecoin-project/lotus/chain/actors/adt"
|
||||||
"github.com/filecoin-project/lotus/node/modules/dtypes"
|
"github.com/filecoin-project/lotus/node/modules/dtypes"
|
||||||
|
|
||||||
init1 "github.com/filecoin-project/specs-actors/v2/actors/builtin/init"
|
init2 "github.com/filecoin-project/specs-actors/v2/actors/builtin/init"
|
||||||
adt1 "github.com/filecoin-project/specs-actors/v2/actors/util/adt"
|
adt2 "github.com/filecoin-project/specs-actors/v2/actors/util/adt"
|
||||||
)
|
)
|
||||||
|
|
||||||
var _ State = (*state1)(nil)
|
var _ State = (*state2)(nil)
|
||||||
|
|
||||||
func load1(store adt.Store, root cid.Cid) (State, error) {
|
func load2(store adt.Store, root cid.Cid) (State, error) {
|
||||||
out := state1{store: store}
|
out := state2{store: store}
|
||||||
err := store.Get(store.Context(), root, &out)
|
err := store.Get(store.Context(), root, &out)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
@ -25,21 +25,21 @@ func load1(store adt.Store, root cid.Cid) (State, error) {
|
|||||||
return &out, nil
|
return &out, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
type state1 struct {
|
type state2 struct {
|
||||||
init1.State
|
init2.State
|
||||||
store adt.Store
|
store adt.Store
|
||||||
}
|
}
|
||||||
|
|
||||||
func (s *state1) ResolveAddress(address address.Address) (address.Address, bool, error) {
|
func (s *state2) ResolveAddress(address address.Address) (address.Address, bool, error) {
|
||||||
return s.State.ResolveAddress(s.store, address)
|
return s.State.ResolveAddress(s.store, address)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (s *state1) MapAddressToNewID(address address.Address) (address.Address, error) {
|
func (s *state2) MapAddressToNewID(address address.Address) (address.Address, error) {
|
||||||
return s.State.MapAddressToNewID(s.store, address)
|
return s.State.MapAddressToNewID(s.store, address)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (s *state1) ForEachActor(cb func(id abi.ActorID, address address.Address) error) error {
|
func (s *state2) ForEachActor(cb func(id abi.ActorID, address address.Address) error) error {
|
||||||
addrs, err := adt1.AsMap(s.store, s.State.AddressMap)
|
addrs, err := adt2.AsMap(s.store, s.State.AddressMap)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
@ -53,12 +53,12 @@ func (s *state1) ForEachActor(cb func(id abi.ActorID, address address.Address) e
|
|||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
func (s *state1) NetworkName() (dtypes.NetworkName, error) {
|
func (s *state2) NetworkName() (dtypes.NetworkName, error) {
|
||||||
return dtypes.NetworkName(s.State.NetworkName), nil
|
return dtypes.NetworkName(s.State.NetworkName), nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func (s *state1) Remove(addrs ...address.Address) (err error) {
|
func (s *state2) Remove(addrs ...address.Address) (err error) {
|
||||||
m, err := adt1.AsMap(s.store, s.State.AddressMap)
|
m, err := adt2.AsMap(s.store, s.State.AddressMap)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
@ -11,7 +11,7 @@ import (
|
|||||||
|
|
||||||
builtin0 "github.com/filecoin-project/specs-actors/actors/builtin"
|
builtin0 "github.com/filecoin-project/specs-actors/actors/builtin"
|
||||||
market0 "github.com/filecoin-project/specs-actors/actors/builtin/market"
|
market0 "github.com/filecoin-project/specs-actors/actors/builtin/market"
|
||||||
builtin1 "github.com/filecoin-project/specs-actors/v2/actors/builtin"
|
builtin2 "github.com/filecoin-project/specs-actors/v2/actors/builtin"
|
||||||
|
|
||||||
"github.com/filecoin-project/lotus/chain/actors/adt"
|
"github.com/filecoin-project/lotus/chain/actors/adt"
|
||||||
"github.com/filecoin-project/lotus/chain/actors/builtin"
|
"github.com/filecoin-project/lotus/chain/actors/builtin"
|
||||||
@ -22,8 +22,8 @@ func init() {
|
|||||||
builtin.RegisterActorState(builtin0.StorageMarketActorCodeID, func(store adt.Store, root cid.Cid) (cbor.Marshaler, error) {
|
builtin.RegisterActorState(builtin0.StorageMarketActorCodeID, func(store adt.Store, root cid.Cid) (cbor.Marshaler, error) {
|
||||||
return load0(store, root)
|
return load0(store, root)
|
||||||
})
|
})
|
||||||
builtin.RegisterActorState(builtin1.StorageMarketActorCodeID, func(store adt.Store, root cid.Cid) (cbor.Marshaler, error) {
|
builtin.RegisterActorState(builtin2.StorageMarketActorCodeID, func(store adt.Store, root cid.Cid) (cbor.Marshaler, error) {
|
||||||
return load1(store, root)
|
return load2(store, root)
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -33,8 +33,8 @@ func Load(store adt.Store, act *types.Actor) (st State, err error) {
|
|||||||
switch act.Code {
|
switch act.Code {
|
||||||
case builtin0.StorageMarketActorCodeID:
|
case builtin0.StorageMarketActorCodeID:
|
||||||
return load0(store, act.Head)
|
return load0(store, act.Head)
|
||||||
case builtin1.StorageMarketActorCodeID:
|
case builtin2.StorageMarketActorCodeID:
|
||||||
return load1(store, act.Head)
|
return load2(store, act.Head)
|
||||||
}
|
}
|
||||||
return nil, xerrors.Errorf("unknown actor code %s", act.Code)
|
return nil, xerrors.Errorf("unknown actor code %s", act.Code)
|
||||||
}
|
}
|
||||||
|
@ -1,205 +0,0 @@
|
|||||||
package market
|
|
||||||
|
|
||||||
import (
|
|
||||||
"bytes"
|
|
||||||
|
|
||||||
"github.com/filecoin-project/go-address"
|
|
||||||
"github.com/filecoin-project/go-state-types/abi"
|
|
||||||
"github.com/ipfs/go-cid"
|
|
||||||
cbg "github.com/whyrusleeping/cbor-gen"
|
|
||||||
|
|
||||||
"github.com/filecoin-project/lotus/chain/actors/adt"
|
|
||||||
"github.com/filecoin-project/lotus/chain/types"
|
|
||||||
|
|
||||||
market1 "github.com/filecoin-project/specs-actors/v2/actors/builtin/market"
|
|
||||||
adt1 "github.com/filecoin-project/specs-actors/v2/actors/util/adt"
|
|
||||||
)
|
|
||||||
|
|
||||||
var _ State = (*state1)(nil)
|
|
||||||
|
|
||||||
func load1(store adt.Store, root cid.Cid) (State, error) {
|
|
||||||
out := state1{store: store}
|
|
||||||
err := store.Get(store.Context(), root, &out)
|
|
||||||
if err != nil {
|
|
||||||
return nil, err
|
|
||||||
}
|
|
||||||
return &out, nil
|
|
||||||
}
|
|
||||||
|
|
||||||
type state1 struct {
|
|
||||||
market1.State
|
|
||||||
store adt.Store
|
|
||||||
}
|
|
||||||
|
|
||||||
func (s *state1) TotalLocked() (abi.TokenAmount, error) {
|
|
||||||
fml := types.BigAdd(s.TotalClientLockedCollateral, s.TotalProviderLockedCollateral)
|
|
||||||
fml = types.BigAdd(fml, s.TotalClientStorageFee)
|
|
||||||
return fml, nil
|
|
||||||
}
|
|
||||||
|
|
||||||
func (s *state1) BalancesChanged(otherState State) (bool, error) {
|
|
||||||
otherState1, ok := otherState.(*state1)
|
|
||||||
if !ok {
|
|
||||||
// there's no way to compare different versions of the state, so let's
|
|
||||||
// just say that means the state of balances has changed
|
|
||||||
return true, nil
|
|
||||||
}
|
|
||||||
return !s.State.EscrowTable.Equals(otherState1.State.EscrowTable) || !s.State.LockedTable.Equals(otherState1.State.LockedTable), nil
|
|
||||||
}
|
|
||||||
|
|
||||||
func (s *state1) StatesChanged(otherState State) (bool, error) {
|
|
||||||
otherState1, ok := otherState.(*state1)
|
|
||||||
if !ok {
|
|
||||||
// there's no way to compare different versions of the state, so let's
|
|
||||||
// just say that means the state of balances has changed
|
|
||||||
return true, nil
|
|
||||||
}
|
|
||||||
return !s.State.States.Equals(otherState1.State.States), nil
|
|
||||||
}
|
|
||||||
|
|
||||||
func (s *state1) States() (DealStates, error) {
|
|
||||||
stateArray, err := adt1.AsArray(s.store, s.State.States)
|
|
||||||
if err != nil {
|
|
||||||
return nil, err
|
|
||||||
}
|
|
||||||
return &dealStates1{stateArray}, nil
|
|
||||||
}
|
|
||||||
|
|
||||||
func (s *state1) ProposalsChanged(otherState State) (bool, error) {
|
|
||||||
otherState1, ok := otherState.(*state1)
|
|
||||||
if !ok {
|
|
||||||
// there's no way to compare different versions of the state, so let's
|
|
||||||
// just say that means the state of balances has changed
|
|
||||||
return true, nil
|
|
||||||
}
|
|
||||||
return !s.State.Proposals.Equals(otherState1.State.Proposals), nil
|
|
||||||
}
|
|
||||||
|
|
||||||
func (s *state1) Proposals() (DealProposals, error) {
|
|
||||||
proposalArray, err := adt1.AsArray(s.store, s.State.Proposals)
|
|
||||||
if err != nil {
|
|
||||||
return nil, err
|
|
||||||
}
|
|
||||||
return &dealProposals1{proposalArray}, nil
|
|
||||||
}
|
|
||||||
|
|
||||||
func (s *state1) EscrowTable() (BalanceTable, error) {
|
|
||||||
bt, err := adt1.AsBalanceTable(s.store, s.State.EscrowTable)
|
|
||||||
if err != nil {
|
|
||||||
return nil, err
|
|
||||||
}
|
|
||||||
return &balanceTable1{bt}, nil
|
|
||||||
}
|
|
||||||
|
|
||||||
func (s *state1) LockedTable() (BalanceTable, error) {
|
|
||||||
bt, err := adt1.AsBalanceTable(s.store, s.State.LockedTable)
|
|
||||||
if err != nil {
|
|
||||||
return nil, err
|
|
||||||
}
|
|
||||||
return &balanceTable1{bt}, nil
|
|
||||||
}
|
|
||||||
|
|
||||||
func (s *state1) VerifyDealsForActivation(
|
|
||||||
minerAddr address.Address, deals []abi.DealID, currEpoch, sectorExpiry abi.ChainEpoch,
|
|
||||||
) (weight, verifiedWeight abi.DealWeight, err error) {
|
|
||||||
w, vw, _, err := market1.ValidateDealsForActivation(&s.State, s.store, deals, minerAddr, sectorExpiry, currEpoch)
|
|
||||||
return w, vw, err
|
|
||||||
}
|
|
||||||
|
|
||||||
type balanceTable1 struct {
|
|
||||||
*adt1.BalanceTable
|
|
||||||
}
|
|
||||||
|
|
||||||
func (bt *balanceTable1) ForEach(cb func(address.Address, abi.TokenAmount) error) error {
|
|
||||||
asMap := (*adt1.Map)(bt.BalanceTable)
|
|
||||||
var ta abi.TokenAmount
|
|
||||||
return asMap.ForEach(&ta, func(key string) error {
|
|
||||||
a, err := address.NewFromBytes([]byte(key))
|
|
||||||
if err != nil {
|
|
||||||
return err
|
|
||||||
}
|
|
||||||
return cb(a, ta)
|
|
||||||
})
|
|
||||||
}
|
|
||||||
|
|
||||||
type dealStates1 struct {
|
|
||||||
adt.Array
|
|
||||||
}
|
|
||||||
|
|
||||||
func (s *dealStates1) Get(dealID abi.DealID) (*DealState, bool, error) {
|
|
||||||
var deal1 market1.DealState
|
|
||||||
found, err := s.Array.Get(uint64(dealID), &deal1)
|
|
||||||
if err != nil {
|
|
||||||
return nil, false, err
|
|
||||||
}
|
|
||||||
if !found {
|
|
||||||
return nil, false, nil
|
|
||||||
}
|
|
||||||
deal := fromV1DealState(deal1)
|
|
||||||
return &deal, true, nil
|
|
||||||
}
|
|
||||||
|
|
||||||
func (s *dealStates1) ForEach(cb func(dealID abi.DealID, ds DealState) error) error {
|
|
||||||
var ds1 market1.DealState
|
|
||||||
return s.Array.ForEach(&ds1, func(idx int64) error {
|
|
||||||
return cb(abi.DealID(idx), fromV1DealState(ds1))
|
|
||||||
})
|
|
||||||
}
|
|
||||||
|
|
||||||
func (s *dealStates1) decode(val *cbg.Deferred) (*DealState, error) {
|
|
||||||
var ds1 market1.DealState
|
|
||||||
if err := ds1.UnmarshalCBOR(bytes.NewReader(val.Raw)); err != nil {
|
|
||||||
return nil, err
|
|
||||||
}
|
|
||||||
ds := fromV1DealState(ds1)
|
|
||||||
return &ds, nil
|
|
||||||
}
|
|
||||||
|
|
||||||
func (s *dealStates1) array() adt.Array {
|
|
||||||
return s.Array
|
|
||||||
}
|
|
||||||
|
|
||||||
func fromV1DealState(v1 market1.DealState) DealState {
|
|
||||||
return (DealState)(v1)
|
|
||||||
}
|
|
||||||
|
|
||||||
type dealProposals1 struct {
|
|
||||||
adt.Array
|
|
||||||
}
|
|
||||||
|
|
||||||
func (s *dealProposals1) Get(dealID abi.DealID) (*DealProposal, bool, error) {
|
|
||||||
var proposal1 market1.DealProposal
|
|
||||||
found, err := s.Array.Get(uint64(dealID), &proposal1)
|
|
||||||
if err != nil {
|
|
||||||
return nil, false, err
|
|
||||||
}
|
|
||||||
if !found {
|
|
||||||
return nil, false, nil
|
|
||||||
}
|
|
||||||
proposal := fromV1DealProposal(proposal1)
|
|
||||||
return &proposal, true, nil
|
|
||||||
}
|
|
||||||
|
|
||||||
func (s *dealProposals1) ForEach(cb func(dealID abi.DealID, dp DealProposal) error) error {
|
|
||||||
var dp1 market1.DealProposal
|
|
||||||
return s.Array.ForEach(&dp1, func(idx int64) error {
|
|
||||||
return cb(abi.DealID(idx), fromV1DealProposal(dp1))
|
|
||||||
})
|
|
||||||
}
|
|
||||||
|
|
||||||
func (s *dealProposals1) decode(val *cbg.Deferred) (*DealProposal, error) {
|
|
||||||
var dp1 market1.DealProposal
|
|
||||||
if err := dp1.UnmarshalCBOR(bytes.NewReader(val.Raw)); err != nil {
|
|
||||||
return nil, err
|
|
||||||
}
|
|
||||||
dp := fromV1DealProposal(dp1)
|
|
||||||
return &dp, nil
|
|
||||||
}
|
|
||||||
|
|
||||||
func (s *dealProposals1) array() adt.Array {
|
|
||||||
return s.Array
|
|
||||||
}
|
|
||||||
|
|
||||||
func fromV1DealProposal(v1 market1.DealProposal) DealProposal {
|
|
||||||
return (DealProposal)(v1)
|
|
||||||
}
|
|
205
chain/actors/builtin/market/v2.go
Normal file
205
chain/actors/builtin/market/v2.go
Normal file
@ -0,0 +1,205 @@
|
|||||||
|
package market
|
||||||
|
|
||||||
|
import (
|
||||||
|
"bytes"
|
||||||
|
|
||||||
|
"github.com/filecoin-project/go-address"
|
||||||
|
"github.com/filecoin-project/go-state-types/abi"
|
||||||
|
"github.com/ipfs/go-cid"
|
||||||
|
cbg "github.com/whyrusleeping/cbor-gen"
|
||||||
|
|
||||||
|
"github.com/filecoin-project/lotus/chain/actors/adt"
|
||||||
|
"github.com/filecoin-project/lotus/chain/types"
|
||||||
|
|
||||||
|
market2 "github.com/filecoin-project/specs-actors/v2/actors/builtin/market"
|
||||||
|
adt2 "github.com/filecoin-project/specs-actors/v2/actors/util/adt"
|
||||||
|
)
|
||||||
|
|
||||||
|
var _ State = (*state2)(nil)
|
||||||
|
|
||||||
|
func load2(store adt.Store, root cid.Cid) (State, error) {
|
||||||
|
out := state2{store: store}
|
||||||
|
err := store.Get(store.Context(), root, &out)
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
return &out, nil
|
||||||
|
}
|
||||||
|
|
||||||
|
type state2 struct {
|
||||||
|
market2.State
|
||||||
|
store adt.Store
|
||||||
|
}
|
||||||
|
|
||||||
|
func (s *state2) TotalLocked() (abi.TokenAmount, error) {
|
||||||
|
fml := types.BigAdd(s.TotalClientLockedCollateral, s.TotalProviderLockedCollateral)
|
||||||
|
fml = types.BigAdd(fml, s.TotalClientStorageFee)
|
||||||
|
return fml, nil
|
||||||
|
}
|
||||||
|
|
||||||
|
func (s *state2) BalancesChanged(otherState State) (bool, error) {
|
||||||
|
otherState2, ok := otherState.(*state2)
|
||||||
|
if !ok {
|
||||||
|
// there's no way to compare different versions of the state, so let's
|
||||||
|
// just say that means the state of balances has changed
|
||||||
|
return true, nil
|
||||||
|
}
|
||||||
|
return !s.State.EscrowTable.Equals(otherState2.State.EscrowTable) || !s.State.LockedTable.Equals(otherState2.State.LockedTable), nil
|
||||||
|
}
|
||||||
|
|
||||||
|
func (s *state2) StatesChanged(otherState State) (bool, error) {
|
||||||
|
otherState2, ok := otherState.(*state2)
|
||||||
|
if !ok {
|
||||||
|
// there's no way to compare different versions of the state, so let's
|
||||||
|
// just say that means the state of balances has changed
|
||||||
|
return true, nil
|
||||||
|
}
|
||||||
|
return !s.State.States.Equals(otherState2.State.States), nil
|
||||||
|
}
|
||||||
|
|
||||||
|
func (s *state2) States() (DealStates, error) {
|
||||||
|
stateArray, err := adt2.AsArray(s.store, s.State.States)
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
return &dealStates2{stateArray}, nil
|
||||||
|
}
|
||||||
|
|
||||||
|
func (s *state2) ProposalsChanged(otherState State) (bool, error) {
|
||||||
|
otherState2, ok := otherState.(*state2)
|
||||||
|
if !ok {
|
||||||
|
// there's no way to compare different versions of the state, so let's
|
||||||
|
// just say that means the state of balances has changed
|
||||||
|
return true, nil
|
||||||
|
}
|
||||||
|
return !s.State.Proposals.Equals(otherState2.State.Proposals), nil
|
||||||
|
}
|
||||||
|
|
||||||
|
func (s *state2) Proposals() (DealProposals, error) {
|
||||||
|
proposalArray, err := adt2.AsArray(s.store, s.State.Proposals)
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
return &dealProposals2{proposalArray}, nil
|
||||||
|
}
|
||||||
|
|
||||||
|
func (s *state2) EscrowTable() (BalanceTable, error) {
|
||||||
|
bt, err := adt2.AsBalanceTable(s.store, s.State.EscrowTable)
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
return &balanceTable2{bt}, nil
|
||||||
|
}
|
||||||
|
|
||||||
|
func (s *state2) LockedTable() (BalanceTable, error) {
|
||||||
|
bt, err := adt2.AsBalanceTable(s.store, s.State.LockedTable)
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
return &balanceTable2{bt}, nil
|
||||||
|
}
|
||||||
|
|
||||||
|
func (s *state2) VerifyDealsForActivation(
|
||||||
|
minerAddr address.Address, deals []abi.DealID, currEpoch, sectorExpiry abi.ChainEpoch,
|
||||||
|
) (weight, verifiedWeight abi.DealWeight, err error) {
|
||||||
|
w, vw, _, err := market2.ValidateDealsForActivation(&s.State, s.store, deals, minerAddr, sectorExpiry, currEpoch)
|
||||||
|
return w, vw, err
|
||||||
|
}
|
||||||
|
|
||||||
|
type balanceTable2 struct {
|
||||||
|
*adt2.BalanceTable
|
||||||
|
}
|
||||||
|
|
||||||
|
func (bt *balanceTable2) ForEach(cb func(address.Address, abi.TokenAmount) error) error {
|
||||||
|
asMap := (*adt2.Map)(bt.BalanceTable)
|
||||||
|
var ta abi.TokenAmount
|
||||||
|
return asMap.ForEach(&ta, func(key string) error {
|
||||||
|
a, err := address.NewFromBytes([]byte(key))
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
return cb(a, ta)
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
type dealStates2 struct {
|
||||||
|
adt.Array
|
||||||
|
}
|
||||||
|
|
||||||
|
func (s *dealStates2) Get(dealID abi.DealID) (*DealState, bool, error) {
|
||||||
|
var deal2 market2.DealState
|
||||||
|
found, err := s.Array.Get(uint64(dealID), &deal2)
|
||||||
|
if err != nil {
|
||||||
|
return nil, false, err
|
||||||
|
}
|
||||||
|
if !found {
|
||||||
|
return nil, false, nil
|
||||||
|
}
|
||||||
|
deal := fromV2DealState(deal2)
|
||||||
|
return &deal, true, nil
|
||||||
|
}
|
||||||
|
|
||||||
|
func (s *dealStates2) ForEach(cb func(dealID abi.DealID, ds DealState) error) error {
|
||||||
|
var ds1 market2.DealState
|
||||||
|
return s.Array.ForEach(&ds1, func(idx int64) error {
|
||||||
|
return cb(abi.DealID(idx), fromV2DealState(ds1))
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
func (s *dealStates2) decode(val *cbg.Deferred) (*DealState, error) {
|
||||||
|
var ds1 market2.DealState
|
||||||
|
if err := ds1.UnmarshalCBOR(bytes.NewReader(val.Raw)); err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
ds := fromV2DealState(ds1)
|
||||||
|
return &ds, nil
|
||||||
|
}
|
||||||
|
|
||||||
|
func (s *dealStates2) array() adt.Array {
|
||||||
|
return s.Array
|
||||||
|
}
|
||||||
|
|
||||||
|
func fromV2DealState(v1 market2.DealState) DealState {
|
||||||
|
return (DealState)(v1)
|
||||||
|
}
|
||||||
|
|
||||||
|
type dealProposals2 struct {
|
||||||
|
adt.Array
|
||||||
|
}
|
||||||
|
|
||||||
|
func (s *dealProposals2) Get(dealID abi.DealID) (*DealProposal, bool, error) {
|
||||||
|
var proposal2 market2.DealProposal
|
||||||
|
found, err := s.Array.Get(uint64(dealID), &proposal2)
|
||||||
|
if err != nil {
|
||||||
|
return nil, false, err
|
||||||
|
}
|
||||||
|
if !found {
|
||||||
|
return nil, false, nil
|
||||||
|
}
|
||||||
|
proposal := fromV2DealProposal(proposal2)
|
||||||
|
return &proposal, true, nil
|
||||||
|
}
|
||||||
|
|
||||||
|
func (s *dealProposals2) ForEach(cb func(dealID abi.DealID, dp DealProposal) error) error {
|
||||||
|
var dp1 market2.DealProposal
|
||||||
|
return s.Array.ForEach(&dp1, func(idx int64) error {
|
||||||
|
return cb(abi.DealID(idx), fromV2DealProposal(dp1))
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
func (s *dealProposals2) decode(val *cbg.Deferred) (*DealProposal, error) {
|
||||||
|
var dp1 market2.DealProposal
|
||||||
|
if err := dp1.UnmarshalCBOR(bytes.NewReader(val.Raw)); err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
dp := fromV2DealProposal(dp1)
|
||||||
|
return &dp, nil
|
||||||
|
}
|
||||||
|
|
||||||
|
func (s *dealProposals2) array() adt.Array {
|
||||||
|
return s.Array
|
||||||
|
}
|
||||||
|
|
||||||
|
func fromV2DealProposal(v1 market2.DealProposal) DealProposal {
|
||||||
|
return (DealProposal)(v1)
|
||||||
|
}
|
@ -18,19 +18,19 @@ import (
|
|||||||
|
|
||||||
builtin0 "github.com/filecoin-project/specs-actors/actors/builtin"
|
builtin0 "github.com/filecoin-project/specs-actors/actors/builtin"
|
||||||
miner0 "github.com/filecoin-project/specs-actors/actors/builtin/miner"
|
miner0 "github.com/filecoin-project/specs-actors/actors/builtin/miner"
|
||||||
builtin1 "github.com/filecoin-project/specs-actors/v2/actors/builtin"
|
builtin2 "github.com/filecoin-project/specs-actors/v2/actors/builtin"
|
||||||
)
|
)
|
||||||
|
|
||||||
func init() {
|
func init() {
|
||||||
builtin.RegisterActorState(builtin0.StorageMinerActorCodeID, func(store adt.Store, root cid.Cid) (cbor.Marshaler, error) {
|
builtin.RegisterActorState(builtin0.StorageMinerActorCodeID, func(store adt.Store, root cid.Cid) (cbor.Marshaler, error) {
|
||||||
return load0(store, root)
|
return load0(store, root)
|
||||||
})
|
})
|
||||||
builtin.RegisterActorState(builtin1.StorageMinerActorCodeID, func(store adt.Store, root cid.Cid) (cbor.Marshaler, error) {
|
builtin.RegisterActorState(builtin2.StorageMinerActorCodeID, func(store adt.Store, root cid.Cid) (cbor.Marshaler, error) {
|
||||||
return load1(store, root)
|
return load2(store, root)
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
// Unchanged between v0 and v1 actors
|
// Unchanged between v0 and v2 actors
|
||||||
var WPoStProvingPeriod = miner0.WPoStProvingPeriod
|
var WPoStProvingPeriod = miner0.WPoStProvingPeriod
|
||||||
|
|
||||||
const MinSectorExpiration = miner0.MinSectorExpiration
|
const MinSectorExpiration = miner0.MinSectorExpiration
|
||||||
@ -39,8 +39,8 @@ func Load(store adt.Store, act *types.Actor) (st State, err error) {
|
|||||||
switch act.Code {
|
switch act.Code {
|
||||||
case builtin0.StorageMinerActorCodeID:
|
case builtin0.StorageMinerActorCodeID:
|
||||||
return load0(store, act.Head)
|
return load0(store, act.Head)
|
||||||
case builtin1.StorageMinerActorCodeID:
|
case builtin2.StorageMinerActorCodeID:
|
||||||
return load1(store, act.Head)
|
return load2(store, act.Head)
|
||||||
}
|
}
|
||||||
return nil, xerrors.Errorf("unknown actor code %s", act.Code)
|
return nil, xerrors.Errorf("unknown actor code %s", act.Code)
|
||||||
}
|
}
|
||||||
|
@ -14,14 +14,14 @@ import (
|
|||||||
|
|
||||||
"github.com/filecoin-project/lotus/chain/actors/adt"
|
"github.com/filecoin-project/lotus/chain/actors/adt"
|
||||||
|
|
||||||
miner1 "github.com/filecoin-project/specs-actors/v2/actors/builtin/miner"
|
miner2 "github.com/filecoin-project/specs-actors/v2/actors/builtin/miner"
|
||||||
adt1 "github.com/filecoin-project/specs-actors/v2/actors/util/adt"
|
adt2 "github.com/filecoin-project/specs-actors/v2/actors/util/adt"
|
||||||
)
|
)
|
||||||
|
|
||||||
var _ State = (*state1)(nil)
|
var _ State = (*state2)(nil)
|
||||||
|
|
||||||
func load1(store adt.Store, root cid.Cid) (State, error) {
|
func load2(store adt.Store, root cid.Cid) (State, error) {
|
||||||
out := state1{store: store}
|
out := state2{store: store}
|
||||||
err := store.Get(store.Context(), root, &out)
|
err := store.Get(store.Context(), root, &out)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
@ -29,30 +29,30 @@ func load1(store adt.Store, root cid.Cid) (State, error) {
|
|||||||
return &out, nil
|
return &out, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
type state1 struct {
|
type state2 struct {
|
||||||
miner1.State
|
miner2.State
|
||||||
store adt.Store
|
store adt.Store
|
||||||
}
|
}
|
||||||
|
|
||||||
type deadline1 struct {
|
type deadline2 struct {
|
||||||
miner1.Deadline
|
miner2.Deadline
|
||||||
store adt.Store
|
store adt.Store
|
||||||
}
|
}
|
||||||
|
|
||||||
type partition1 struct {
|
type partition2 struct {
|
||||||
miner1.Partition
|
miner2.Partition
|
||||||
store adt.Store
|
store adt.Store
|
||||||
}
|
}
|
||||||
|
|
||||||
func (s *state1) AvailableBalance(bal abi.TokenAmount) (abi.TokenAmount, error) {
|
func (s *state2) AvailableBalance(bal abi.TokenAmount) (abi.TokenAmount, error) {
|
||||||
return s.GetAvailableBalance(bal), nil
|
return s.GetAvailableBalance(bal), nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func (s *state1) VestedFunds(epoch abi.ChainEpoch) (abi.TokenAmount, error) {
|
func (s *state2) VestedFunds(epoch abi.ChainEpoch) (abi.TokenAmount, error) {
|
||||||
return s.CheckVestedFunds(s.store, epoch)
|
return s.CheckVestedFunds(s.store, epoch)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (s *state1) LockedFunds() (LockedFunds, error) {
|
func (s *state2) LockedFunds() (LockedFunds, error) {
|
||||||
return LockedFunds{
|
return LockedFunds{
|
||||||
VestingFunds: s.State.LockedFunds,
|
VestingFunds: s.State.LockedFunds,
|
||||||
InitialPledgeRequirement: s.State.InitialPledge,
|
InitialPledgeRequirement: s.State.InitialPledge,
|
||||||
@ -60,25 +60,25 @@ func (s *state1) LockedFunds() (LockedFunds, error) {
|
|||||||
}, nil
|
}, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func (s *state1) InitialPledge() (abi.TokenAmount, error) {
|
func (s *state2) InitialPledge() (abi.TokenAmount, error) {
|
||||||
return s.State.InitialPledge, nil
|
return s.State.InitialPledge, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func (s *state1) PreCommitDeposits() (abi.TokenAmount, error) {
|
func (s *state2) PreCommitDeposits() (abi.TokenAmount, error) {
|
||||||
return s.State.PreCommitDeposits, nil
|
return s.State.PreCommitDeposits, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func (s *state1) GetSector(num abi.SectorNumber) (*SectorOnChainInfo, error) {
|
func (s *state2) 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 {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
|
||||||
ret := fromV1SectorOnChainInfo(*info)
|
ret := fromV2SectorOnChainInfo(*info)
|
||||||
return &ret, nil
|
return &ret, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func (s *state1) FindSector(num abi.SectorNumber) (*SectorLocation, error) {
|
func (s *state2) FindSector(num abi.SectorNumber) (*SectorLocation, error) {
|
||||||
dlIdx, partIdx, err := s.State.FindSector(s.store, num)
|
dlIdx, partIdx, err := s.State.FindSector(s.store, num)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
@ -89,13 +89,13 @@ func (s *state1) FindSector(num abi.SectorNumber) (*SectorLocation, error) {
|
|||||||
}, nil
|
}, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func (s *state1) NumLiveSectors() (uint64, error) {
|
func (s *state2) NumLiveSectors() (uint64, error) {
|
||||||
dls, err := s.State.LoadDeadlines(s.store)
|
dls, err := s.State.LoadDeadlines(s.store)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return 0, err
|
return 0, err
|
||||||
}
|
}
|
||||||
var total uint64
|
var total uint64
|
||||||
if err := dls.ForEach(s.store, func(dlIdx uint64, dl *miner1.Deadline) error {
|
if err := dls.ForEach(s.store, func(dlIdx uint64, dl *miner2.Deadline) error {
|
||||||
total += dl.LiveSectors
|
total += dl.LiveSectors
|
||||||
return nil
|
return nil
|
||||||
}); err != nil {
|
}); err != nil {
|
||||||
@ -109,7 +109,7 @@ func (s *state1) NumLiveSectors() (uint64, error) {
|
|||||||
// If the sector isn't found or has already been terminated, this method returns
|
// If the sector isn't found or has already been terminated, this method returns
|
||||||
// nil and no error. If the sector does not expire early, the Early expiration
|
// nil and no error. If the sector does not expire early, the Early expiration
|
||||||
// field is 0.
|
// field is 0.
|
||||||
func (s *state1) GetSectorExpiration(num abi.SectorNumber) (*SectorExpiration, error) {
|
func (s *state2) GetSectorExpiration(num abi.SectorNumber) (*SectorExpiration, error) {
|
||||||
dls, err := s.State.LoadDeadlines(s.store)
|
dls, err := s.State.LoadDeadlines(s.store)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
@ -122,13 +122,13 @@ func (s *state1) GetSectorExpiration(num abi.SectorNumber) (*SectorExpiration, e
|
|||||||
// of the expiration queue.
|
// of the expiration queue.
|
||||||
stopErr := errors.New("stop")
|
stopErr := errors.New("stop")
|
||||||
out := SectorExpiration{}
|
out := SectorExpiration{}
|
||||||
err = dls.ForEach(s.store, func(dlIdx uint64, dl *miner1.Deadline) error {
|
err = dls.ForEach(s.store, func(dlIdx uint64, dl *miner2.Deadline) error {
|
||||||
partitions, err := dl.PartitionsArray(s.store)
|
partitions, err := dl.PartitionsArray(s.store)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
quant := s.State.QuantSpecForDeadline(dlIdx)
|
quant := s.State.QuantSpecForDeadline(dlIdx)
|
||||||
var part miner1.Partition
|
var part miner2.Partition
|
||||||
return partitions.ForEach(&part, func(partIdx int64) error {
|
return partitions.ForEach(&part, func(partIdx int64) error {
|
||||||
if found, err := part.Sectors.IsSet(uint64(num)); err != nil {
|
if found, err := part.Sectors.IsSet(uint64(num)); err != nil {
|
||||||
return err
|
return err
|
||||||
@ -142,11 +142,11 @@ func (s *state1) GetSectorExpiration(num abi.SectorNumber) (*SectorExpiration, e
|
|||||||
return stopErr
|
return stopErr
|
||||||
}
|
}
|
||||||
|
|
||||||
q, err := miner1.LoadExpirationQueue(s.store, part.ExpirationsEpochs, quant)
|
q, err := miner2.LoadExpirationQueue(s.store, part.ExpirationsEpochs, quant)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
var exp miner1.ExpirationSet
|
var exp miner2.ExpirationSet
|
||||||
return q.ForEach(&exp, func(epoch int64) error {
|
return q.ForEach(&exp, func(epoch int64) error {
|
||||||
if early, err := exp.EarlySectors.IsSet(uint64(num)); err != nil {
|
if early, err := exp.EarlySectors.IsSet(uint64(num)); err != nil {
|
||||||
return err
|
return err
|
||||||
@ -176,19 +176,19 @@ func (s *state1) GetSectorExpiration(num abi.SectorNumber) (*SectorExpiration, e
|
|||||||
return &out, nil
|
return &out, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func (s *state1) GetPrecommittedSector(num abi.SectorNumber) (*SectorPreCommitOnChainInfo, error) {
|
func (s *state2) GetPrecommittedSector(num abi.SectorNumber) (*SectorPreCommitOnChainInfo, error) {
|
||||||
info, ok, err := s.State.GetPrecommittedSector(s.store, num)
|
info, ok, err := s.State.GetPrecommittedSector(s.store, num)
|
||||||
if !ok || err != nil {
|
if !ok || err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
|
||||||
ret := fromV1SectorPreCommitOnChainInfo(*info)
|
ret := fromV2SectorPreCommitOnChainInfo(*info)
|
||||||
|
|
||||||
return &ret, nil
|
return &ret, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func (s *state1) LoadSectors(snos *bitfield.BitField) ([]*SectorOnChainInfo, error) {
|
func (s *state2) LoadSectors(snos *bitfield.BitField) ([]*SectorOnChainInfo, error) {
|
||||||
sectors, err := miner1.LoadSectors(s.store, s.State.Sectors)
|
sectors, err := miner2.LoadSectors(s.store, s.State.Sectors)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
@ -196,9 +196,9 @@ func (s *state1) LoadSectors(snos *bitfield.BitField) ([]*SectorOnChainInfo, err
|
|||||||
// If no sector numbers are specified, load all.
|
// If no sector numbers are specified, load all.
|
||||||
if snos == nil {
|
if snos == nil {
|
||||||
infos := make([]*SectorOnChainInfo, 0, sectors.Length())
|
infos := make([]*SectorOnChainInfo, 0, sectors.Length())
|
||||||
var info1 miner1.SectorOnChainInfo
|
var info2 miner2.SectorOnChainInfo
|
||||||
if err := sectors.ForEach(&info1, func(_ int64) error {
|
if err := sectors.ForEach(&info2, func(_ int64) error {
|
||||||
info := fromV1SectorOnChainInfo(info1)
|
info := fromV2SectorOnChainInfo(info2)
|
||||||
infos = append(infos, &info)
|
infos = append(infos, &info)
|
||||||
return nil
|
return nil
|
||||||
}); err != nil {
|
}); err != nil {
|
||||||
@ -208,19 +208,19 @@ func (s *state1) LoadSectors(snos *bitfield.BitField) ([]*SectorOnChainInfo, err
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Otherwise, load selected.
|
// Otherwise, load selected.
|
||||||
infos1, err := sectors.Load(*snos)
|
infos2, err := sectors.Load(*snos)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
infos := make([]*SectorOnChainInfo, len(infos1))
|
infos := make([]*SectorOnChainInfo, len(infos2))
|
||||||
for i, info1 := range infos1 {
|
for i, info2 := range infos2 {
|
||||||
info := fromV1SectorOnChainInfo(*info1)
|
info := fromV2SectorOnChainInfo(*info2)
|
||||||
infos[i] = &info
|
infos[i] = &info
|
||||||
}
|
}
|
||||||
return infos, nil
|
return infos, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func (s *state1) IsAllocated(num abi.SectorNumber) (bool, error) {
|
func (s *state2) IsAllocated(num abi.SectorNumber) (bool, error) {
|
||||||
var allocatedSectors bitfield.BitField
|
var allocatedSectors bitfield.BitField
|
||||||
if err := s.store.Get(s.store.Context(), s.State.AllocatedSectors, &allocatedSectors); err != nil {
|
if err := s.store.Get(s.store.Context(), s.State.AllocatedSectors, &allocatedSectors); err != nil {
|
||||||
return false, err
|
return false, err
|
||||||
@ -229,7 +229,7 @@ func (s *state1) IsAllocated(num abi.SectorNumber) (bool, error) {
|
|||||||
return allocatedSectors.IsSet(uint64(num))
|
return allocatedSectors.IsSet(uint64(num))
|
||||||
}
|
}
|
||||||
|
|
||||||
func (s *state1) LoadDeadline(idx uint64) (Deadline, error) {
|
func (s *state2) LoadDeadline(idx uint64) (Deadline, error) {
|
||||||
dls, err := s.State.LoadDeadlines(s.store)
|
dls, err := s.State.LoadDeadlines(s.store)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
@ -238,34 +238,34 @@ func (s *state1) LoadDeadline(idx uint64) (Deadline, error) {
|
|||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
return &deadline1{*dl, s.store}, nil
|
return &deadline2{*dl, s.store}, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func (s *state1) ForEachDeadline(cb func(uint64, Deadline) error) error {
|
func (s *state2) ForEachDeadline(cb func(uint64, Deadline) error) error {
|
||||||
dls, err := s.State.LoadDeadlines(s.store)
|
dls, err := s.State.LoadDeadlines(s.store)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
return dls.ForEach(s.store, func(i uint64, dl *miner1.Deadline) error {
|
return dls.ForEach(s.store, func(i uint64, dl *miner2.Deadline) error {
|
||||||
return cb(i, &deadline1{*dl, s.store})
|
return cb(i, &deadline2{*dl, s.store})
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
func (s *state1) NumDeadlines() (uint64, error) {
|
func (s *state2) NumDeadlines() (uint64, error) {
|
||||||
return miner1.WPoStPeriodDeadlines, nil
|
return miner2.WPoStPeriodDeadlines, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func (s *state1) DeadlinesChanged(other State) (bool, error) {
|
func (s *state2) DeadlinesChanged(other State) (bool, error) {
|
||||||
other1, ok := other.(*state1)
|
other2, ok := other.(*state2)
|
||||||
if !ok {
|
if !ok {
|
||||||
// treat an upgrade as a change, always
|
// treat an upgrade as a change, always
|
||||||
return true, nil
|
return true, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
return s.State.Deadlines.Equals(other1.Deadlines), nil
|
return s.State.Deadlines.Equals(other2.Deadlines), nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func (s *state1) Info() (MinerInfo, error) {
|
func (s *state2) Info() (MinerInfo, error) {
|
||||||
info, err := s.State.GetInfo(s.store)
|
info, err := s.State.GetInfo(s.store)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return MinerInfo{}, err
|
return MinerInfo{}, err
|
||||||
@ -299,105 +299,105 @@ func (s *state1) Info() (MinerInfo, error) {
|
|||||||
return mi, nil
|
return mi, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func (s *state1) DeadlineInfo(epoch abi.ChainEpoch) (*dline.Info, error) {
|
func (s *state2) DeadlineInfo(epoch abi.ChainEpoch) (*dline.Info, error) {
|
||||||
return s.State.DeadlineInfo(epoch), nil
|
return s.State.DeadlineInfo(epoch), nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func (s *state1) sectors() (adt.Array, error) {
|
func (s *state2) sectors() (adt.Array, error) {
|
||||||
return adt1.AsArray(s.store, s.Sectors)
|
return adt2.AsArray(s.store, s.Sectors)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (s *state1) decodeSectorOnChainInfo(val *cbg.Deferred) (SectorOnChainInfo, error) {
|
func (s *state2) decodeSectorOnChainInfo(val *cbg.Deferred) (SectorOnChainInfo, error) {
|
||||||
var si miner1.SectorOnChainInfo
|
var si miner2.SectorOnChainInfo
|
||||||
err := si.UnmarshalCBOR(bytes.NewReader(val.Raw))
|
err := si.UnmarshalCBOR(bytes.NewReader(val.Raw))
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return SectorOnChainInfo{}, err
|
return SectorOnChainInfo{}, err
|
||||||
}
|
}
|
||||||
|
|
||||||
return fromV1SectorOnChainInfo(si), nil
|
return fromV2SectorOnChainInfo(si), nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func (s *state1) precommits() (adt.Map, error) {
|
func (s *state2) precommits() (adt.Map, error) {
|
||||||
return adt1.AsMap(s.store, s.PreCommittedSectors)
|
return adt2.AsMap(s.store, s.PreCommittedSectors)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (s *state1) decodeSectorPreCommitOnChainInfo(val *cbg.Deferred) (SectorPreCommitOnChainInfo, error) {
|
func (s *state2) decodeSectorPreCommitOnChainInfo(val *cbg.Deferred) (SectorPreCommitOnChainInfo, error) {
|
||||||
var sp miner1.SectorPreCommitOnChainInfo
|
var sp miner2.SectorPreCommitOnChainInfo
|
||||||
err := sp.UnmarshalCBOR(bytes.NewReader(val.Raw))
|
err := sp.UnmarshalCBOR(bytes.NewReader(val.Raw))
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return SectorPreCommitOnChainInfo{}, err
|
return SectorPreCommitOnChainInfo{}, err
|
||||||
}
|
}
|
||||||
|
|
||||||
return fromV1SectorPreCommitOnChainInfo(sp), nil
|
return fromV2SectorPreCommitOnChainInfo(sp), nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func (d *deadline1) LoadPartition(idx uint64) (Partition, error) {
|
func (d *deadline2) LoadPartition(idx uint64) (Partition, error) {
|
||||||
p, err := d.Deadline.LoadPartition(d.store, idx)
|
p, err := d.Deadline.LoadPartition(d.store, idx)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
return &partition1{*p, d.store}, nil
|
return &partition2{*p, d.store}, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func (d *deadline1) ForEachPartition(cb func(uint64, Partition) error) error {
|
func (d *deadline2) ForEachPartition(cb func(uint64, Partition) error) error {
|
||||||
ps, err := d.Deadline.PartitionsArray(d.store)
|
ps, err := d.Deadline.PartitionsArray(d.store)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
var part miner1.Partition
|
var part miner2.Partition
|
||||||
return ps.ForEach(&part, func(i int64) error {
|
return ps.ForEach(&part, func(i int64) error {
|
||||||
return cb(uint64(i), &partition1{part, d.store})
|
return cb(uint64(i), &partition2{part, d.store})
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
func (d *deadline1) PartitionsChanged(other Deadline) (bool, error) {
|
func (d *deadline2) PartitionsChanged(other Deadline) (bool, error) {
|
||||||
other1, ok := other.(*deadline1)
|
other2, ok := other.(*deadline2)
|
||||||
if !ok {
|
if !ok {
|
||||||
// treat an upgrade as a change, always
|
// treat an upgrade as a change, always
|
||||||
return true, nil
|
return true, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
return d.Deadline.Partitions.Equals(other1.Deadline.Partitions), nil
|
return d.Deadline.Partitions.Equals(other2.Deadline.Partitions), nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func (d *deadline1) PostSubmissions() (bitfield.BitField, error) {
|
func (d *deadline2) PostSubmissions() (bitfield.BitField, error) {
|
||||||
return d.Deadline.PostSubmissions, nil
|
return d.Deadline.PostSubmissions, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func (p *partition1) AllSectors() (bitfield.BitField, error) {
|
func (p *partition2) AllSectors() (bitfield.BitField, error) {
|
||||||
return p.Partition.Sectors, nil
|
return p.Partition.Sectors, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func (p *partition1) FaultySectors() (bitfield.BitField, error) {
|
func (p *partition2) FaultySectors() (bitfield.BitField, error) {
|
||||||
return p.Partition.Faults, nil
|
return p.Partition.Faults, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func (p *partition1) RecoveringSectors() (bitfield.BitField, error) {
|
func (p *partition2) RecoveringSectors() (bitfield.BitField, error) {
|
||||||
return p.Partition.Recoveries, nil
|
return p.Partition.Recoveries, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func fromV1SectorOnChainInfo(v1 miner1.SectorOnChainInfo) SectorOnChainInfo {
|
func fromV2SectorOnChainInfo(v2 miner2.SectorOnChainInfo) SectorOnChainInfo {
|
||||||
return SectorOnChainInfo{
|
return SectorOnChainInfo{
|
||||||
SectorNumber: v1.SectorNumber,
|
SectorNumber: v2.SectorNumber,
|
||||||
SealProof: v1.SealProof,
|
SealProof: v2.SealProof,
|
||||||
SealedCID: v1.SealedCID,
|
SealedCID: v2.SealedCID,
|
||||||
DealIDs: v1.DealIDs,
|
DealIDs: v2.DealIDs,
|
||||||
Activation: v1.Activation,
|
Activation: v2.Activation,
|
||||||
Expiration: v1.Expiration,
|
Expiration: v2.Expiration,
|
||||||
DealWeight: v1.DealWeight,
|
DealWeight: v2.DealWeight,
|
||||||
VerifiedDealWeight: v1.VerifiedDealWeight,
|
VerifiedDealWeight: v2.VerifiedDealWeight,
|
||||||
InitialPledge: v1.InitialPledge,
|
InitialPledge: v2.InitialPledge,
|
||||||
ExpectedDayReward: v1.ExpectedDayReward,
|
ExpectedDayReward: v2.ExpectedDayReward,
|
||||||
ExpectedStoragePledge: v1.ExpectedStoragePledge,
|
ExpectedStoragePledge: v2.ExpectedStoragePledge,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func fromV1SectorPreCommitOnChainInfo(v1 miner1.SectorPreCommitOnChainInfo) SectorPreCommitOnChainInfo {
|
func fromV2SectorPreCommitOnChainInfo(v2 miner2.SectorPreCommitOnChainInfo) SectorPreCommitOnChainInfo {
|
||||||
return SectorPreCommitOnChainInfo{
|
return SectorPreCommitOnChainInfo{
|
||||||
Info: (SectorPreCommitInfo)(v1.Info),
|
Info: (SectorPreCommitInfo)(v2.Info),
|
||||||
PreCommitDeposit: v1.PreCommitDeposit,
|
PreCommitDeposit: v2.PreCommitDeposit,
|
||||||
PreCommitEpoch: v1.PreCommitEpoch,
|
PreCommitEpoch: v2.PreCommitEpoch,
|
||||||
DealWeight: v1.DealWeight,
|
DealWeight: v2.DealWeight,
|
||||||
VerifiedDealWeight: v1.VerifiedDealWeight,
|
VerifiedDealWeight: v2.VerifiedDealWeight,
|
||||||
}
|
}
|
||||||
}
|
}
|
@ -10,7 +10,7 @@ import (
|
|||||||
|
|
||||||
builtin0 "github.com/filecoin-project/specs-actors/actors/builtin"
|
builtin0 "github.com/filecoin-project/specs-actors/actors/builtin"
|
||||||
msig0 "github.com/filecoin-project/specs-actors/actors/builtin/multisig"
|
msig0 "github.com/filecoin-project/specs-actors/actors/builtin/multisig"
|
||||||
builtin1 "github.com/filecoin-project/specs-actors/v2/actors/builtin"
|
builtin2 "github.com/filecoin-project/specs-actors/v2/actors/builtin"
|
||||||
|
|
||||||
"github.com/filecoin-project/lotus/chain/actors/adt"
|
"github.com/filecoin-project/lotus/chain/actors/adt"
|
||||||
"github.com/filecoin-project/lotus/chain/actors/builtin"
|
"github.com/filecoin-project/lotus/chain/actors/builtin"
|
||||||
@ -21,8 +21,8 @@ func init() {
|
|||||||
builtin.RegisterActorState(builtin0.MultisigActorCodeID, func(store adt.Store, root cid.Cid) (cbor.Marshaler, error) {
|
builtin.RegisterActorState(builtin0.MultisigActorCodeID, func(store adt.Store, root cid.Cid) (cbor.Marshaler, error) {
|
||||||
return load0(store, root)
|
return load0(store, root)
|
||||||
})
|
})
|
||||||
builtin.RegisterActorState(builtin1.MultisigActorCodeID, func(store adt.Store, root cid.Cid) (cbor.Marshaler, error) {
|
builtin.RegisterActorState(builtin2.MultisigActorCodeID, func(store adt.Store, root cid.Cid) (cbor.Marshaler, error) {
|
||||||
return load1(store, root)
|
return load2(store, root)
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -30,8 +30,8 @@ func Load(store adt.Store, act *types.Actor) (State, error) {
|
|||||||
switch act.Code {
|
switch act.Code {
|
||||||
case builtin0.MultisigActorCodeID:
|
case builtin0.MultisigActorCodeID:
|
||||||
return load0(store, act.Head)
|
return load0(store, act.Head)
|
||||||
case builtin1.MultisigActorCodeID:
|
case builtin2.MultisigActorCodeID:
|
||||||
return load1(store, act.Head)
|
return load2(store, act.Head)
|
||||||
}
|
}
|
||||||
return nil, xerrors.Errorf("unknown actor code %s", act.Code)
|
return nil, xerrors.Errorf("unknown actor code %s", act.Code)
|
||||||
}
|
}
|
||||||
|
@ -10,14 +10,14 @@ import (
|
|||||||
|
|
||||||
"github.com/filecoin-project/lotus/chain/actors/adt"
|
"github.com/filecoin-project/lotus/chain/actors/adt"
|
||||||
|
|
||||||
msig1 "github.com/filecoin-project/specs-actors/v2/actors/builtin/multisig"
|
msig2 "github.com/filecoin-project/specs-actors/v2/actors/builtin/multisig"
|
||||||
adt1 "github.com/filecoin-project/specs-actors/v2/actors/util/adt"
|
adt2 "github.com/filecoin-project/specs-actors/v2/actors/util/adt"
|
||||||
)
|
)
|
||||||
|
|
||||||
var _ State = (*state1)(nil)
|
var _ State = (*state2)(nil)
|
||||||
|
|
||||||
func load1(store adt.Store, root cid.Cid) (State, error) {
|
func load2(store adt.Store, root cid.Cid) (State, error) {
|
||||||
out := state1{store: store}
|
out := state2{store: store}
|
||||||
err := store.Get(store.Context(), root, &out)
|
err := store.Get(store.Context(), root, &out)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
@ -25,41 +25,41 @@ func load1(store adt.Store, root cid.Cid) (State, error) {
|
|||||||
return &out, nil
|
return &out, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
type state1 struct {
|
type state2 struct {
|
||||||
msig1.State
|
msig2.State
|
||||||
store adt.Store
|
store adt.Store
|
||||||
}
|
}
|
||||||
|
|
||||||
func (s *state1) LockedBalance(currEpoch abi.ChainEpoch) (abi.TokenAmount, error) {
|
func (s *state2) LockedBalance(currEpoch abi.ChainEpoch) (abi.TokenAmount, error) {
|
||||||
return s.State.AmountLocked(currEpoch - s.State.StartEpoch), nil
|
return s.State.AmountLocked(currEpoch - s.State.StartEpoch), nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func (s *state1) StartEpoch() (abi.ChainEpoch, error) {
|
func (s *state2) StartEpoch() (abi.ChainEpoch, error) {
|
||||||
return s.State.StartEpoch, nil
|
return s.State.StartEpoch, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func (s *state1) UnlockDuration() (abi.ChainEpoch, error) {
|
func (s *state2) UnlockDuration() (abi.ChainEpoch, error) {
|
||||||
return s.State.UnlockDuration, nil
|
return s.State.UnlockDuration, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func (s *state1) InitialBalance() (abi.TokenAmount, error) {
|
func (s *state2) InitialBalance() (abi.TokenAmount, error) {
|
||||||
return s.State.InitialBalance, nil
|
return s.State.InitialBalance, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func (s *state1) Threshold() (uint64, error) {
|
func (s *state2) Threshold() (uint64, error) {
|
||||||
return s.State.NumApprovalsThreshold, nil
|
return s.State.NumApprovalsThreshold, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func (s *state1) Signers() ([]address.Address, error) {
|
func (s *state2) Signers() ([]address.Address, error) {
|
||||||
return s.State.Signers, nil
|
return s.State.Signers, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func (s *state1) ForEachPendingTxn(cb func(id int64, txn Transaction) error) error {
|
func (s *state2) ForEachPendingTxn(cb func(id int64, txn Transaction) error) error {
|
||||||
arr, err := adt1.AsMap(s.store, s.State.PendingTxns)
|
arr, err := adt2.AsMap(s.store, s.State.PendingTxns)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
var out msig1.Transaction
|
var out msig2.Transaction
|
||||||
return arr.ForEach(&out, func(key string) error {
|
return arr.ForEach(&out, func(key string) error {
|
||||||
txid, n := binary.Varint([]byte(key))
|
txid, n := binary.Varint([]byte(key))
|
||||||
if n <= 0 {
|
if n <= 0 {
|
@ -11,7 +11,7 @@ import (
|
|||||||
|
|
||||||
builtin0 "github.com/filecoin-project/specs-actors/actors/builtin"
|
builtin0 "github.com/filecoin-project/specs-actors/actors/builtin"
|
||||||
paych0 "github.com/filecoin-project/specs-actors/actors/builtin/paych"
|
paych0 "github.com/filecoin-project/specs-actors/actors/builtin/paych"
|
||||||
builtin1 "github.com/filecoin-project/specs-actors/v2/actors/builtin"
|
builtin2 "github.com/filecoin-project/specs-actors/v2/actors/builtin"
|
||||||
|
|
||||||
"github.com/filecoin-project/lotus/chain/actors/adt"
|
"github.com/filecoin-project/lotus/chain/actors/adt"
|
||||||
"github.com/filecoin-project/lotus/chain/actors/builtin"
|
"github.com/filecoin-project/lotus/chain/actors/builtin"
|
||||||
@ -22,8 +22,8 @@ func init() {
|
|||||||
builtin.RegisterActorState(builtin0.PaymentChannelActorCodeID, func(store adt.Store, root cid.Cid) (cbor.Marshaler, error) {
|
builtin.RegisterActorState(builtin0.PaymentChannelActorCodeID, func(store adt.Store, root cid.Cid) (cbor.Marshaler, error) {
|
||||||
return load0(store, root)
|
return load0(store, root)
|
||||||
})
|
})
|
||||||
builtin.RegisterActorState(builtin1.PaymentChannelActorCodeID, func(store adt.Store, root cid.Cid) (cbor.Marshaler, error) {
|
builtin.RegisterActorState(builtin2.PaymentChannelActorCodeID, func(store adt.Store, root cid.Cid) (cbor.Marshaler, error) {
|
||||||
return load1(store, root)
|
return load2(store, root)
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -32,8 +32,8 @@ func Load(store adt.Store, act *types.Actor) (State, error) {
|
|||||||
switch act.Code {
|
switch act.Code {
|
||||||
case builtin0.PaymentChannelActorCodeID:
|
case builtin0.PaymentChannelActorCodeID:
|
||||||
return load0(store, act.Head)
|
return load0(store, act.Head)
|
||||||
case builtin1.PaymentChannelActorCodeID:
|
case builtin2.PaymentChannelActorCodeID:
|
||||||
return load1(store, act.Head)
|
return load2(store, act.Head)
|
||||||
}
|
}
|
||||||
return nil, xerrors.Errorf("unknown actor code %s", act.Code)
|
return nil, xerrors.Errorf("unknown actor code %s", act.Code)
|
||||||
}
|
}
|
||||||
|
@ -9,14 +9,14 @@ import (
|
|||||||
|
|
||||||
"github.com/filecoin-project/lotus/chain/actors/adt"
|
"github.com/filecoin-project/lotus/chain/actors/adt"
|
||||||
|
|
||||||
paych1 "github.com/filecoin-project/specs-actors/v2/actors/builtin/paych"
|
paych2 "github.com/filecoin-project/specs-actors/v2/actors/builtin/paych"
|
||||||
adt1 "github.com/filecoin-project/specs-actors/v2/actors/util/adt"
|
adt2 "github.com/filecoin-project/specs-actors/v2/actors/util/adt"
|
||||||
)
|
)
|
||||||
|
|
||||||
var _ State = (*state1)(nil)
|
var _ State = (*state2)(nil)
|
||||||
|
|
||||||
func load1(store adt.Store, root cid.Cid) (State, error) {
|
func load2(store adt.Store, root cid.Cid) (State, error) {
|
||||||
out := state1{store: store}
|
out := state2{store: store}
|
||||||
err := store.Get(store.Context(), root, &out)
|
err := store.Get(store.Context(), root, &out)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
@ -24,39 +24,39 @@ func load1(store adt.Store, root cid.Cid) (State, error) {
|
|||||||
return &out, nil
|
return &out, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
type state1 struct {
|
type state2 struct {
|
||||||
paych1.State
|
paych2.State
|
||||||
store adt.Store
|
store adt.Store
|
||||||
lsAmt *adt1.Array
|
lsAmt *adt2.Array
|
||||||
}
|
}
|
||||||
|
|
||||||
// Channel owner, who has funded the actor
|
// Channel owner, who has funded the actor
|
||||||
func (s *state1) From() (address.Address, error) {
|
func (s *state2) From() (address.Address, error) {
|
||||||
return s.State.From, nil
|
return s.State.From, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
// Recipient of payouts from channel
|
// Recipient of payouts from channel
|
||||||
func (s *state1) To() (address.Address, error) {
|
func (s *state2) To() (address.Address, error) {
|
||||||
return s.State.To, nil
|
return s.State.To, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
// Height at which the channel can be `Collected`
|
// Height at which the channel can be `Collected`
|
||||||
func (s *state1) SettlingAt() (abi.ChainEpoch, error) {
|
func (s *state2) SettlingAt() (abi.ChainEpoch, error) {
|
||||||
return s.State.SettlingAt, nil
|
return s.State.SettlingAt, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
// Amount successfully redeemed through the payment channel, paid out on `Collect()`
|
// Amount successfully redeemed through the payment channel, paid out on `Collect()`
|
||||||
func (s *state1) ToSend() (abi.TokenAmount, error) {
|
func (s *state2) ToSend() (abi.TokenAmount, error) {
|
||||||
return s.State.ToSend, nil
|
return s.State.ToSend, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func (s *state1) getOrLoadLsAmt() (*adt1.Array, error) {
|
func (s *state2) getOrLoadLsAmt() (*adt2.Array, error) {
|
||||||
if s.lsAmt != nil {
|
if s.lsAmt != nil {
|
||||||
return s.lsAmt, nil
|
return s.lsAmt, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
// Get the lane state from the chain
|
// Get the lane state from the chain
|
||||||
lsamt, err := adt1.AsArray(s.store, s.State.LaneStates)
|
lsamt, err := adt2.AsArray(s.store, s.State.LaneStates)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
@ -66,7 +66,7 @@ func (s *state1) getOrLoadLsAmt() (*adt1.Array, error) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Get total number of lanes
|
// Get total number of lanes
|
||||||
func (s *state1) LaneCount() (uint64, error) {
|
func (s *state2) LaneCount() (uint64, error) {
|
||||||
lsamt, err := s.getOrLoadLsAmt()
|
lsamt, err := s.getOrLoadLsAmt()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return 0, err
|
return 0, err
|
||||||
@ -75,7 +75,7 @@ func (s *state1) LaneCount() (uint64, error) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Iterate lane states
|
// Iterate lane states
|
||||||
func (s *state1) ForEachLaneState(cb func(idx uint64, dl LaneState) error) error {
|
func (s *state2) ForEachLaneState(cb func(idx uint64, dl LaneState) error) error {
|
||||||
// Get the lane state from the chain
|
// Get the lane state from the chain
|
||||||
lsamt, err := s.getOrLoadLsAmt()
|
lsamt, err := s.getOrLoadLsAmt()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
@ -85,20 +85,20 @@ func (s *state1) ForEachLaneState(cb func(idx uint64, dl LaneState) error) error
|
|||||||
// Note: we use a map instead of an array to store laneStates because the
|
// Note: we use a map instead of an array to store laneStates because the
|
||||||
// client sets the lane ID (the index) and potentially they could use a
|
// client sets the lane ID (the index) and potentially they could use a
|
||||||
// very large index.
|
// very large index.
|
||||||
var ls paych1.LaneState
|
var ls paych2.LaneState
|
||||||
return lsamt.ForEach(&ls, func(i int64) error {
|
return lsamt.ForEach(&ls, func(i int64) error {
|
||||||
return cb(uint64(i), &laneState1{ls})
|
return cb(uint64(i), &laneState2{ls})
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
type laneState1 struct {
|
type laneState2 struct {
|
||||||
paych1.LaneState
|
paych2.LaneState
|
||||||
}
|
}
|
||||||
|
|
||||||
func (ls *laneState1) Redeemed() (big.Int, error) {
|
func (ls *laneState2) Redeemed() (big.Int, error) {
|
||||||
return ls.LaneState.Redeemed, nil
|
return ls.LaneState.Redeemed, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func (ls *laneState1) Nonce() (uint64, error) {
|
func (ls *laneState2) Nonce() (uint64, error) {
|
||||||
return ls.LaneState.Nonce, nil
|
return ls.LaneState.Nonce, nil
|
||||||
}
|
}
|
@ -13,15 +13,15 @@ import (
|
|||||||
"github.com/filecoin-project/lotus/chain/types"
|
"github.com/filecoin-project/lotus/chain/types"
|
||||||
|
|
||||||
builtin0 "github.com/filecoin-project/specs-actors/actors/builtin"
|
builtin0 "github.com/filecoin-project/specs-actors/actors/builtin"
|
||||||
builtin1 "github.com/filecoin-project/specs-actors/v2/actors/builtin"
|
builtin2 "github.com/filecoin-project/specs-actors/v2/actors/builtin"
|
||||||
)
|
)
|
||||||
|
|
||||||
func init() {
|
func init() {
|
||||||
builtin.RegisterActorState(builtin0.StoragePowerActorCodeID, func(store adt.Store, root cid.Cid) (cbor.Marshaler, error) {
|
builtin.RegisterActorState(builtin0.StoragePowerActorCodeID, func(store adt.Store, root cid.Cid) (cbor.Marshaler, error) {
|
||||||
return load0(store, root)
|
return load0(store, root)
|
||||||
})
|
})
|
||||||
builtin.RegisterActorState(builtin1.StoragePowerActorCodeID, func(store adt.Store, root cid.Cid) (cbor.Marshaler, error) {
|
builtin.RegisterActorState(builtin2.StoragePowerActorCodeID, func(store adt.Store, root cid.Cid) (cbor.Marshaler, error) {
|
||||||
return load1(store, root)
|
return load2(store, root)
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -31,8 +31,8 @@ func Load(store adt.Store, act *types.Actor) (st State, err error) {
|
|||||||
switch act.Code {
|
switch act.Code {
|
||||||
case builtin0.StoragePowerActorCodeID:
|
case builtin0.StoragePowerActorCodeID:
|
||||||
return load0(store, act.Head)
|
return load0(store, act.Head)
|
||||||
case builtin1.StoragePowerActorCodeID:
|
case builtin2.StoragePowerActorCodeID:
|
||||||
return load1(store, act.Head)
|
return load2(store, act.Head)
|
||||||
}
|
}
|
||||||
return nil, xerrors.Errorf("unknown actor code %s", act.Code)
|
return nil, xerrors.Errorf("unknown actor code %s", act.Code)
|
||||||
}
|
}
|
||||||
|
@ -8,14 +8,14 @@ import (
|
|||||||
"github.com/filecoin-project/lotus/chain/actors/adt"
|
"github.com/filecoin-project/lotus/chain/actors/adt"
|
||||||
"github.com/filecoin-project/lotus/chain/actors/builtin"
|
"github.com/filecoin-project/lotus/chain/actors/builtin"
|
||||||
|
|
||||||
power1 "github.com/filecoin-project/specs-actors/v2/actors/builtin/power"
|
power2 "github.com/filecoin-project/specs-actors/v2/actors/builtin/power"
|
||||||
adt1 "github.com/filecoin-project/specs-actors/v2/actors/util/adt"
|
adt2 "github.com/filecoin-project/specs-actors/v2/actors/util/adt"
|
||||||
)
|
)
|
||||||
|
|
||||||
var _ State = (*state1)(nil)
|
var _ State = (*state2)(nil)
|
||||||
|
|
||||||
func load1(store adt.Store, root cid.Cid) (State, error) {
|
func load2(store adt.Store, root cid.Cid) (State, error) {
|
||||||
out := state1{store: store}
|
out := state2{store: store}
|
||||||
err := store.Get(store.Context(), root, &out)
|
err := store.Get(store.Context(), root, &out)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
@ -23,16 +23,16 @@ func load1(store adt.Store, root cid.Cid) (State, error) {
|
|||||||
return &out, nil
|
return &out, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
type state1 struct {
|
type state2 struct {
|
||||||
power1.State
|
power2.State
|
||||||
store adt.Store
|
store adt.Store
|
||||||
}
|
}
|
||||||
|
|
||||||
func (s *state1) TotalLocked() (abi.TokenAmount, error) {
|
func (s *state2) TotalLocked() (abi.TokenAmount, error) {
|
||||||
return s.TotalPledgeCollateral, nil
|
return s.TotalPledgeCollateral, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func (s *state1) TotalPower() (Claim, error) {
|
func (s *state2) TotalPower() (Claim, error) {
|
||||||
return Claim{
|
return Claim{
|
||||||
RawBytePower: s.TotalRawBytePower,
|
RawBytePower: s.TotalRawBytePower,
|
||||||
QualityAdjPower: s.TotalQualityAdjPower,
|
QualityAdjPower: s.TotalQualityAdjPower,
|
||||||
@ -40,19 +40,19 @@ func (s *state1) TotalPower() (Claim, error) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Committed power to the network. Includes miners below the minimum threshold.
|
// Committed power to the network. Includes miners below the minimum threshold.
|
||||||
func (s *state1) TotalCommitted() (Claim, error) {
|
func (s *state2) TotalCommitted() (Claim, error) {
|
||||||
return Claim{
|
return Claim{
|
||||||
RawBytePower: s.TotalBytesCommitted,
|
RawBytePower: s.TotalBytesCommitted,
|
||||||
QualityAdjPower: s.TotalQABytesCommitted,
|
QualityAdjPower: s.TotalQABytesCommitted,
|
||||||
}, nil
|
}, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func (s *state1) MinerPower(addr address.Address) (Claim, bool, error) {
|
func (s *state2) MinerPower(addr address.Address) (Claim, bool, error) {
|
||||||
claims, err := adt1.AsMap(s.store, s.Claims)
|
claims, err := adt2.AsMap(s.store, s.Claims)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return Claim{}, false, err
|
return Claim{}, false, err
|
||||||
}
|
}
|
||||||
var claim power1.Claim
|
var claim power2.Claim
|
||||||
ok, err := claims.Get(abi.AddrKey(addr), &claim)
|
ok, err := claims.Get(abi.AddrKey(addr), &claim)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return Claim{}, false, err
|
return Claim{}, false, err
|
||||||
@ -63,20 +63,20 @@ func (s *state1) MinerPower(addr address.Address) (Claim, bool, error) {
|
|||||||
}, ok, nil
|
}, ok, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func (s *state1) MinerNominalPowerMeetsConsensusMinimum(a address.Address) (bool, error) {
|
func (s *state2) MinerNominalPowerMeetsConsensusMinimum(a address.Address) (bool, error) {
|
||||||
return s.State.MinerNominalPowerMeetsConsensusMinimum(s.store, a)
|
return s.State.MinerNominalPowerMeetsConsensusMinimum(s.store, a)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (s *state1) TotalPowerSmoothed() (builtin.FilterEstimate, error) {
|
func (s *state2) TotalPowerSmoothed() (builtin.FilterEstimate, error) {
|
||||||
return builtin.FromV1FilterEstimate(s.State.ThisEpochQAPowerSmoothed), nil
|
return builtin.FromV2FilterEstimate(s.State.ThisEpochQAPowerSmoothed), nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func (s *state1) MinerCounts() (uint64, uint64, error) {
|
func (s *state2) MinerCounts() (uint64, uint64, error) {
|
||||||
return uint64(s.State.MinerAboveMinPowerCount), uint64(s.State.MinerCount), nil
|
return uint64(s.State.MinerAboveMinPowerCount), uint64(s.State.MinerCount), nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func (s *state1) ListAllMiners() ([]address.Address, error) {
|
func (s *state2) ListAllMiners() ([]address.Address, error) {
|
||||||
claims, err := adt1.AsMap(s.store, s.Claims)
|
claims, err := adt2.AsMap(s.store, s.Claims)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
@ -8,7 +8,7 @@ import (
|
|||||||
|
|
||||||
"github.com/filecoin-project/go-state-types/cbor"
|
"github.com/filecoin-project/go-state-types/cbor"
|
||||||
builtin0 "github.com/filecoin-project/specs-actors/actors/builtin"
|
builtin0 "github.com/filecoin-project/specs-actors/actors/builtin"
|
||||||
builtin1 "github.com/filecoin-project/specs-actors/v2/actors/builtin"
|
builtin2 "github.com/filecoin-project/specs-actors/v2/actors/builtin"
|
||||||
|
|
||||||
"github.com/filecoin-project/lotus/chain/actors/adt"
|
"github.com/filecoin-project/lotus/chain/actors/adt"
|
||||||
"github.com/filecoin-project/lotus/chain/actors/builtin"
|
"github.com/filecoin-project/lotus/chain/actors/builtin"
|
||||||
@ -19,8 +19,8 @@ func init() {
|
|||||||
builtin.RegisterActorState(builtin0.RewardActorCodeID, func(store adt.Store, root cid.Cid) (cbor.Marshaler, error) {
|
builtin.RegisterActorState(builtin0.RewardActorCodeID, func(store adt.Store, root cid.Cid) (cbor.Marshaler, error) {
|
||||||
return load0(store, root)
|
return load0(store, root)
|
||||||
})
|
})
|
||||||
builtin.RegisterActorState(builtin1.RewardActorCodeID, func(store adt.Store, root cid.Cid) (cbor.Marshaler, error) {
|
builtin.RegisterActorState(builtin2.RewardActorCodeID, func(store adt.Store, root cid.Cid) (cbor.Marshaler, error) {
|
||||||
return load1(store, root)
|
return load2(store, root)
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -30,8 +30,8 @@ func Load(store adt.Store, act *types.Actor) (st State, err error) {
|
|||||||
switch act.Code {
|
switch act.Code {
|
||||||
case builtin0.RewardActorCodeID:
|
case builtin0.RewardActorCodeID:
|
||||||
return load0(store, act.Head)
|
return load0(store, act.Head)
|
||||||
case builtin1.RewardActorCodeID:
|
case builtin2.RewardActorCodeID:
|
||||||
return load1(store, act.Head)
|
return load2(store, act.Head)
|
||||||
}
|
}
|
||||||
return nil, xerrors.Errorf("unknown actor code %s", act.Code)
|
return nil, xerrors.Errorf("unknown actor code %s", act.Code)
|
||||||
}
|
}
|
||||||
|
@ -7,15 +7,15 @@ import (
|
|||||||
"github.com/filecoin-project/lotus/chain/actors/adt"
|
"github.com/filecoin-project/lotus/chain/actors/adt"
|
||||||
"github.com/filecoin-project/lotus/chain/actors/builtin"
|
"github.com/filecoin-project/lotus/chain/actors/builtin"
|
||||||
|
|
||||||
miner1 "github.com/filecoin-project/specs-actors/v2/actors/builtin/miner"
|
miner2 "github.com/filecoin-project/specs-actors/v2/actors/builtin/miner"
|
||||||
reward1 "github.com/filecoin-project/specs-actors/v2/actors/builtin/reward"
|
reward2 "github.com/filecoin-project/specs-actors/v2/actors/builtin/reward"
|
||||||
smoothing1 "github.com/filecoin-project/specs-actors/v2/actors/util/smoothing"
|
smoothing2 "github.com/filecoin-project/specs-actors/v2/actors/util/smoothing"
|
||||||
)
|
)
|
||||||
|
|
||||||
var _ State = (*state1)(nil)
|
var _ State = (*state2)(nil)
|
||||||
|
|
||||||
func load1(store adt.Store, root cid.Cid) (State, error) {
|
func load2(store adt.Store, root cid.Cid) (State, error) {
|
||||||
out := state1{store: store}
|
out := state2{store: store}
|
||||||
err := store.Get(store.Context(), root, &out)
|
err := store.Get(store.Context(), root, &out)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
@ -23,52 +23,52 @@ func load1(store adt.Store, root cid.Cid) (State, error) {
|
|||||||
return &out, nil
|
return &out, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
type state1 struct {
|
type state2 struct {
|
||||||
reward1.State
|
reward2.State
|
||||||
store adt.Store
|
store adt.Store
|
||||||
}
|
}
|
||||||
|
|
||||||
func (s *state1) ThisEpochReward() (abi.StoragePower, error) {
|
func (s *state2) ThisEpochReward() (abi.StoragePower, error) {
|
||||||
return s.State.ThisEpochReward, nil
|
return s.State.ThisEpochReward, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func (s *state1) ThisEpochRewardSmoothed() (builtin.FilterEstimate, error) {
|
func (s *state2) ThisEpochRewardSmoothed() (builtin.FilterEstimate, error) {
|
||||||
return builtin.FilterEstimate{
|
return builtin.FilterEstimate{
|
||||||
PositionEstimate: s.State.ThisEpochRewardSmoothed.PositionEstimate,
|
PositionEstimate: s.State.ThisEpochRewardSmoothed.PositionEstimate,
|
||||||
VelocityEstimate: s.State.ThisEpochRewardSmoothed.VelocityEstimate,
|
VelocityEstimate: s.State.ThisEpochRewardSmoothed.VelocityEstimate,
|
||||||
}, nil
|
}, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func (s *state1) ThisEpochBaselinePower() (abi.StoragePower, error) {
|
func (s *state2) ThisEpochBaselinePower() (abi.StoragePower, error) {
|
||||||
return s.State.ThisEpochBaselinePower, nil
|
return s.State.ThisEpochBaselinePower, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func (s *state1) TotalStoragePowerReward() (abi.TokenAmount, error) {
|
func (s *state2) TotalStoragePowerReward() (abi.TokenAmount, error) {
|
||||||
return s.State.TotalStoragePowerReward, nil
|
return s.State.TotalStoragePowerReward, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func (s *state1) EffectiveBaselinePower() (abi.StoragePower, error) {
|
func (s *state2) EffectiveBaselinePower() (abi.StoragePower, error) {
|
||||||
return s.State.EffectiveBaselinePower, nil
|
return s.State.EffectiveBaselinePower, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func (s *state1) EffectiveNetworkTime() (abi.ChainEpoch, error) {
|
func (s *state2) EffectiveNetworkTime() (abi.ChainEpoch, error) {
|
||||||
return s.State.EffectiveNetworkTime, nil
|
return s.State.EffectiveNetworkTime, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func (s *state1) CumsumBaseline() (abi.StoragePower, error) {
|
func (s *state2) CumsumBaseline() (abi.StoragePower, error) {
|
||||||
return s.State.CumsumBaseline, nil
|
return s.State.CumsumBaseline, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func (s *state1) CumsumRealized() (abi.StoragePower, error) {
|
func (s *state2) CumsumRealized() (abi.StoragePower, error) {
|
||||||
return s.State.CumsumBaseline, nil
|
return s.State.CumsumBaseline, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func (s *state1) InitialPledgeForPower(qaPower abi.StoragePower, networkTotalPledge abi.TokenAmount, networkQAPower *builtin.FilterEstimate, circSupply abi.TokenAmount) (abi.TokenAmount, error) {
|
func (s *state2) InitialPledgeForPower(qaPower abi.StoragePower, networkTotalPledge abi.TokenAmount, networkQAPower *builtin.FilterEstimate, circSupply abi.TokenAmount) (abi.TokenAmount, error) {
|
||||||
return miner1.InitialPledgeForPower(
|
return miner2.InitialPledgeForPower(
|
||||||
qaPower,
|
qaPower,
|
||||||
s.State.ThisEpochBaselinePower,
|
s.State.ThisEpochBaselinePower,
|
||||||
s.State.ThisEpochRewardSmoothed,
|
s.State.ThisEpochRewardSmoothed,
|
||||||
smoothing1.FilterEstimate{
|
smoothing2.FilterEstimate{
|
||||||
PositionEstimate: networkQAPower.PositionEstimate,
|
PositionEstimate: networkQAPower.PositionEstimate,
|
||||||
VelocityEstimate: networkQAPower.VelocityEstimate,
|
VelocityEstimate: networkQAPower.VelocityEstimate,
|
||||||
},
|
},
|
||||||
@ -76,9 +76,9 @@ func (s *state1) InitialPledgeForPower(qaPower abi.StoragePower, networkTotalPle
|
|||||||
), nil
|
), nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func (s *state1) PreCommitDepositForPower(networkQAPower builtin.FilterEstimate, sectorWeight abi.StoragePower) (abi.TokenAmount, error) {
|
func (s *state2) PreCommitDepositForPower(networkQAPower builtin.FilterEstimate, sectorWeight abi.StoragePower) (abi.TokenAmount, error) {
|
||||||
return miner1.PreCommitDepositForPower(s.State.ThisEpochRewardSmoothed,
|
return miner2.PreCommitDepositForPower(s.State.ThisEpochRewardSmoothed,
|
||||||
smoothing1.FilterEstimate{
|
smoothing2.FilterEstimate{
|
||||||
PositionEstimate: networkQAPower.PositionEstimate,
|
PositionEstimate: networkQAPower.PositionEstimate,
|
||||||
VelocityEstimate: networkQAPower.VelocityEstimate,
|
VelocityEstimate: networkQAPower.VelocityEstimate,
|
||||||
},
|
},
|
@ -1,44 +0,0 @@
|
|||||||
package verifreg
|
|
||||||
|
|
||||||
import (
|
|
||||||
"github.com/filecoin-project/go-address"
|
|
||||||
"github.com/filecoin-project/go-state-types/abi"
|
|
||||||
"github.com/ipfs/go-cid"
|
|
||||||
|
|
||||||
"github.com/filecoin-project/lotus/chain/actors"
|
|
||||||
"github.com/filecoin-project/lotus/chain/actors/adt"
|
|
||||||
|
|
||||||
verifreg1 "github.com/filecoin-project/specs-actors/v2/actors/builtin/verifreg"
|
|
||||||
)
|
|
||||||
|
|
||||||
var _ State = (*state1)(nil)
|
|
||||||
|
|
||||||
func load1(store adt.Store, root cid.Cid) (State, error) {
|
|
||||||
out := state1{store: store}
|
|
||||||
err := store.Get(store.Context(), root, &out)
|
|
||||||
if err != nil {
|
|
||||||
return nil, err
|
|
||||||
}
|
|
||||||
return &out, nil
|
|
||||||
}
|
|
||||||
|
|
||||||
type state1 struct {
|
|
||||||
verifreg1.State
|
|
||||||
store adt.Store
|
|
||||||
}
|
|
||||||
|
|
||||||
func (s *state1) VerifiedClientDataCap(addr address.Address) (bool, abi.StoragePower, error) {
|
|
||||||
return getDataCap(s.store, actors.Version1, s.State.VerifiedClients, addr)
|
|
||||||
}
|
|
||||||
|
|
||||||
func (s *state1) VerifierDataCap(addr address.Address) (bool, abi.StoragePower, error) {
|
|
||||||
return getDataCap(s.store, actors.Version1, s.State.Verifiers, addr)
|
|
||||||
}
|
|
||||||
|
|
||||||
func (s *state1) ForEachVerifier(cb func(addr address.Address, dcap abi.StoragePower) error) error {
|
|
||||||
return forEachCap(s.store, actors.Version1, s.State.Verifiers, cb)
|
|
||||||
}
|
|
||||||
|
|
||||||
func (s *state1) ForEachClient(cb func(addr address.Address, dcap abi.StoragePower) error) error {
|
|
||||||
return forEachCap(s.store, actors.Version1, s.State.VerifiedClients, cb)
|
|
||||||
}
|
|
44
chain/actors/builtin/verifreg/v2.go
Normal file
44
chain/actors/builtin/verifreg/v2.go
Normal file
@ -0,0 +1,44 @@
|
|||||||
|
package verifreg
|
||||||
|
|
||||||
|
import (
|
||||||
|
"github.com/filecoin-project/go-address"
|
||||||
|
"github.com/filecoin-project/go-state-types/abi"
|
||||||
|
"github.com/ipfs/go-cid"
|
||||||
|
|
||||||
|
"github.com/filecoin-project/lotus/chain/actors"
|
||||||
|
"github.com/filecoin-project/lotus/chain/actors/adt"
|
||||||
|
|
||||||
|
verifreg2 "github.com/filecoin-project/specs-actors/v2/actors/builtin/verifreg"
|
||||||
|
)
|
||||||
|
|
||||||
|
var _ State = (*state2)(nil)
|
||||||
|
|
||||||
|
func load2(store adt.Store, root cid.Cid) (State, error) {
|
||||||
|
out := state2{store: store}
|
||||||
|
err := store.Get(store.Context(), root, &out)
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
return &out, nil
|
||||||
|
}
|
||||||
|
|
||||||
|
type state2 struct {
|
||||||
|
verifreg2.State
|
||||||
|
store adt.Store
|
||||||
|
}
|
||||||
|
|
||||||
|
func (s *state2) VerifiedClientDataCap(addr address.Address) (bool, abi.StoragePower, error) {
|
||||||
|
return getDataCap(s.store, actors.Version2, s.State.VerifiedClients, addr)
|
||||||
|
}
|
||||||
|
|
||||||
|
func (s *state2) VerifierDataCap(addr address.Address) (bool, abi.StoragePower, error) {
|
||||||
|
return getDataCap(s.store, actors.Version2, s.State.Verifiers, addr)
|
||||||
|
}
|
||||||
|
|
||||||
|
func (s *state2) ForEachVerifier(cb func(addr address.Address, dcap abi.StoragePower) error) error {
|
||||||
|
return forEachCap(s.store, actors.Version2, s.State.Verifiers, cb)
|
||||||
|
}
|
||||||
|
|
||||||
|
func (s *state2) ForEachClient(cb func(addr address.Address, dcap abi.StoragePower) error) error {
|
||||||
|
return forEachCap(s.store, actors.Version2, s.State.VerifiedClients, cb)
|
||||||
|
}
|
@ -8,7 +8,7 @@ import (
|
|||||||
|
|
||||||
"github.com/filecoin-project/go-state-types/cbor"
|
"github.com/filecoin-project/go-state-types/cbor"
|
||||||
builtin0 "github.com/filecoin-project/specs-actors/actors/builtin"
|
builtin0 "github.com/filecoin-project/specs-actors/actors/builtin"
|
||||||
builtin1 "github.com/filecoin-project/specs-actors/v2/actors/builtin"
|
builtin2 "github.com/filecoin-project/specs-actors/v2/actors/builtin"
|
||||||
|
|
||||||
"github.com/filecoin-project/lotus/chain/actors/adt"
|
"github.com/filecoin-project/lotus/chain/actors/adt"
|
||||||
"github.com/filecoin-project/lotus/chain/actors/builtin"
|
"github.com/filecoin-project/lotus/chain/actors/builtin"
|
||||||
@ -19,8 +19,8 @@ func init() {
|
|||||||
builtin.RegisterActorState(builtin0.VerifiedRegistryActorCodeID, func(store adt.Store, root cid.Cid) (cbor.Marshaler, error) {
|
builtin.RegisterActorState(builtin0.VerifiedRegistryActorCodeID, func(store adt.Store, root cid.Cid) (cbor.Marshaler, error) {
|
||||||
return load0(store, root)
|
return load0(store, root)
|
||||||
})
|
})
|
||||||
builtin.RegisterActorState(builtin1.VerifiedRegistryActorCodeID, func(store adt.Store, root cid.Cid) (cbor.Marshaler, error) {
|
builtin.RegisterActorState(builtin2.VerifiedRegistryActorCodeID, func(store adt.Store, root cid.Cid) (cbor.Marshaler, error) {
|
||||||
return load1(store, root)
|
return load2(store, root)
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -30,8 +30,8 @@ func Load(store adt.Store, act *types.Actor) (State, error) {
|
|||||||
switch act.Code {
|
switch act.Code {
|
||||||
case builtin0.VerifiedRegistryActorCodeID:
|
case builtin0.VerifiedRegistryActorCodeID:
|
||||||
return load0(store, act.Head)
|
return load0(store, act.Head)
|
||||||
case builtin1.VerifiedRegistryActorCodeID:
|
case builtin2.VerifiedRegistryActorCodeID:
|
||||||
return load1(store, act.Head)
|
return load2(store, act.Head)
|
||||||
}
|
}
|
||||||
return nil, xerrors.Errorf("unknown actor code %s", act.Code)
|
return nil, xerrors.Errorf("unknown actor code %s", act.Code)
|
||||||
}
|
}
|
||||||
|
@ -9,8 +9,8 @@ import (
|
|||||||
type Version int
|
type Version int
|
||||||
|
|
||||||
const (
|
const (
|
||||||
Version0 = iota
|
Version0 = 0
|
||||||
Version1
|
Version2 = 2
|
||||||
)
|
)
|
||||||
|
|
||||||
// Converts a network version into an actors adt version.
|
// Converts a network version into an actors adt version.
|
||||||
|
@ -125,7 +125,7 @@ func NewStateTree(cst cbor.IpldStore, version actors.Version) (*StateTree, error
|
|||||||
switch version {
|
switch version {
|
||||||
case actors.Version0:
|
case actors.Version0:
|
||||||
// info is undefined
|
// info is undefined
|
||||||
case actors.Version1:
|
case actors.Version2:
|
||||||
var err error
|
var err error
|
||||||
info, err = cst.Put(context.TODO(), new(types.StateInfo))
|
info, err = cst.Put(context.TODO(), new(types.StateInfo))
|
||||||
if err != nil {
|
if err != nil {
|
||||||
@ -165,7 +165,7 @@ func LoadStateTree(cst cbor.IpldStore, c cid.Cid) (*StateTree, error) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
switch root.Version {
|
switch root.Version {
|
||||||
case actors.Version0, actors.Version1:
|
case actors.Version0, actors.Version2:
|
||||||
// supported
|
// supported
|
||||||
default:
|
default:
|
||||||
return nil, xerrors.Errorf("unsupported state tree version: %d", root.Version)
|
return nil, xerrors.Errorf("unsupported state tree version: %d", root.Version)
|
||||||
|
@ -21,7 +21,7 @@ import (
|
|||||||
|
|
||||||
builtin0 "github.com/filecoin-project/specs-actors/actors/builtin"
|
builtin0 "github.com/filecoin-project/specs-actors/actors/builtin"
|
||||||
exported0 "github.com/filecoin-project/specs-actors/actors/builtin/exported"
|
exported0 "github.com/filecoin-project/specs-actors/actors/builtin/exported"
|
||||||
exported1 "github.com/filecoin-project/specs-actors/actors/builtin/exported"
|
exported2 "github.com/filecoin-project/specs-actors/actors/builtin/exported"
|
||||||
proof0 "github.com/filecoin-project/specs-actors/actors/runtime/proof"
|
proof0 "github.com/filecoin-project/specs-actors/actors/runtime/proof"
|
||||||
|
|
||||||
"github.com/filecoin-project/lotus/api"
|
"github.com/filecoin-project/lotus/api"
|
||||||
@ -530,14 +530,14 @@ func init() {
|
|||||||
// TODO: combine with the runtime actor registry.
|
// TODO: combine with the runtime actor registry.
|
||||||
var actors []rt.VMActor
|
var actors []rt.VMActor
|
||||||
actors = append(actors, exported0.BuiltinActors()...)
|
actors = append(actors, exported0.BuiltinActors()...)
|
||||||
actors = append(actors, exported1.BuiltinActors()...)
|
actors = append(actors, exported2.BuiltinActors()...)
|
||||||
|
|
||||||
for _, actor := range actors {
|
for _, actor := range actors {
|
||||||
exports := actor.Exports()
|
exports := actor.Exports()
|
||||||
methods := make(map[abi.MethodNum]MethodMeta, len(exports))
|
methods := make(map[abi.MethodNum]MethodMeta, len(exports))
|
||||||
|
|
||||||
// Explicitly add send, it's special.
|
// Explicitly add send, it's special.
|
||||||
// Note that builtin1.MethodSend = builtin0.MethodSend = 0.
|
// Note that builtin2.MethodSend = builtin0.MethodSend = 0.
|
||||||
methods[builtin0.MethodSend] = MethodMeta{
|
methods[builtin0.MethodSend] = MethodMeta{
|
||||||
Name: "Send",
|
Name: "Send",
|
||||||
Params: reflect.TypeOf(new(abi.EmptyValue)),
|
Params: reflect.TypeOf(new(abi.EmptyValue)),
|
||||||
@ -563,10 +563,10 @@ func init() {
|
|||||||
|
|
||||||
switch abi.MethodNum(number) {
|
switch abi.MethodNum(number) {
|
||||||
case builtin0.MethodSend:
|
case builtin0.MethodSend:
|
||||||
// Note that builtin1.MethodSend = builtin0.MethodSend = 0.
|
// Note that builtin2.MethodSend = builtin0.MethodSend = 0.
|
||||||
panic("method 0 is reserved for Send")
|
panic("method 0 is reserved for Send")
|
||||||
case builtin0.MethodConstructor:
|
case builtin0.MethodConstructor:
|
||||||
// Note that builtin1.MethodConstructor = builtin0.MethodConstructor = 1.
|
// Note that builtin2.MethodConstructor = builtin0.MethodConstructor = 1.
|
||||||
if fnName != "Constructor" {
|
if fnName != "Constructor" {
|
||||||
panic("method 1 is reserved for Constructor")
|
panic("method 1 is reserved for Constructor")
|
||||||
}
|
}
|
||||||
|
@ -11,7 +11,7 @@ import (
|
|||||||
"golang.org/x/xerrors"
|
"golang.org/x/xerrors"
|
||||||
|
|
||||||
exported0 "github.com/filecoin-project/specs-actors/actors/builtin/exported"
|
exported0 "github.com/filecoin-project/specs-actors/actors/builtin/exported"
|
||||||
exported1 "github.com/filecoin-project/specs-actors/v2/actors/builtin/exported"
|
exported2 "github.com/filecoin-project/specs-actors/v2/actors/builtin/exported"
|
||||||
vmr "github.com/filecoin-project/specs-actors/v2/actors/runtime"
|
vmr "github.com/filecoin-project/specs-actors/v2/actors/runtime"
|
||||||
|
|
||||||
"github.com/filecoin-project/go-state-types/abi"
|
"github.com/filecoin-project/go-state-types/abi"
|
||||||
@ -57,7 +57,7 @@ func NewActorRegistry() *ActorRegistry {
|
|||||||
|
|
||||||
// add builtInCode using: register(cid, singleton)
|
// add builtInCode using: register(cid, singleton)
|
||||||
inv.Register(ActorsVersionPredicate(actors.Version0), exported0.BuiltinActors()...)
|
inv.Register(ActorsVersionPredicate(actors.Version0), exported0.BuiltinActors()...)
|
||||||
inv.Register(ActorsVersionPredicate(actors.Version1), exported1.BuiltinActors()...)
|
inv.Register(ActorsVersionPredicate(actors.Version2), exported2.BuiltinActors()...)
|
||||||
|
|
||||||
return inv
|
return inv
|
||||||
}
|
}
|
||||||
|
@ -11,7 +11,7 @@ import (
|
|||||||
cbor "github.com/ipfs/go-ipld-cbor"
|
cbor "github.com/ipfs/go-ipld-cbor"
|
||||||
|
|
||||||
builtin0 "github.com/filecoin-project/specs-actors/actors/builtin"
|
builtin0 "github.com/filecoin-project/specs-actors/actors/builtin"
|
||||||
builtin1 "github.com/filecoin-project/specs-actors/v2/actors/builtin"
|
builtin2 "github.com/filecoin-project/specs-actors/v2/actors/builtin"
|
||||||
|
|
||||||
"github.com/filecoin-project/go-address"
|
"github.com/filecoin-project/go-address"
|
||||||
"github.com/filecoin-project/lotus/chain/actors/aerrors"
|
"github.com/filecoin-project/lotus/chain/actors/aerrors"
|
||||||
@ -87,8 +87,8 @@ func newAccountActor(ver actors.Version) *types.Actor {
|
|||||||
switch ver {
|
switch ver {
|
||||||
case actors.Version0:
|
case actors.Version0:
|
||||||
code = builtin0.AccountActorCodeID
|
code = builtin0.AccountActorCodeID
|
||||||
case actors.Version1:
|
case actors.Version2:
|
||||||
code = builtin1.AccountActorCodeID
|
code = builtin2.AccountActorCodeID
|
||||||
default:
|
default:
|
||||||
panic("unsupported actors version")
|
panic("unsupported actors version")
|
||||||
}
|
}
|
||||||
|
@ -11,7 +11,7 @@ import (
|
|||||||
"github.com/filecoin-project/go-state-types/abi"
|
"github.com/filecoin-project/go-state-types/abi"
|
||||||
"github.com/ipfs/go-cid"
|
"github.com/ipfs/go-cid"
|
||||||
|
|
||||||
builtin1 "github.com/filecoin-project/specs-actors/v2/actors/builtin"
|
builtin2 "github.com/filecoin-project/specs-actors/v2/actors/builtin"
|
||||||
|
|
||||||
"github.com/filecoin-project/lotus/chain/actors/builtin"
|
"github.com/filecoin-project/lotus/chain/actors/builtin"
|
||||||
_init "github.com/filecoin-project/lotus/chain/actors/builtin/init"
|
_init "github.com/filecoin-project/lotus/chain/actors/builtin/init"
|
||||||
@ -138,15 +138,15 @@ func (p Processor) storeActorAddresses(ctx context.Context, actors map[cid.Cid]A
|
|||||||
|
|
||||||
addressToID := map[address.Address]address.Address{}
|
addressToID := map[address.Address]address.Address{}
|
||||||
// HACK until genesis storage is figured out:
|
// HACK until genesis storage is figured out:
|
||||||
addressToID[builtin1.SystemActorAddr] = builtin1.SystemActorAddr
|
addressToID[builtin2.SystemActorAddr] = builtin2.SystemActorAddr
|
||||||
addressToID[builtin1.InitActorAddr] = builtin1.InitActorAddr
|
addressToID[builtin2.InitActorAddr] = builtin2.InitActorAddr
|
||||||
addressToID[builtin1.RewardActorAddr] = builtin1.RewardActorAddr
|
addressToID[builtin2.RewardActorAddr] = builtin2.RewardActorAddr
|
||||||
addressToID[builtin1.CronActorAddr] = builtin1.CronActorAddr
|
addressToID[builtin2.CronActorAddr] = builtin2.CronActorAddr
|
||||||
addressToID[builtin1.StoragePowerActorAddr] = builtin1.StoragePowerActorAddr
|
addressToID[builtin2.StoragePowerActorAddr] = builtin2.StoragePowerActorAddr
|
||||||
addressToID[builtin1.StorageMarketActorAddr] = builtin1.StorageMarketActorAddr
|
addressToID[builtin2.StorageMarketActorAddr] = builtin2.StorageMarketActorAddr
|
||||||
addressToID[builtin1.VerifiedRegistryActorAddr] = builtin1.VerifiedRegistryActorAddr
|
addressToID[builtin2.VerifiedRegistryActorAddr] = builtin2.VerifiedRegistryActorAddr
|
||||||
addressToID[builtin1.BurntFundsActorAddr] = builtin1.BurntFundsActorAddr
|
addressToID[builtin2.BurntFundsActorAddr] = builtin2.BurntFundsActorAddr
|
||||||
initActor, err := p.node.StateGetActor(ctx, builtin1.InitActorAddr, types.EmptyTSK)
|
initActor, err := p.node.StateGetActor(ctx, builtin2.InitActorAddr, types.EmptyTSK)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
@ -14,7 +14,7 @@ func TestDisabledEvents(t *testing.T) {
|
|||||||
registry := NewEventTypeRegistry(dis)
|
registry := NewEventTypeRegistry(dis)
|
||||||
|
|
||||||
reg1 := registry.RegisterEventType("system1", "disabled1")
|
reg1 := registry.RegisterEventType("system1", "disabled1")
|
||||||
reg2 := registry.RegisterEventType("system2", "disabled2")
|
reg2 := registry.RegisterEventType("system1", "disabled2")
|
||||||
|
|
||||||
req.False(reg1.Enabled())
|
req.False(reg1.Enabled())
|
||||||
req.False(reg2.Enabled())
|
req.False(reg2.Enabled())
|
||||||
@ -29,21 +29,21 @@ func TestDisabledEvents(t *testing.T) {
|
|||||||
|
|
||||||
t.Run("direct", test(DisabledEvents{
|
t.Run("direct", test(DisabledEvents{
|
||||||
EventType{System: "system1", Event: "disabled1"},
|
EventType{System: "system1", Event: "disabled1"},
|
||||||
EventType{System: "system2", Event: "disabled2"},
|
EventType{System: "system1", Event: "disabled2"},
|
||||||
}))
|
}))
|
||||||
|
|
||||||
dis, err := ParseDisabledEvents("system1:disabled1,system2:disabled2")
|
dis, err := ParseDisabledEvents("system1:disabled1,system1:disabled2")
|
||||||
req.NoError(err)
|
req.NoError(err)
|
||||||
|
|
||||||
t.Run("parsed", test(dis))
|
t.Run("parsed", test(dis))
|
||||||
|
|
||||||
dis, err = ParseDisabledEvents(" system1:disabled1 , system2:disabled2 ")
|
dis, err = ParseDisabledEvents(" system1:disabled1 , system1:disabled2 ")
|
||||||
req.NoError(err)
|
req.NoError(err)
|
||||||
|
|
||||||
t.Run("parsed_spaces", test(dis))
|
t.Run("parsed_spaces", test(dis))
|
||||||
}
|
}
|
||||||
|
|
||||||
func TestParseDisableEvents(t *testing.T) {
|
func TestParseDisableEvents(t *testing.T) {
|
||||||
_, err := ParseDisabledEvents("system1:disabled1:failed,system2:disabled2")
|
_, err := ParseDisabledEvents("system1:disabled1:failed,system1:disabled2")
|
||||||
require.Error(t, err)
|
require.Error(t, err)
|
||||||
}
|
}
|
||||||
|
@ -22,7 +22,7 @@ var (
|
|||||||
// DisabledEvents is the set of event types whose journaling is suppressed.
|
// DisabledEvents is the set of event types whose journaling is suppressed.
|
||||||
type DisabledEvents []EventType
|
type DisabledEvents []EventType
|
||||||
|
|
||||||
// ParseDisabledEvents parses a string of the form: "system1:event1,system2:event2[,...]"
|
// ParseDisabledEvents parses a string of the form: "system1:event1,system1:event2[,...]"
|
||||||
// into a DisabledEvents object, returning an error if the string failed to parse.
|
// into a DisabledEvents object, returning an error if the string failed to parse.
|
||||||
//
|
//
|
||||||
// It sanitizes strings via strings.TrimSpace.
|
// It sanitizes strings via strings.TrimSpace.
|
||||||
|
Loading…
Reference in New Issue
Block a user