~/bend-docscommunity

storage.bend relies on unsafe/foreign

raw source on the hub · import bend-kit-storage@0.3.1.0/storage.bend as Storage

Content-addressed object store: Merkle trees, sync plans, and reachability GC with proved laws. Source: https://github.com/paymog/bend-kit/tree/main/storage

6 imports
import Base
import bend-kit-bytes@0.3.3.0/bytes.bend as Bytes
import bend-kit-files@0.3.1.0/files.bend as Files
import bend-kit-crypto@0.2.2.2/crypto.bend as Crypto
import bend-kit-collections@0.1.5.0/omap.bend as OMap
import bend-kit-collections@0.1.5.0/order.bend as Order

Types

type Tree source · line 10 · raw

@-B:Data -> Data

The content: a file, or a directory as a chain of named entries that ends in End.

type Obj source · line 16 · raw

@-D:Data -> @-B:Data -> Data

One stored object. An OItem names its child and the rest of its directory by digest.

type Store source · line 23 · raw

@-D:Data -> @-B:Data -> Data

Objects by digest, as a list: the model the laws reason about. get answers the first entry whose digest eq accepts. Index below answers the same in O(log n) comparisons.

type Blob source · line 407 · raw

Data

Octets packed four to a U32, low byte first, as Bytes packs them. Words past len are 0.

type Digest source · line 485 · raw

Data

A SHA-256 digest: its 32 octets packed four to a U32, low octet first, as Bytes packs them.

type Fetch source · line 848 · raw

Data

One step of Disk.fetch.go.

type Step source · line 1047 · raw

Data

Definitions

def Store.new source · line 27 · raw

@-D:Data -> @-B:Data -> Store<D, B>

def Store.put.if source · line 54 · raw

@-D:Data -> @-B:Data -> @found:Bool -> @s:Store<D, B> -> @d:D -> @o:Obj<D, B> -> Store<D, B>

def Store.size source · line 73 · raw

@-D:Data -> @-B:Data -> @s:Store<D, B> -> U32

def Store.cat source · line 81 · raw

@-D:Data -> @-B:Data -> @xs:Store<D, B> -> @ys:Store<D, B> -> Store<D, B>

xs, then ys.

def Tree.item source · line 89 · raw

@-B:Data -> @n:String -> @c:Maybe<&2, Tree<B>> -> @r:Maybe<&2, Tree<B>> -> Maybe<&2, Tree<B>>

Some only when both halves loaded.

def closure.item source · line 116 · raw

@-D:Data -> @-B:Data -> @d:D -> @o:Obj<D, B> -> @c:Maybe<&2, Store<D, B>> -> @r:Maybe<&2, Store<D, B>> -> Maybe<&2, Store<D, B>>

def live.cat source · line 178 · raw

@-D:Data -> @-B:Data -> @a:Maybe<&2, Store<D, B>> -> @b:Maybe<&2, Store<D, B>> -> Maybe<&2, Store<D, B>>

def keep.if source · line 203 · raw

@-D:Data -> @-B:Data -> @live:Bool -> @k:D -> @o:Obj<D, B> -> @r:Store<D, B> -> Store<D, B>

def admit.if source · line 229 · raw

@-D:Data -> @-B:Data -> @ok:Bool -> @s:Store<D, B> -> @keep:Store<D, B> -> Maybe<&2, Store<D, B>>

def fits source · line 263 · raw

@-B:Data -> @fuel:Nat -> @t:Tree<B> -> Bool

True when load with this fuel reaches every node of t.

def Index source · line 285 · raw

@-D:Data -> @-B:Data -> Data

def Index.new source · line 288 · raw

@-D:Data -> @-B:Data -> Index(D, B)

def Index.size source · line 291 · raw

@-D:Data -> @-B:Data -> @m:Index(D, B) -> U32

def Index.admit.if source · line 393 · raw

@-D:Data -> @-B:Data -> @ok:Bool -> @s:Index(D, B) -> Maybe<&2, Index(D, B)>

def Blob.read source · line 411 · raw

@n:Nat -> @r:Pair(Array<U32>, U32) -> @+i:U32 -> @acc:List<&2, U32> -> List<&2, U32>

