This repository has been archived by the owner on Jun 6, 2023. It is now read-only.
/
verifreg.go
57 lines (44 loc) · 1.53 KB
/
verifreg.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
package nv15
import (
"context"
builtin7 "github.com/filecoin-project/specs-actors/v7/actors/builtin"
"github.com/filecoin-project/specs-actors/v7/actors/util/adt"
"golang.org/x/xerrors"
verifreg6 "github.com/filecoin-project/specs-actors/v6/actors/builtin/verifreg"
verifreg7 "github.com/filecoin-project/specs-actors/v7/actors/builtin/verifreg"
cid "github.com/ipfs/go-cid"
cbor "github.com/ipfs/go-ipld-cbor"
)
type verifregMigrator struct{}
func (m verifregMigrator) migrateState(ctx context.Context, store cbor.IpldStore, in actorMigrationInput) (*actorMigrationResult, error) {
var inState verifreg6.State
if err := store.Get(ctx, in.head, &inState); err != nil {
return nil, err
}
proposalId, err := migrateProposalIds(ctx, store)
if err != nil {
return nil, err
}
outState := verifreg7.State{
RootKey: inState.RootKey,
Verifiers: inState.Verifiers,
VerifiedClients: inState.VerifiedClients,
RemoveDataCapProposalIDs: proposalId,
}
newHead, err := store.Put(ctx, &outState)
return &actorMigrationResult{
newCodeCID: m.migratedCodeCID(),
newHead: newHead,
}, err
}
func (m verifregMigrator) migratedCodeCID() cid.Cid {
return builtin7.VerifiedRegistryActorCodeID
}
func migrateProposalIds(ctx context.Context, store cbor.IpldStore) (cid.Cid, error) {
ctxStore := adt.WrapStore(ctx, store)
outArray, err := adt.MakeEmptyMap(ctxStore, builtin7.DefaultHamtBitwidth)
if err != nil {
return cid.Undef, xerrors.Errorf("failed to construct new remove datacap proposal id map %w", err)
}
return outArray.Root()
}