Documentation ¶
Index ¶
- Variables
- type Array
- func (a *Array) AppendContinuous(value cbor.Marshaler) error
- func (a *Array) BatchDelete(ix []uint64) 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) Root() (cid.Cid, error)
- func (a *Array) Set(i uint64, value cbor.Marshaler) error
- type BalanceTable
- func (t *BalanceTable) Add(key addr.Address, value abi.TokenAmount) error
- func (t *BalanceTable) Get(key addr.Address) (abi.TokenAmount, error)
- func (t *BalanceTable) MustSubtract(key addr.Address, req abi.TokenAmount) error
- func (t *BalanceTable) Root() (cid.Cid, error)
- func (t *BalanceTable) SubtractWithMinimum(key addr.Address, req abi.TokenAmount, floor abi.TokenAmount) (abi.TokenAmount, error)
- func (t *BalanceTable) Total() (abi.TokenAmount, error)
- 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) Put(k abi.Keyer, v cbor.Marshaler) error
- func (m *Map) Root() (cid.Cid, error)
- type Multimap
- func (mm *Multimap) Add(key abi.Keyer, value cbor.Marshaler) error
- func (mm *Multimap) ForAll(fn func(k string, arr *Array) error) error
- func (mm *Multimap) ForEach(key abi.Keyer, out cbor.Unmarshaler, fn func(i int64) error) error
- func (mm *Multimap) Get(key abi.Keyer) (*Array, bool, error)
- func (mm *Multimap) RemoveAll(key abi.Keyer) error
- func (mm *Multimap) Root() (cid.Cid, error)
- type Set
- type Store
Constants ¶
This section is empty.
Variables ¶
var HamtOptions = []hamt.Option{ hamt.UseTreeBitWidth(hamtBitwidth), hamt.UseHashFunction(func(input []byte) []byte { res := sha256.Sum256(input) return res[:] }), }
HamtOptions specifies all the options used to construct filecoin HAMTs.
Functions ¶
This section is empty.
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 map backed by an empty HAMT and flushes it to the store.
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) BatchDelete ¶
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
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) Add ¶
func (t *BalanceTable) Add(key addr.Address, value abi.TokenAmount) error
Adds an amount to a balance, requiring the resulting balance to be non-negative.
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.
func (*BalanceTable) MustSubtract ¶
func (t *BalanceTable) MustSubtract(key addr.Address, req abi.TokenAmount) error
MustSubtract subtracts the given amount from the account's balance. Returns an error if the account has insufficient balance
func (*BalanceTable) Root ¶
func (t *BalanceTable) Root() (cid.Cid, error)
Returns the root cid of underlying HAMT.
func (*BalanceTable) SubtractWithMinimum ¶
func (t *BalanceTable) SubtractWithMinimum(key addr.Address, req abi.TokenAmount, floor abi.TokenAmount) (abi.TokenAmount, error)
Subtracts up to the specified amount from a balance, without reducing the balance below some minimum. Returns the amount subtracted.
func (*BalanceTable) Total ¶
func (t *BalanceTable) Total() (abi.TokenAmount, error)
Returns the total balance held by this BalanceTable
type Map ¶
type Map struct {
// contains filtered or unexported fields
}
Map stores key-value pairs in a HAMT.
func MakeEmptyMap ¶
Creates a new map backed by an empty HAMT and flushes it to the store.
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.
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 AsMultimap ¶
Interprets a store as a HAMT-based map of AMTs with root `r`.
func MakeEmptyMultimap ¶
Creates a new map backed by an empty HAMT and flushes it to the store.
func (*Multimap) ForEach ¶
Iterates all entries for a key in the order they were inserted, 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.
type Set ¶
type Set struct {
// contains filtered or unexported fields
}
Set interprets a Map as a set, storing keys (with empty values) in a HAMT.
func MakeEmptySet ¶
NewSet creates a new HAMT with root `r` and store `s`.
func (*Set) CollectKeys ¶
Collects all the keys from the set into a slice of strings.
func (*Set) ForEach ¶
ForEach iterates over all values in the set, calling the callback for each value. Returning error from the callback stops the iteration.