r is the array beside the word read at i - 1.

def Blob.of source · line 419 · raw

@b:0x632652e3c1c0183f12728faf3870bb68/bytes.Bytes -> Blob

def Blob.write source · line 423 · raw

@ws:List<&2, U32> -> @a:Array<U32> -> @+i:U32 -> Array<U32>

def Blob.bytes source · line 430 · raw

@x:Blob -> 0x632652e3c1c0183f12728faf3870bb68/bytes.Bytes

def Blob.write.last source · line 435 · raw

@zero:Bool -> @a:Array<U32> -> @+j:U32 -> @+carry:U32 -> Array<U32>

A zero last carry may lie past the array, where a write would wrap to word 0.

def Blob.write.shift source · line 443 · raw

@ws:List<&2, U32> -> @a:Array<U32> -> @+j:U32 -> @+lo:Nat -> @+hi:Nat -> @+carry:U32 -> Array<U32>

Writes ws from octet 4 * j + lo / 8 on; carry holds the octets of word j below lo.

def Blob.string source · line 450 · raw

@+s:String -> Blob

def limit source · line 454 · raw

Nat

Loads and collections give up past this many levels. Each directory entry is one level.

def char.ok source · line 457 · raw

@+c:U32 -> Bool

def chars.ok source · line 460 · raw

@s:String -> Bool

def name.ok source · line 468 · raw

@+n:String -> Bool

A directory entry name: one to 255 octets, not "." or "..", with no NUL, newline, or "/".

def hex.ok source · line 473 · raw

@s:String -> Bool

def digest.ok source · line 481 · raw

@+d:String -> Bool

64 lowercase hex characters.

def Digest.order source · line 488 · raw

@a:List<&2, U32> -> @b:List<&2, U32> -> Cmp

def Digest.cmp source · line 500 · raw

@a:Digest -> @b:Digest -> Cmp

A total order on digests (the digest_cmp_ laws). It is not hex order.

def Digest.hex source · line 505 · raw

@d:Digest -> String

def nibble source · line 510 · raw

@+c:U32 -> U32

def unhex source · line 514 · raw

@s:String -> List<&2, U32>

Two hex digits per octet.

def pack source · line 522 · raw

@bs:List<&2, U32> -> List<&2, U32>

Four octets per word, low octet first.

def Digest.read.if source · line 529 · raw

@ok:Bool -> @s:String -> Maybe<&2, Digest>

def Digest.read source · line 537 · raw

@+s:String -> Maybe<&2, Digest>

The digest that 64 lowercase hex characters name, or None.

def encode.file.at source · line 540 · raw

@+len:U32 -> @ws:List<&2, U32> -> @+hl:U32 -> @r:Pair(Array<U32>, U32) -> 0x632652e3c1c0183f12728faf3870bb68/bytes.Bytes

def encode.file.pick source · line 545 · raw

@aligned:Bool -> @+len:U32 -> @ws:List<&2, U32> -> @+hl:U32 -> @a:Array<U32> -> 0x632652e3c1c0183f12728faf3870bb68/bytes.Bytes

def encode.file source · line 553 · raw

@+len:U32 -> @ws:List<&2, U32> -> @h:0x632652e3c1c0183f12728faf3870bb68/bytes.Bytes -> 0x632652e3c1c0183f12728faf3870bb68/bytes.Bytes

The header h, then the words of a Blob of len octets, written once without a byte loop.

def encode source · line 558 · raw

@o:Obj<Digest, Blob> -> 0x632652e3c1c0183f12728faf3870bb68/bytes.Bytes

The canonical encoding: "file <len>\n" and the octets, "end\n", or "item <child> <rest> <name>\n".

def decode.when source · line 568 · raw

@ok:Bool -> @o:Obj<Digest, Blob> -> Maybe<&2, Obj<Digest, Blob>>

def decode.item.of source · line 575 · raw

@ok:Bool -> @n:String -> @c:Maybe<&2, Digest> -> @r:Maybe<&2, Digest> -> Maybe<&2, Obj<Digest, Blob>>

def decode.item source · line 583 · raw

