forked from filecoin-project/lotus
/
retrieval.go
61 lines (53 loc) · 2.04 KB
/
retrieval.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
package retrieval
import (
"github.com/EpiK-Protocol/go-epik/chain/actors/adt"
"github.com/EpiK-Protocol/go-epik/chain/actors/builtin"
"github.com/EpiK-Protocol/go-epik/chain/types"
"github.com/filecoin-project/go-address"
"github.com/filecoin-project/go-state-types/abi"
"github.com/filecoin-project/go-state-types/cbor"
builtin2 "github.com/filecoin-project/specs-actors/v2/actors/builtin"
retrieval2 "github.com/filecoin-project/specs-actors/v2/actors/builtin/retrieval"
"github.com/ipfs/go-cid"
"golang.org/x/xerrors"
)
func init() {
builtin.RegisterActorState(builtin2.RetrievalFundActorCodeID, func(store adt.Store, root cid.Cid) (cbor.Marshaler, error) {
return load2(store, root)
})
}
var (
Address = builtin2.RetrievalFundActorAddr
Methods = builtin2.MethodsRetrieval
)
type PledgeState = retrieval2.PledgeState
type PledgeParams = retrieval2.PledgeParams
type RetrievalDataParams = retrieval2.RetrievalDataParams
type WithdrawBalanceParams = retrieval2.WithdrawBalanceParams
type LockedState = retrieval2.LockedState
type BindMinersParams = retrieval2.BindMinersParams
type RetrievalState struct {
BindMiners []address.Address
Amount abi.TokenAmount
EpochDate uint64
DateSize abi.PaddedPieceSize // date retrieval size
}
func Load(store adt.Store, act *types.Actor) (st State, err error) {
switch act.Code {
case builtin2.RetrievalFundActorCodeID:
return load2(store, act.Head)
}
return nil, xerrors.Errorf("unknown actor code %s", act.Code)
}
type State interface {
cbor.Marshaler
PledgesInfo(addr address.Address) (map[address.Address]abi.TokenAmount, error)
StateInfo(fromAddr address.Address) (*RetrievalState, error)
DayExpend(epoch abi.ChainEpoch, fromAddr address.Address) (abi.TokenAmount, error)
LockedPeriod() (abi.ChainEpoch, error)
LockedState(fromAddr address.Address, out *LockedState) (bool, error)
TotalCollateral() (abi.TokenAmount, error)
TotalRetrievalReward() (abi.TokenAmount, error)
PendingReward() (abi.TokenAmount, error)
ForEachState(func(addr address.Address, state *RetrievalState) error) error
}