@@ -38,9 +38,9 @@ func (ch Change) String() string {
3838 return string (b )
3939}
4040
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 ... )
4444 if err != nil {
4545 return nil , xerrors .Errorf ("loading previous root: %w" , err )
4646 }
@@ -51,11 +51,16 @@ func Diff(ctx context.Context, prevBs, curBs cbor.IpldStore, prev, cur cid.Cid)
5151 height : prevAmt .height ,
5252 }
5353
54- curAmt , err := LoadAMT (ctx , curBs , cur )
54+ curAmt , err := LoadAMT (ctx , curBs , cur , opts ... )
5555 if err != nil {
5656 return nil , xerrors .Errorf ("loading current root: %w" , err )
5757 }
5858
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+
5964 curCtx := & nodeContext {
6065 bs : curBs ,
6166 bitWidth : curAmt .bitWidth ,
0 commit comments