@+rest:String -> Maybe<&2, Obj<Digest, Blob>>

rest is "<child> <rest> <name>".

def decode.file source · line 589 · raw

@m:Maybe<&2, U32> -> @+digits:String -> @+at:U32 -> @b:0x632652e3c1c0183f12728faf3870bb68/bytes.Bytes -> Maybe<&2, Obj<Digest, Blob>>

def decode.head source · line 598 · raw

@+head:String -> @+at:U32 -> @b:0x632652e3c1c0183f12728faf3870bb68/bytes.Bytes -> Maybe<&2, Obj<Digest, Blob>>

def decode.cut source · line 607 · raw

@+at:U32 -> @r:Pair(0x632652e3c1c0183f12728faf3870bb68/bytes.Bytes, 0x632652e3c1c0183f12728faf3870bb68/bytes.Bytes) -> Maybe<&2, Obj<Digest, Blob>>

def decode.at source · line 611 · raw

@r:Pair(0x632652e3c1c0183f12728faf3870bb68/bytes.Bytes, Maybe<&2, U32>) -> Maybe<&2, Obj<Digest, Blob>>

def decode source · line 619 · raw

@b:0x632652e3c1c0183f12728faf3870bb68/bytes.Bytes -> Maybe<&2, Obj<Digest, Blob>>

The object that encode wrote, or None for any other octets.

def Run source · line 624 · raw

@-A:Type -> Type

def Run.pure source · line 627 · raw

@-A:Type -> @x:A -> Run(A)

def Run.fail source · line 630 · raw

@-A:Type -> @e:Pair(U32, String) -> Run(A)

def Run.next source · line 633 · raw

@-A:Type -> @-B:Type -> @r:Result<&1, &1, Pair(U32, String), A> -> @f:(@_:A -> Run(B)) -> Run(B)

def Run.bind source · line 640 · raw

@-A:Type -> @-B:Type -> @m:Run(A) -> @f:(@_:A -> Run(B)) -> Run(B)

def Run.lift source · line 643 · raw

@-A:Type -> @m:IO(A) -> Run(A)

def Run.check source · line 646 · raw

@ok:Bool -> @+why:String -> Run(Unit)

def Run.some source · line 653 · raw

@-A:Data -> @m:Maybe<&2, A> -> @+why:String -> Run(A)

def digest.of source · line 660 · raw

@r:Pair(U32, Array<U32>) -> Digest

def digest source · line 665 · raw

@b:0x632652e3c1c0183f12728faf3870bb68/bytes.Bytes -> Run(Digest)

The SHA-256 of b.

def commit.done source · line 671 · raw

@+d:Digest -> @o:Obj<Digest, Blob> -> @xs:Store<Digest, Blob> -> Run(Pair(Digest, Store<Digest, Blob>))

def commit.node source · line 674 · raw

@+o:Obj<Digest, Blob> -> @xs:Store<Digest, Blob> -> Run(Pair(Digest, Store<Digest, Blob>))

def commit.item source · line 679 · raw

@+n:String -> @c:Pair(Digest, Store<Digest, Blob>) -> @r:Pair(Digest, Store<Digest, Blob>) -> Run(Pair(Digest, Store<Digest, Blob>))

def commit source · line 687 · raw

@t:Tree<Blob> -> Run(Pair(Digest, Store<Digest, Blob>))

hash and objects with H = SHA-256 of encode: the root digest and the objects, children first.

def receive.two source · line 699 · raw

@+s:Index(Digest, Blob) -> @+claimed:Digest -> @bb:Pair(0x632652e3c1c0183f12728faf3870bb68/bytes.Bytes, 0x632652e3c1c0183f12728faf3870bb68/bytes.Bytes) -> Run(Index(Digest, Blob))

def receive source · line 707 · raw

@+s:Index(Digest, Blob) -> @+claimed:Digest -> @b:0x632652e3c1c0183f12728faf3870bb68/bytes.Bytes -> Run(Index(Digest, Blob))

Ingress: the store with the object that b encodes. Fails when b does not decode or its SHA-256 is not claimed.

def Disk.object source · line 712 · raw

@+dir:String -> @+d:Digest -> String

