lotus/chain/actors/builtin/multisig/state.go

64 lines
2.0 KiB
Go
Raw Normal View History

2020-09-15 21:44:03 +00:00
package multisig
import (
cbg "github.com/whyrusleeping/cbor-gen"
2020-09-15 21:44:03 +00:00
"golang.org/x/xerrors"
"github.com/filecoin-project/go-address"
2020-09-15 21:44:03 +00:00
"github.com/filecoin-project/go-state-types/abi"
"github.com/filecoin-project/go-state-types/cbor"
"github.com/ipfs/go-cid"
builtin0 "github.com/filecoin-project/specs-actors/actors/builtin"
msig0 "github.com/filecoin-project/specs-actors/actors/builtin/multisig"
builtin2 "github.com/filecoin-project/specs-actors/v2/actors/builtin"
2021-01-16 07:00:14 +00:00
builtin3 "github.com/filecoin-project/specs-actors/v3/actors/builtin"
2020-09-15 21:44:03 +00:00
"github.com/filecoin-project/lotus/chain/actors/adt"
"github.com/filecoin-project/lotus/chain/actors/builtin"
2020-09-15 21:44:03 +00:00
"github.com/filecoin-project/lotus/chain/types"
)
func init() {
builtin.RegisterActorState(builtin0.MultisigActorCodeID, func(store adt.Store, root cid.Cid) (cbor.Marshaler, error) {
return load0(store, root)
})
builtin.RegisterActorState(builtin2.MultisigActorCodeID, func(store adt.Store, root cid.Cid) (cbor.Marshaler, error) {
return load2(store, root)
})
2021-01-16 07:00:14 +00:00
builtin.RegisterActorState(builtin3.MultisigActorCodeID, func(store adt.Store, root cid.Cid) (cbor.Marshaler, error) {
return load3(store, root)
})
}
2020-09-15 21:44:03 +00:00
func Load(store adt.Store, act *types.Actor) (State, error) {
switch act.Code {
case builtin0.MultisigActorCodeID:
return load0(store, act.Head)
case builtin2.MultisigActorCodeID:
return load2(store, act.Head)
2021-01-18 23:04:32 +00:00
case builtin3.MultisigActorCodeID:
return load3(store, act.Head)
2020-09-15 21:44:03 +00:00
}
return nil, xerrors.Errorf("unknown actor code %s", act.Code)
}
type State interface {
cbor.Marshaler
LockedBalance(epoch abi.ChainEpoch) (abi.TokenAmount, error)
StartEpoch() (abi.ChainEpoch, error)
UnlockDuration() (abi.ChainEpoch, error)
InitialBalance() (abi.TokenAmount, error)
Threshold() (uint64, error)
Signers() ([]address.Address, error)
ForEachPendingTxn(func(id int64, txn Transaction) error) error
PendingTxnChanged(State) (bool, error)
transactions() (adt.Map, error)
decodeTransaction(val *cbg.Deferred) (Transaction, error)
2020-09-15 21:44:03 +00:00
}
type Transaction = msig0.Transaction