@@ -38,9 +38,9 @@ func (ch Change) String() string {
38
38
return string (b )
39
39
}
40
40
41
- // Diff returns a set of changes that transform node 'a' into node 'b'.
42
- func Diff (ctx context.Context , prevBs , curBs cbor.IpldStore , prev , cur cid.Cid ) ([]* Change , error ) {
43
- prevAmt , err := LoadAMT (ctx , prevBs , prev )
41
+ // Diff returns a set of changes that transform node 'a' into node 'b'. opts are applied to both prev and cur.
42
+ func Diff (ctx context.Context , prevBs , curBs cbor.IpldStore , prev , cur cid.Cid , opts ... Option ) ([]* Change , error ) {
43
+ prevAmt , err := LoadAMT (ctx , prevBs , prev , opts ... )
44
44
if err != nil {
45
45
return nil , xerrors .Errorf ("loading previous root: %w" , err )
46
46
}
@@ -51,11 +51,16 @@ func Diff(ctx context.Context, prevBs, curBs cbor.IpldStore, prev, cur cid.Cid)
51
51
height : prevAmt .height ,
52
52
}
53
53
54
- curAmt , err := LoadAMT (ctx , curBs , cur )
54
+ curAmt , err := LoadAMT (ctx , curBs , cur , opts ... )
55
55
if err != nil {
56
56
return nil , xerrors .Errorf ("loading current root: %w" , err )
57
57
}
58
58
59
+ // TODO: remove when https://github.com/filecoin-project/go-amt-ipld/issues/54 is closed.
60
+ if curAmt .bitWidth != prevAmt .bitWidth {
61
+ return nil , xerrors .Errorf ("diffing AMTs with differing bitWidths not supported (prev=%d, cur=%d)" , prevAmt .bitWidth , curAmt .bitWidth )
62
+ }
63
+
59
64
curCtx := & nodeContext {
60
65
bs : curBs ,
61
66
bitWidth : curAmt .bitWidth ,
0 commit comments