def Disk.init source · line 715 · raw

@+dir:String -> Run(Unit)

def write.close source · line 721 · raw

@r:Pair(File, Result<&1, &1, Pair(U32, String), Unit>) -> Run(Unit)

def write.file source · line 728 · raw

@+path:String -> @b:0x632652e3c1c0183f12728faf3870bb68/bytes.Bytes -> Run(Unit)

def write source · line 735 · raw

@+dir:String -> @+name:String -> @+path:String -> @b:0x632652e3c1c0183f12728faf3870bb68/bytes.Bytes -> Run(Unit)

Writes b to path through dir/tmp and a rename, so a reader sees all of b or nothing.

def read.chunk source · line 741 · raw

@r:Pair(File, Result<&1, &1, Pair(U32, String), 0x632652e3c1c0183f12728faf3870bb68/bytes.Bytes>) -> Run(Pair(File, 0x632652e3c1c0183f12728faf3870bb68/bytes.Bytes))

def read.piece source · line 750 · raw

@f:File -> Run(Pair(File, 0x632652e3c1c0183f12728faf3870bb68/bytes.Bytes))

def read.go source · line 754 · raw

@n:Nat -> @fb:Pair(File, 0x632652e3c1c0183f12728faf3870bb68/bytes.Bytes) -> @acc:0x632652e3c1c0183f12728faf3870bb68/bytes.Bytes -> Run(0x632652e3c1c0183f12728faf3870bb68/bytes.Bytes)

n more reads of up to 1 MiB each; fb holds the file and the last piece.

def read.check source · line 765 · raw

@+size:U32 -> @b:0x632652e3c1c0183f12728faf3870bb68/bytes.Bytes -> Run(0x632652e3c1c0183f12728faf3870bb68/bytes.Bytes)

def info.size source · line 771 · raw

@i:0xc022f29d7abb4bf4d2f497d0b5159f5a/files.Info -> U32

def read.sized source · line 775 · raw

@+path:String -> @+size:U32 -> Run(0x632652e3c1c0183f12728faf3870bb68/bytes.Bytes)

def read source · line 782 · raw

@+path:String -> Run(0x632652e3c1c0183f12728faf3870bb68/bytes.Bytes)

The whole file at path.

def Disk.put.if source · line 788 · raw

@there:Bool -> @+dir:String -> @+d:Digest -> @+path:String -> @b:0x632652e3c1c0183f12728faf3870bb68/bytes.Bytes -> Run(Unit)

def Disk.put source · line 796 · raw

@+dir:String -> @+d:Digest -> @b:0x632652e3c1c0183f12728faf3870bb68/bytes.Bytes -> Run(Unit)

Writes the encoded object under its digest unless the file exists. Objects never change.

def Disk.save source · line 802 · raw

@+dir:String -> @xs:Store<Digest, Blob> -> Run(Unit)

def Disk.receive.two source · line 812 · raw

@+dir:String -> @+s:Index(Digest, Blob) -> @+claimed:Digest -> @bb:Pair(0x632652e3c1c0183f12728faf3870bb68/bytes.Bytes, 0x632652e3c1c0183f12728faf3870bb68/bytes.Bytes) -> Run(Index(Digest, Blob))

Ingress into the store at dir: receive, then write the octets under their digest.

def Disk.receive source · line 819 · raw

@+dir:String -> @+s:Index(Digest, Blob) -> @+claimed:Digest -> @b:0x632652e3c1c0183f12728faf3870bb68/bytes.Bytes -> Run(Index(Digest, Blob))

def Disk.load.one source · line 823 · raw

@+dir:String -> @+n:String -> @m:Maybe<&2, Digest> -> @+s:Index(Digest, Blob) -> Run(Index(Digest, Blob))

The object in file objects/n, checked against the digest that n names.

def Disk.load.go source · line 832 · raw

@+dir:String -> @names:List<&2, String> -> @+s:Index(Digest, Blob) -> Run(Index(Digest, Blob))

def Disk.load source · line 842 · raw

@+dir:String -> Run(Index(Digest, Blob))

Every object at dir, each checked against its file name. A tampered or undecodable object fails the load.

