Documentation ¶
Index ¶
- Constants
- Variables
- func StoreEmptyArray(s Store, bitwidth int) (cid.Cid, error)
- func StoreEmptyMap(s Store, bitwidth int) (cid.Cid, error)
- func StoreEmptyMultimap(store Store, outerBitwidth, innerBitwidth int) (cid.Cid, error)
- type Array
- func (a *Array) AppendContinuous(value cbor.Marshaler) error
- func (a *Array) BatchDelete(ix []uint64, strict bool) error
- func (a *Array) Delete(i uint64) error
- func (a *Array) ForEach(out cbor.Unmarshaler, fn func(i int64) error) error
- func (a *Array) Get(k uint64, out cbor.Unmarshaler) (bool, error)
- func (a *Array) Length() uint64
- func (a *Array) Pop(k uint64, out cbor.Unmarshaler) (bool, error)
- func (a *Array) Root() (cid.Cid, error)
- func (a *Array) Set(i uint64, value cbor.Marshaler) error
- func (a *Array) TryDelete(i uint64) (bool, error)
- type BalanceTable
- type Map
- func (m *Map) CollectKeys() (out []string, err error)
- func (m *Map) Delete(k abi.Keyer) error
- func (m *Map) ForEach(out cbor.Unmarshaler, fn func(key string) error) error
- func (m *Map) Get(k abi.Keyer, out cbor.Unmarshaler) (bool, error)
- func (m *Map) Has(k abi.Keyer) (bool, error)
- func (m *Map) MarshalCBOR(w io.Writer) error
- func (m *Map) Pop(k abi.Keyer, out cbor.Unmarshaler) (bool, error)
- func (m *Map) Put(k abi.Keyer, v cbor.Marshaler) error
- func (m *Map) PutIfAbsent(k abi.Keyer, v cbor.Marshaler) (bool, error)
- func (m *Map) Root() (cid.Cid, error)
- func (m *Map) TryDelete(k abi.Keyer) (bool, error)
- type Multimap
- type Set
- func (h *Set) CollectKeys() (out []string, err error)
- func (h *Set) Delete(k abi.Keyer) error
- func (h *Set) ForEach(cb func(k string) error) error
- func (h *Set) Has(k abi.Keyer) (bool, error)
- func (h *Set) Put(k abi.Keyer) error
- func (h *Set) Root() (cid.Cid, error)
- func (h *Set) TryDelete(k abi.Keyer) (bool, error)
- type Store
Constants ¶
const BalanceTableBitwidth = 6
Bitwidth of balance table HAMTs, determined empirically from mutation patterns and projections of mainnet data
Variables ¶
var DefaultAmtOptions = []amt.Option{}
var DefaultHamtOptions = []hamt.Option{ hamt.UseHashFunction(func(input []byte) []byte { res := sha256.Sum256(input) return res[:] }), }
DefaultHamtOptions specifies default options used to construct Filecoin HAMTs. Specific HAMT instances may specify additional options, especially the bitwidth.
Functions ¶
func StoreEmptyArray ¶
Writes a new empty array to the store, returning its CID.
func StoreEmptyMap ¶
Creates and stores a new empty map, returning its CID.
func StoreEmptyMultimap ¶
Creates and stores a new empty multimap, returning its CID.
Types ¶
type Array ¶
type Array struct {
// contains filtered or unexported fields
}
Array stores a sparse sequence of values in an AMT.
func MakeEmptyArray ¶
Creates a new array backed by an empty AMT.
func (*Array) AppendContinuous ¶
Appends a value to the end of the array. Assumes continuous array. If the array isn't continuous use Set and a separate counter
func (*Array) ForEach ¶
Iterates all entries in the array, deserializing each value in turn into `out` and then calling a function. Iteration halts if the function returns an error. If the output parameter is nil, deserialization is skipped.
func (*Array) Get ¶
Get retrieves array element into the 'out' unmarshaler, returning a boolean
indicating whether the element was found in the array
func (*Array) Pop ¶
Retrieves an array value into the 'out' unmarshaler (if non-nil), and removes the entry. Returns a boolean indicating whether the element was previously in the array.
type BalanceTable ¶
type BalanceTable Map
A specialization of a map of addresses to (positive) token amounts. Absent keys implicitly have a balance of zero.
func AsBalanceTable ¶
func AsBalanceTable(s Store, r cid.Cid) (*BalanceTable, error)
Interprets a store as balance table with root `r`.
func (*BalanceTable) Get ¶
func (t *BalanceTable) Get(key addr.Address) (abi.TokenAmount, error)
Gets the balance for a key, which is zero if they key has never been added to.
type Map ¶
type Map struct {
// contains filtered or unexported fields
}
Map stores key-value pairs in a HAMT.
func AsMap ¶
AsMap interprets a store as a HAMT-based map with root `r`. The HAMT is interpreted with branching factor 2^bitwidth. We could drop this parameter if https://github.com/filecoin-project/go-hamt-ipld/issues/79 is implemented.
func MakeEmptyMap ¶
Creates a new map backed by an empty HAMT.
func (*Map) CollectKeys ¶
Collects all the keys from the map into a slice of strings.
func (*Map) ForEach ¶
Iterates all entries in the map, deserializing each value in turn into `out` and then calling a function with the corresponding key. Iteration halts if the function returns an error. If the output parameter is nil, deserialization is skipped.
func (*Map) Get ¶
Get retrieves the value at `k` into `out`, if the `k` is present and `out` is non-nil. Returns whether the key was found.
func (*Map) Pop ¶
Retrieves the value for `k` into the 'out' unmarshaler (if non-nil), and removes the entry. Returns a boolean indicating whether the element was previously in the map.
func (*Map) PutIfAbsent ¶
Sets key key `k` to value `v` iff the key is not already present.
type Multimap ¶
type Multimap struct {
// contains filtered or unexported fields
}
Multimap stores multiple values per key in a HAMT of AMTs. The order of insertion of values for each key is retained.
func MakeEmptyMultimap ¶
Creates a new map backed by an empty HAMT and flushes it to the store. The outer map has a branching factor of 2^bitwidth.
type Set ¶ added in v0.9.0
type Set struct {
// contains filtered or unexported fields
}
Set interprets a Map as a set, storing keys (with empty values) in a HAMT.
func AsSet ¶ added in v0.9.0
AsSet interprets a store as a HAMT-based set with root `r`. The HAMT is interpreted with branching factor 2^bitwidth.
func MakeEmptySet ¶ added in v0.9.0
NewSet creates a new HAMT with root `r` and store `s`. The HAMT has branching factor 2^bitwidth.
func (*Set) CollectKeys ¶ added in v0.9.0
Collects all the keys from the set into a slice of strings.
func (*Set) ForEach ¶ added in v0.9.0
ForEach iterates over all values in the set, calling the callback for each value. Returning error from the callback stops the iteration.