Documentation ¶
Index ¶
- func Amt(ctx context.Context, preArr, curArr adt2.Array, preStore, curStore adt.Store, ...) ([]*amt.Change, error)
- func CompareArray(preArr, curArr adt.Array, out ArrayDiffer) error
- func CompareMap(preMap, curMap adt.Map, out MapDiffer) error
- func Hamt(ctx context.Context, preMap, curMap adt2.Map, preStore, curStore adt.Store, ...) ([]*hamt.Change, error)
- type ArrayDiffer
- type MapDiffer
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func Amt ¶
func Amt(ctx context.Context, preArr, curArr adt2.Array, preStore, curStore adt.Store, amtOpts ...amt.Option) ([]*amt.Change, error)
Amt returns a set of changes that transform `preArr` into `curArr`. opts are applied to both `preArr` and `curArr`.
func CompareArray ¶
func CompareArray(preArr, curArr adt.Array, out ArrayDiffer) error
CompareArray accepts two *adt.Array's and an ArrayDiffer implementation. It does the following: - All values that exist in preArr and not in curArr are passed to ArrayDiffer.Remove() - All values that exist in curArr nnd not in prevArr are passed to ArrayDiffer.Add() - All values that exist in preArr and in curArr are passed to ArrayDiffer.Modify()
- It is the responsibility of ArrayDiffer.Modify() to determine if the values it was passed have been modified.
If `preArr` and `curArr` are both backed by /v3/AMTs with the same bitwidth use the more efficient Amt method.
func CompareMap ¶
CompareMap accepts two *adt.Map's and an MapDiffer implementation. It does the following: - All values that exist in preMap and not in curMap are passed to MapDiffer.Remove() - All values that exist in curMap nnd not in prevArr are passed to MapDiffer.Add() - All values that exist in preMap and in curMap are passed to MapDiffer.Modify()
- It is the responsibility of ArrayDiffer.Modify() to determine if the values it was passed have been modified.
If `preMap` and `curMap` are both backed by /v3/HAMTs with the same bitwidth and hash function use the more efficient Hamt method.
Types ¶
type ArrayDiffer ¶
type ArrayDiffer interface { Add(key uint64, val *typegen.Deferred) error Modify(key uint64, from, to *typegen.Deferred) error Remove(key uint64, val *typegen.Deferred) error }
ArrayDiffer generalizes adt.Array diffing by accepting a Deferred type that can unmarshalled to its corresponding struct in an interface implantation. Add should be called when a new k,v is added to the array Modify should be called when a value is modified in the array Remove should be called when a value is removed from the array
type MapDiffer ¶
type MapDiffer interface { AsKey(key string) (abi.Keyer, error) Add(key string, val *typegen.Deferred) error Modify(key string, from, to *typegen.Deferred) error Remove(key string, val *typegen.Deferred) error }
MapDiffer generalizes adt.Map diffing by accepting a Deferred type that can unmarshalled to its corresponding struct in an interface implantation. AsKey should return the Keyer implementation specific to the map Add should be called when a new k,v is added to the map Modify should be called when a value is modified in the map Remove should be called when a value is removed from the map