def Disk.fetch.go source · line 857 · raw

@fuel:Nat -> @+dir:String -> @step:Fetch -> @+s:Index(Digest, Blob) -> Run(Index(Digest, Blob))

Adds to s every object that a Want reaches at dir, each read and checked through receive once. A missing object is left out, so a load of the root then fails.

def fetch.fuel source · line 884 · raw

Nat

Five steps per level, so a fetch goes as deep as a load with limit().

def Disk.fetch source · line 888 · raw

@+dir:String -> @+root:Digest -> Run(Index(Digest, Blob))

The index of the objects that root reaches at dir. Other objects are not read.

def Disk.fetch.all source · line 891 · raw

@+dir:String -> @roots:List<&2, Digest> -> @+s:Index(Digest, Blob) -> Run(Index(Digest, Blob))

def Disk.probe.one source · line 900 · raw

@there:Bool -> @+dir:String -> @+d:Digest -> @+s:Index(Digest, Blob) -> Run(Index(Digest, Blob))

def Disk.probe source · line 910 · raw

@+dir:String -> @xs:Store<Digest, Blob> -> @+s:Index(Digest, Blob) -> Run(Index(Digest, Blob))

Adds to s the objects of xs that dir holds, each read and checked. Other objects are not read.

def Disk.set_root source · line 920 · raw

@+dir:String -> @+name:String -> @+d:Digest -> Run(Unit)

def Disk.root source · line 925 · raw

@+dir:String -> @+name:String -> Run(Digest)

def Disk.roots.go source · line 930 · raw

@+dir:String -> @names:List<&2, String> -> Run(List<&2, Digest>)

def Disk.roots source · line 941 · raw

@+dir:String -> Run(List<&2, Digest>)

The digest of every named root.

def Disk.drop.one source · line 946 · raw

@live:Bool -> @+dir:String -> @+d:Digest -> Run(U32)

def Disk.drop source · line 955 · raw

@+dir:String -> @ds:List<&2, Digest> -> @+live:Index(Digest, Blob) -> @+n:U32 -> Run(U32)

def digests.add source · line 964 · raw

@m:Maybe<&2, Digest> -> @ds:List<&2, Digest> -> List<&2, Digest>

def digests source · line 972 · raw

@names:List<&2, String> -> List<&2, Digest>

The digests that names name. Other names are left out.

def Disk.collect.of source · line 980 · raw

@+dir:String -> @+retained:List<&2, Digest> -> @+s:Index(Digest, Blob) -> Run(U32)

Drops what gc drops: an object stays exactly when its digest is in the live set.

def Disk.collect source · line 989 · raw

@+dir:String -> @+retained:List<&2, Digest> -> Run(U32)

Deletes every object that no retained root reaches and answers how many it deleted. Fails, and deletes nothing, when a retained root does not load. It reads only the objects the roots reach. No writer may run during the collection.

def sync.send source · line 994 · raw

@+dir:String -> @ys:Store<Digest, Blob> -> @+dst:Index(Digest, Blob) -> @+n:U32 -> Run(U32)

def sync.of source · line 1003 · raw

@+dst:String -> @+root:Digest -> @+a:Index(Digest, Blob) -> @+b:Index(Digest, Blob) -> Run(U32)

def sync.probe source · line 1009 · raw

@+dst:String -> @+root:Digest -> @+a:Index(Digest, Blob) -> @+ys:Store<Digest, Blob> -> Run(U32)

b holds the objects of the closure ys that dst has, so plan sees what a full load of dst would show it.

def sync.from source · line 1014 · raw

@+dst:String -> @+root:Digest -> @+a:Index(Digest, Blob) -> Run(U32)

def sync source · line 1021 · raw

@+src:String -> @+dst:String -> @+root:Digest -> Run(U32)

Sends dst every object it needs to load root as src does, through ingress. Answers how many it sent. It reads the objects root reaches in src, and only those of them that dst holds.

def Disk.checkout source · line 1028 · raw

@+dir:String -> @+root:Digest -> Run(Tree<Blob>)

The tree under root at dir. Fails when an object is missing or tampered, or the tree is too deep. It reads only the objects root reaches.

