Open cryptoyang opened 3 years ago
A binary (canonical) ID is a 320-bit value of concat(size, hash)
, where:
size
is a uint64 data length in network byte order.
hash
is a sha256 checksum of the data
A text representation of an ID is literal id1
concatenated with zBase32-encoded binary ID with removed leading zeroes (represented as y
in zBase32)
This document is not complete and can change over time.
File system abstraction
Purpose
Persistent data storage is a common problem that can be solved in many ways. However, each available solution has its own drawbacks, and any of them doesn't meet all our requirements that we can imagine.
Requirements
Layers
The file system abstraction can be represented as a unidirectional(?) layers or graph of cooperating services.
Store
The lowest level of data persistence abstraction. Key-value store for hash-based IDs associated with blob.
Requirements
The storage interface allows only for basic operations, the domain-specific functions will be delivered on higher layers.
API
interface Store {
suspend operator fun plus(data: T): Id
operator fun get(id: Id): T
operator fun minus(id: Id): Boolean
operator fun contains(id: Id): Boolean
fun set(): Set
fun additions(): Flow
}
typealias Type = String
interface Graph { fun source(id: Id): Set
fun target(id: Id): Set
fun type(name: Type): Set
}
data class Story( val ver: Int = 0, val type: Type = "", val rel: Set = emptySet(),
val body: Map<String, Any> = emptyMap()
)