storage.bend relies on unsafe/foreign
raw source on the hub · import bend-kit-storage@0.7.0.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.1/bytes.bend as Bytes import bend-kit-files@0.4.0.1/files.bend as Files import bend-kit-crypto@0.2.2.2/crypto.bend as Crypto import bend-kit-collections@0.1.6.0/omap.bend as OMap import bend-kit-collections@0.1.6.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.
TFile@-B:Data -> @data:B -> Tree<B>
TEnd@-B:Data -> Tree<B>
TItem@-B:Data -> @name:String -> @child:Tree<B> -> @rest:Tree<B> -> Tree<B>
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.
OFile@-D:Data -> @-B:Data -> @data:B -> Obj<D, B>
OEnd@-D:Data -> @-B:Data -> Obj<D, B>
OItem@-D:Data -> @-B:Data -> @name:String -> @child:D -> @rest:D -> Obj<D, B>
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.
StNil@-D:Data -> @-B:Data -> Store<D, B>
StCon@-D:Data -> @-B:Data -> @key:D -> @obj:Obj<D, B> -> @rest:Store<D, B> -> Store<D, B>
type Blob source · line 407 · raw
Data
File octets and the SHA-256 of their canonical file encoding.
Blob@len:U32 -> @words:List<&2, U32> -> @digest:Digest -> Blob
type Digest source · line 483 · raw
Data
A SHA-256 digest: its 32 octets packed four to a U32, low octet first, as Bytes packs them.
Digest@words:List<&2, U32> -> Digest
type Fetch source · line 914 · raw
Data
One step of Disk.fetch.go.
Want@d:Digest -> Fetch
Have@d:Digest -> @held:Bool -> Fetch
Read@d:Digest -> @there:Bool -> Fetch
Got@d:Digest -> Fetch
Seen@m:Maybe<&2, Obj<Digest, Blob>> -> Fetch
type Step source · line 1128 · raw
Data
StatStep
Statted@info:0x5fea041be86f1677bfed779e7579233f/files.Info -> Step
Listing@names:List<&2, String> -> Step
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.pack source · line 419 · raw
@d:Digest -> @b:0xec25e4adfb02e59e4b817801115988ee/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 -> 0xec25e4adfb02e59e4b817801115988ee/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 limit source · line 452 · raw
Nat
Loads and collections give up past this many levels. Each directory entry is one level.
def char.ok source · line 455 · raw
@+c:U32 -> Bool
def chars.ok source · line 458 · raw
@s:String -> Bool
def name.ok source · line 466 · raw
@+n:String -> Bool
A directory entry name: one to 255 octets, not "." or "..", with no NUL, newline, or "/".
def hex.ok source · line 471 · raw
@s:String -> Bool
def digest.ok source · line 479 · raw
@+d:String -> Bool
64 lowercase hex characters.
def Digest.order source · line 486 · raw
@a:List<&2, U32> -> @b:List<&2, U32> -> Cmp
def Digest.cmp source · line 498 · 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 503 · raw
@d:Digest -> String
def nibble source · line 508 · raw
@+c:U32 -> U32
def unhex source · line 512 · raw
@s:String -> List<&2, U32>
Two hex digits per octet.
def pack source · line 520 · raw
@bs:List<&2, U32> -> List<&2, U32>
Four octets per word, low octet first.
def Digest.read.if source · line 527 · raw
@ok:Bool -> @s:String -> Maybe<&2, Digest>
def Digest.read source · line 535 · raw
@+s:String -> Maybe<&2, Digest>
The digest that 64 lowercase hex characters name, or None.
def encode.file.at source · line 538 · raw
@+len:U32 -> @ws:List<&2, U32> -> @+hl:U32 -> @r:Pair(Array<U32>, U32) -> 0xec25e4adfb02e59e4b817801115988ee/bytes.Bytes
def encode.file.pick source · line 543 · raw
@aligned:Bool -> @+len:U32 -> @ws:List<&2, U32> -> @+hl:U32 -> @a:Array<U32> -> 0xec25e4adfb02e59e4b817801115988ee/bytes.Bytes
def encode.file source · line 551 · raw
@+len:U32 -> @ws:List<&2, U32> -> @h:0xec25e4adfb02e59e4b817801115988ee/bytes.Bytes -> 0xec25e4adfb02e59e4b817801115988ee/bytes.Bytes
The header h, then the words of a Blob of len octets, written once without a byte loop.
def encode source · line 556 · raw
@o:Obj<Digest, Blob> -> 0xec25e4adfb02e59e4b817801115988ee/bytes.Bytes
The canonical encoding: "file <len>\n" and the octets, "end\n", or "item <child> <rest> <name>\n".
def Run source · line 569 · raw
@-A:Type -> Type
def Run.pure source · line 572 · raw
@-A:Type -> @x:A -> Run(A)
def Run.fail source · line 575 · raw
@-A:Type -> @e:Pair(U32, String) -> Run(A)
def Run.next source · line 578 · raw
@-A:Type -> @-B:Type -> @r:Result<&1, &1, Pair(U32, String), A> -> @f:(@_:A -> Run(B)) -> Run(B)
def Run.bind source · line 585 · raw
@-A:Type -> @-B:Type -> @m:Run(A) -> @f:(@_:A -> Run(B)) -> Run(B)
def Run.lift source · line 588 · raw
@-A:Type -> @m:IO(A) -> Run(A)
def Run.check source · line 591 · raw
@ok:Bool -> @+why:String -> Run(Unit)
def Run.some source · line 598 · raw
@-A:Data -> @m:Maybe<&2, A> -> @+why:String -> Run(A)
def digest.of source · line 605 · raw
@r:Pair(U32, Array<U32>) -> Digest
def digest source · line 610 · raw
@b:0xec25e4adfb02e59e4b817801115988ee/bytes.Bytes -> Run(Digest)
The SHA-256 of b.
def Blob.of.hashed source · line 620 · raw
@+len:U32 -> @buffers:Pair(Array<U32>, Pair(U32, Array<U32>)) -> Blob
def Blob.of source · line 625 · raw
@b:0xec25e4adfb02e59e4b817801115988ee/bytes.Bytes -> Run(Blob)
Hashes the packed input before it becomes a reusable word list.
def Blob.string source · line 631 · raw
@s:String -> Run(Blob)
def object.digest source · line 634 · raw
@o:Obj<Digest, Blob> -> Run(Digest)
def decode.when source · line 643 · raw
@ok:Bool -> @o:Obj<Digest, Blob> -> Maybe<&2, Obj<Digest, Blob>>
def decode.item.of source · line 650 · raw
@ok:Bool -> @n:String -> @c:Maybe<&2, Digest> -> @r:Maybe<&2, Digest> -> Maybe<&2, Obj<Digest, Blob>>
def decode.item source · line 658 · raw
@+rest:String -> Maybe<&2, Obj<Digest, Blob>>
rest is "<child> <rest> <name>".
def decode.file source · line 664 · raw
@m:Maybe<&2, U32> -> @d:Digest -> @+digits:String -> @+at:U32 -> @b:0xec25e4adfb02e59e4b817801115988ee/bytes.Bytes -> Maybe<&2, Obj<Digest, Blob>>
def decode.head source · line 673 · raw
@d:Digest -> @+head:String -> @+at:U32 -> @b:0xec25e4adfb02e59e4b817801115988ee/bytes.Bytes -> Maybe<&2, Obj<Digest, Blob>>
def decode.cut source · line 682 · raw
@d:Digest -> @+at:U32 -> @r:Pair(0xec25e4adfb02e59e4b817801115988ee/bytes.Bytes, 0xec25e4adfb02e59e4b817801115988ee/bytes.Bytes) -> Maybe<&2, Obj<Digest, Blob>>
def decode.at source · line 686 · raw
@d:Digest -> @r:Pair(0xec25e4adfb02e59e4b817801115988ee/bytes.Bytes, Maybe<&2, U32>) -> Maybe<&2, Obj<Digest, Blob>>
def decode.hashed source · line 693 · raw
@d:Digest -> @b:0xec25e4adfb02e59e4b817801115988ee/bytes.Bytes -> Maybe<&2, Obj<Digest, Blob>>
def decode.two source · line 696 · raw
@bb:Pair(0xec25e4adfb02e59e4b817801115988ee/bytes.Bytes, 0xec25e4adfb02e59e4b817801115988ee/bytes.Bytes) -> Run(Maybe<&2, Obj<Digest, Blob>>)
def decode source · line 703 · raw
@b:0xec25e4adfb02e59e4b817801115988ee/bytes.Bytes -> Run(Maybe<&2, Obj<Digest, Blob>>)
The object that encode wrote, or None for any other octets.
def commit.done source · line 706 · raw
@+d:Digest -> @o:Obj<Digest, Blob> -> @xs:Store<Digest, Blob> -> Run(Pair(Digest, Store<Digest, Blob>))
def commit.node source · line 709 · raw
@+o:Obj<Digest, Blob> -> @xs:Store<Digest, Blob> -> Run(Pair(Digest, Store<Digest, Blob>))
def commit.item source · line 714 · 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 722 · 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 734 · raw
@+s:Index(Digest, Blob) -> @+claimed:Digest -> @bb:Pair(0xec25e4adfb02e59e4b817801115988ee/bytes.Bytes, 0xec25e4adfb02e59e4b817801115988ee/bytes.Bytes) -> Run(Index(Digest, Blob))
def receive source · line 742 · raw
@+s:Index(Digest, Blob) -> @+claimed:Digest -> @b:0xec25e4adfb02e59e4b817801115988ee/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 747 · raw
@+dir:String -> @+d:Digest -> String
def Disk.init source · line 750 · raw
@+dir:String -> Run(Unit)
def write.close source · line 756 · raw
@r:Pair(File, Result<&1, &1, Pair(U32, String), Unit>) -> Run(Unit)
def write.file source · line 763 · raw
@+path:String -> @b:0xec25e4adfb02e59e4b817801115988ee/bytes.Bytes -> Run(Unit)
def write.cleanup source · line 773 · raw
@+tmp:String -> @r:Result<&1, &1, Pair(U32, String), Unit> -> Run(Unit)
def write.publish source · line 782 · raw
@r:Result<&1, &1, Pair(U32, String), Unit> -> @+tmp:String -> @path:String -> Run(Unit)
def write.opened source · line 791 · raw
@pair:Pair(String, File) -> @path:String -> @b:0xec25e4adfb02e59e4b817801115988ee/bytes.Bytes -> Run(Unit)
def write source · line 799 · raw
@+dir:String -> @name:String -> @path:String -> @b:0xec25e4adfb02e59e4b817801115988ee/bytes.Bytes -> Run(Unit)
Each write owns its exclusively created temporary file until publication or cleanup.
def read.chunk source · line 804 · raw
@r:Pair(File, Result<&1, &1, Pair(U32, String), 0xec25e4adfb02e59e4b817801115988ee/bytes.Bytes>) -> Run(Pair(File, 0xec25e4adfb02e59e4b817801115988ee/bytes.Bytes))
def read.piece source · line 813 · raw
@f:File -> Run(Pair(File, 0xec25e4adfb02e59e4b817801115988ee/bytes.Bytes))
def read.go source · line 817 · raw
@n:Nat -> @fb:Pair(File, 0xec25e4adfb02e59e4b817801115988ee/bytes.Bytes) -> @acc:0xec25e4adfb02e59e4b817801115988ee/bytes.Bytes -> Run(0xec25e4adfb02e59e4b817801115988ee/bytes.Bytes)
n more reads of up to 1 MiB each; fb holds the file and the last piece.
def read.check source · line 828 · raw
@+size:U32 -> @b:0xec25e4adfb02e59e4b817801115988ee/bytes.Bytes -> Run(0xec25e4adfb02e59e4b817801115988ee/bytes.Bytes)
def info.size source · line 834 · raw
@i:0x5fea041be86f1677bfed779e7579233f/files.Info -> Run(U32)
def read.sized source · line 840 · raw
@+path:String -> @+size:U32 -> Run(0xec25e4adfb02e59e4b817801115988ee/bytes.Bytes)
def read source · line 847 · raw
@+path:String -> Run(0xec25e4adfb02e59e4b817801115988ee/bytes.Bytes)
The whole file at path.
def Disk.put.if source · line 854 · raw
@there:Bool -> @+dir:String -> @+d:Digest -> @+path:String -> @b:0xec25e4adfb02e59e4b817801115988ee/bytes.Bytes -> Run(Unit)
def Disk.put source · line 862 · raw
@+dir:String -> @+d:Digest -> @b:0xec25e4adfb02e59e4b817801115988ee/bytes.Bytes -> Run(Unit)
Writes the encoded object under its digest unless the file exists. Objects never change.
def Disk.save source · line 868 · raw
@+dir:String -> @xs:Store<Digest, Blob> -> Run(Unit)
def Disk.receive.two source · line 878 · raw
@+dir:String -> @+s:Index(Digest, Blob) -> @+claimed:Digest -> @bb:Pair(0xec25e4adfb02e59e4b817801115988ee/bytes.Bytes, 0xec25e4adfb02e59e4b817801115988ee/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 885 · raw
@+dir:String -> @+s:Index(Digest, Blob) -> @+claimed:Digest -> @b:0xec25e4adfb02e59e4b817801115988ee/bytes.Bytes -> Run(Index(Digest, Blob))
def Disk.load.one source · line 889 · 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 898 · raw
@+dir:String -> @names:List<&2, String> -> @+s:Index(Digest, Blob) -> Run(Index(Digest, Blob))
def Disk.load source · line 908 · 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 923 · 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 950 · raw
Nat
Five steps per level, so a fetch goes as deep as a load with limit().
def Disk.fetch source · line 954 · 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 957 · raw
@+dir:String -> @roots:List<&2, Digest> -> @+s:Index(Digest, Blob) -> Run(Index(Digest, Blob))
def Disk.probe.one source · line 966 · raw
@there:Bool -> @+dir:String -> @+d:Digest -> @+s:Index(Digest, Blob) -> Run(Index(Digest, Blob))
def Disk.probe source · line 976 · 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 986 · raw
@+dir:String -> @+name:String -> @+d:Digest -> Run(Unit)
def Disk.root source · line 991 · raw
@+dir:String -> @+name:String -> Run(Digest)
def Disk.roots.go source · line 996 · raw
@+dir:String -> @names:List<&2, String> -> Run(List<&2, Digest>)
def Disk.roots source · line 1007 · raw
@+dir:String -> Run(List<&2, Digest>)
The digest of every named root.
def Disk.drop.one source · line 1012 · raw
@live:Bool -> @+dir:String -> @+d:Digest -> Run(U32)
def Disk.drop source · line 1021 · raw
@+dir:String -> @ds:List<&2, Digest> -> @+live:Index(Digest, Blob) -> @+n:U32 -> Run(U32)
def digests.add source · line 1030 · raw
@m:Maybe<&2, Digest> -> @ds:List<&2, Digest> -> List<&2, Digest>
def digests source · line 1038 · raw
@names:List<&2, String> -> List<&2, Digest>
The digests that names name. Other names are left out.
def Disk.collect.of source · line 1046 · 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 1055 · 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 Disk.clean_tmp.go source · line 1060 · raw
@+dir:String -> @names:List<&2, String> -> @+n:U32 -> Run(U32)
def Disk.clean_tmp source · line 1070 · raw
@+dir:String -> Run(U32)
No writer may run during maintenance; the caller must hold the store exclusively.
def sync.send source · line 1075 · raw
@+dir:String -> @ys:Store<Digest, Blob> -> @+dst:Index(Digest, Blob) -> @+n:U32 -> Run(U32)
def sync.of source · line 1084 · raw
@+dst:String -> @+root:Digest -> @+a:Index(Digest, Blob) -> @+b:Index(Digest, Blob) -> Run(U32)
def sync.probe source · line 1090 · 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 1095 · raw
@+dst:String -> @+root:Digest -> @+a:Index(Digest, Blob) -> Run(U32)
def sync source · line 1102 · 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 1109 · 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 1114 · raw
@+dir:String -> @r:Pair(Digest, Store<Digest, Blob>) -> Run(Digest)
def Disk.commit source · line 1121 · raw
@+dir:String -> @t:Tree<Blob> -> Run(Digest)
Commits t to the store at dir and answers its root digest.
def snap source · line 1134 · 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 1158 · raw
@+path:String -> Run(Tree<Blob>)
def restore.go source · line 1162 · 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 1185 · 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.
Effects (foreign code)
effect Blob.hash.words source · line 616 · raw
@len:U32 -> @raw:Array<U32> -> IO(Result<&1, &1, Pair(U32, String), Pair(Array<U32>, Pair(U32, Array<U32>))>)
foreign: effs/storage.c, effs/storage.js
effect write.temp source · line 769 · raw
@prefix:String -> IO(Result<&1, &1, Pair(U32, String), Pair(String, File)>)
foreign: effs/storage.c, effs/storage.js