def Disk.commit.save source · line 1033 · raw

@+dir:String -> @r:Pair(Digest, Store<Digest, Blob>) -> Run(Digest)

def Disk.commit source · line 1040 · raw

@+dir:String -> @t:Tree<Blob> -> Run(Digest)

Commits t to the store at dir and answers its root digest.

def snap source · line 1053 · raw

@fuel:Nat -> @+path:String -> @step:Step -> Run(Tree<Blob>)

The tree at path. Regular files become TFile and directories become TItem chains in name order.

def snapshot source · line 1074 · raw

@+path:String -> Run(Tree<Blob>)

def restore.go source · line 1078 · raw

@t:Tree<Blob> -> @+path:String -> @chain:Bool -> Run(Unit)

Writes t at path. chain is True when t is the rest of the listing of directory path.

def restore source · line 1101 · raw

@t:Tree<Blob> -> @+path:String -> Run(Unit)

Writes t as a new file or directory at path. Fails if path exists.

Templates

template Store.head source · line 31 · raw

@-D:Data -> @-B:Data -> @-eq:(@_:D -> @_:D -> Bool) -> @s:Store<D, B> -> @+d:D -> Bool

eq(d, first key), or False when s is empty.

template Store.get.go source · line 39 · raw

@-D:Data -> @-B:Data -> @-eq:(@_:D -> @_:D -> Bool) -> @s:Store<D, B> -> @+d:D -> @hit:Bool -> Maybe<&2, Obj<D, B>>

hit is Store.head(s, d), so the walk stops at the first match.

template Store.get source · line 48 · raw

@-D:Data -> @-B:Data -> @-eq:(@_:D -> @_:D -> Bool) -> @+s:Store<D, B> -> @+d:D -> Maybe<&2, Obj<D, B>>

template Store.has source · line 51 · raw

@-D:Data -> @-B:Data -> @-eq:(@_:D -> @_:D -> Bool) -> @+s:Store<D, B> -> @+d:D -> Bool

template Store.put source · line 62 · raw

@-D:Data -> @-B:Data -> @-eq:(@_:D -> @_:D -> Bool) -> @+s:Store<D, B> -> @+d:D -> @o:Obj<D, B> -> Store<D, B>

Adds o under d unless d is present. The first object under a digest stays.

template Store.apply source · line 66 · raw

@-D:Data -> @-B:Data -> @-eq:(@_:D -> @_:D -> Bool) -> @xs:Store<D, B> -> @+s:Store<D, B> -> Store<D, B>

Puts each (digest, object) in order.

template load.go source · line 99 · raw

@-D:Data -> @-B:Data -> @-eq:(@_:D -> @_:D -> Bool) -> @fuel:Nat -> @+s:Store<D, B> -> @m:Maybe<&2, Obj<D, B>> -> Maybe<&2, Tree<B>>

m is the object under the digest being loaded.

template load source · line 113 · raw

@-D:Data -> @-B:Data -> @-eq:(@_:D -> @_:D -> Bool) -> @fuel:Nat -> @+s:Store<D, B> -> @+d:D -> Maybe<&2, Tree<B>>

The tree under d, or None when an object is missing or the tree is deeper than fuel.

template closure.go source · line 125 · raw

@-D:Data -> @-B:Data -> @-eq:(@_:D -> @_:D -> Bool) -> @fuel:Nat -> @+s:Store<D, B> -> @+d:D -> @m:Maybe<&2, Obj<D, B>> -> Maybe<&2, Store<D, B>>

template closure source · line 141 · raw

@-D:Data -> @-B:Data -> @-eq:(@_:D -> @_:D -> Bool) -> @fuel:Nat -> @+s:Store<D, B> -> @+d:D -> Maybe<&2, Store<D, B>>

Every object that load(fuel, s, d) reads, parents first, or None when load fails.

template need.head source · line 145 · raw

@-D:Data -> @-B:Data -> @-eq:(@_:D -> @_:D -> Bool) -> @+t:Store<D, B> -> @xs:Store<D, B> -> Bool

Store.has(t, first digest of xs), or False when xs is empty.

template need.go source · line 153 · raw

@-D:Data -> @-B:Data -> @-eq:(@_:D -> @_:D -> Bool) -> @xs:Store<D, B> -> @+t:Store<D, B> -> @found:Bool -> Store<D, B>

found is need.head(t, xs), so only the taken branch recurses.

template need source · line 164 · raw

@-D:Data -> @-B:Data -> @-eq:(@_:D -> @_:D -> Bool) -> @+xs:Store<D, B> -> @+t:Store<D, B> -> Store<D, B>

The entries of xs whose digest t lacks, each digest once. t grows as entries are taken.

template plan.of source · line 167 · raw

@-D:Data -> @-B:Data -> @-eq:(@_:D -> @_:D -> Bool) -> @+dst:Store<D, B> -> @m:Maybe<&2, Store<D, B>> -> Maybe<&2, Store<D, B>>

template plan source · line 175 · raw

@-D:Data -> @-B:Data -> @-eq:(@_:D -> @_:D -> Bool) -> @fuel:Nat -> @+src:Store<D, B> -> @+dst:Store<D, B> -> @+root:D -> Maybe<&2, Store<D, B>>

The objects dst needs to load root as src does, or None when src cannot load root.

template live source · line 188 · raw

@-D:Data -> @-B:Data -> @-eq:(@_:D -> @_:D -> Bool) -> @+fuel:Nat -> @+s:Store<D, B> -> @roots:List<&2, D> -> Maybe<&2, Store<D, B>>

The closures of every root, or None when one root does not load.

template mem source · line 196 · raw

@-D:Data -> @-B:Data -> @-eq:(@_:D -> @_:D -> Bool) -> @ls:Store<D, B> -> @+d:D -> Bool

eq(d, k) for some entry (k, o) of ls.

template keep source · line 211 · raw

@-D:Data -> @-B:Data -> @-eq:(@_:D -> @_:D -> Bool) -> @s:Store<D, B> -> @+ls:Store<D, B> -> Store<D, B>

The entries of s whose digest is in ls.

template gc.of source · line 218 · raw

@-D:Data -> @-B:Data -> @-eq:(@_:D -> @_:D -> Bool) -> @s:Store<D, B> -> @m:Maybe<&2, Store<D, B>> -> Maybe<&2, Store<D, B>>

template gc source · line 226 · raw

@-D:Data -> @-B:Data -> @-eq:(@_:D -> @_:D -> Bool) -> @fuel:Nat -> @+s:Store<D, B> -> @+roots:List<&2, D> -> Maybe<&2, Store<D, B>>

s without the objects that no retained root reaches, or None when a root does not load.

template admit source · line 237 · raw

@-D:Data -> @-B:Data -> @-eq:(@_:D -> @_:D -> Bool) -> @+s:Store<D, B> -> @+claimed:D -> @+computed:D -> @o:Obj<D, B> -> Maybe<&2, Store<D, B>>

Ingress: computed is the digest of o's encoding. None when it is not the claimed digest.

template hash source · line 241 · raw

@-D:Data -> @-B:Data -> @-H:(@_:Obj<D, B> -> D) -> @t:Tree<B> -> D

The Merkle digest of t under the object hash H.

template objects source · line 251 · raw

@-D:Data -> @-B:Data -> @-H:(@_:Obj<D, B> -> D) -> @t:Tree<B> -> Store<D, B>

The objects of t with their digests, children before parents; hash(t) is the last digest.

template valid source · line 275 · raw

@-D:Data -> @-B:Data -> @-H:(@_:Obj<D, B> -> D) -> @-eq:(@_:D -> @_:D -> Bool) -> @s:Store<D, B> -> Bool

True when every entry (k, o) has eq(k, H(o)).

template Index.get source · line 294 · raw

@-D:Data -> @-B:Data -> @-cmp:(@_:D -> @_:D -> Cmp) -> @m:Index(D, B) -> @+d:D -> Maybe<&2, Obj<D, B>>

template Index.has source · line 297 · raw

@-D:Data -> @-B:Data -> @-cmp:(@_:D -> @_:D -> Cmp) -> @m:Index(D, B) -> @+d:D -> Bool

template Index.put.if source · line 300 · raw

@-D:Data -> @-B:Data -> @-cmp:(@_:D -> @_:D -> Cmp) -> @found:Bool -> @m:Index(D, B) -> @+d:D -> @o:Obj<D, B> -> Index(D, B)

template Index.put source · line 308 · raw

@-D:Data -> @-B:Data -> @-cmp:(@_:D -> @_:D -> Cmp) -> @+m:Index(D, B) -> @+d:D -> @o:Obj<D, B> -> Index(D, B)

Adds o under d unless d is present, as Store.put does.

template Index.apply source · line 312 · raw

@-D:Data -> @-B:Data -> @-cmp:(@_:D -> @_:D -> Cmp) -> @xs:Store<D, B> -> @+m:Index(D, B) -> Index(D, B)

Puts each (digest, object) in order.

template Index.of source · line 319 · raw

@-D:Data -> @-B:Data -> @-cmp:(@_:D -> @_:D -> Cmp) -> @xs:Store<D, B> -> Index(D, B)

template Index.load.go source · line 322 · raw

@-D:Data -> @-B:Data -> @-cmp:(@_:D -> @_:D -> Cmp) -> @fuel:Nat -> @+s:Index(D, B) -> @m:Maybe<&2, Obj<D, B>> -> Maybe<&2, Tree<B>>

template Index.load source · line 335 · raw

@-D:Data -> @-B:Data -> @-cmp:(@_:D -> @_:D -> Cmp) -> @fuel:Nat -> @+s:Index(D, B) -> @+d:D -> Maybe<&2, Tree<B>>

template Index.closure.go source · line 338 · raw

@-D:Data -> @-B:Data -> @-cmp:(@_:D -> @_:D -> Cmp) -> @fuel:Nat -> @+s:Index(D, B) -> @+d:D -> @m:Maybe<&2, Obj<D, B>> -> Maybe<&2, Store<D, B>>

template Index.closure source · line 353 · raw

@-D:Data -> @-B:Data -> @-cmp:(@_:D -> @_:D -> Cmp) -> @fuel:Nat -> @+s:Index(D, B) -> @+d:D -> Maybe<&2, Store<D, B>>

template Index.need.head source · line 356 · raw

@-D:Data -> @-B:Data -> @-cmp:(@_:D -> @_:D -> Cmp) -> @+t:Index(D, B) -> @xs:Store<D, B> -> Bool

template Index.need.go source · line 363 · raw

@-D:Data -> @-B:Data -> @-cmp:(@_:D -> @_:D -> Cmp) -> @xs:Store<D, B> -> @+t:Index(D, B) -> @found:Bool -> Store<D, B>

template Index.need source · line 373 · raw

@-D:Data -> @-B:Data -> @-cmp:(@_:D -> @_:D -> Cmp) -> @+xs:Store<D, B> -> @+t:Index(D, B) -> Store<D, B>

template Index.plan.of source · line 376 · raw

@-D:Data -> @-B:Data -> @-cmp:(@_:D -> @_:D -> Cmp) -> @+dst:Index(D, B) -> @m:Maybe<&2, Store<D, B>> -> Maybe<&2, Store<D, B>>

template Index.plan source · line 383 · raw

@-D:Data -> @-B:Data -> @-cmp:(@_:D -> @_:D -> Cmp) -> @fuel:Nat -> @+src:Index(D, B) -> @+dst:Index(D, B) -> @+root:D -> Maybe<&2, Store<D, B>>

template Index.live source · line 386 · raw

@-D:Data -> @-B:Data -> @-cmp:(@_:D -> @_:D -> Cmp) -> @+fuel:Nat -> @+s:Index(D, B) -> @roots:List<&2, D> -> Maybe<&2, Store<D, B>>

template Index.admit source · line 401 · raw

@-D:Data -> @-B:Data -> @-cmp:(@_:D -> @_:D -> Cmp) -> @+s:Index(D, B) -> @+claimed:D -> @+computed:D -> @o:Obj<D, B> -> Maybe<&2, Index(D, B)>

admit on an index: None when claimed is not computed.