-
Notifications
You must be signed in to change notification settings - Fork 11
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Updates data format to match the spec: https://github.com/web3-storage/specs/blob/4163e28d7e6a7c44cff68db9d9bffb9b37707dc6/pail.md#data-format
- Loading branch information
Alan Shaw
authored
Jan 10, 2024
1 parent
13c8c59
commit 6b54a88
Showing
23 changed files
with
493 additions
and
395 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
export {} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,65 @@ | ||
import { Link, UnknownLink, BlockView, Block, Version } from 'multiformats' | ||
import { sha256 } from 'multiformats/hashes/sha2' | ||
import * as dagCBOR from '@ipld/dag-cbor' | ||
|
||
export { Link, UnknownLink, BlockView, Block, Version } | ||
|
||
export type ShardEntryValueValue = UnknownLink | ||
|
||
export type ShardEntryLinkValue = [ShardLink] | ||
|
||
export type ShardEntryLinkAndValueValue = [ShardLink, UnknownLink] | ||
|
||
export type ShardValueEntry = [key: string, value: ShardEntryValueValue] | ||
|
||
export type ShardLinkEntry = [key: string, value: ShardEntryLinkValue | ShardEntryLinkAndValueValue] | ||
|
||
/** Single key/value entry within a shard. */ | ||
export type ShardEntry = [key: string, value: ShardEntryValueValue | ShardEntryLinkValue | ShardEntryLinkAndValueValue] | ||
|
||
/** Legacy shards are not self describing. */ | ||
export type LegacyShard = ShardEntry[] | ||
|
||
export interface Shard { | ||
entries: ShardEntry[] | ||
/** Max key length (in UTF-8 encoded characters) - default 64. */ | ||
maxKeyLength: number | ||
/** Max encoded shard size in bytes - default 512 KiB. */ | ||
maxSize: number | ||
} | ||
|
||
export type ShardLink = Link<Shard, typeof dagCBOR.code, typeof sha256.code, 1> | ||
|
||
export interface ShardBlockView extends BlockView<Shard, typeof dagCBOR.code, typeof sha256.code, 1> { | ||
prefix: string | ||
} | ||
|
||
export interface ShardDiff { | ||
additions: ShardBlockView[] | ||
removals: ShardBlockView[] | ||
} | ||
|
||
export interface BlockFetcher { | ||
get<T = unknown, C extends number = number, A extends number = number, V extends Version = 1> (link: Link<T, C, A, V>): | ||
Promise<Block<T, C, A, V> | undefined> | ||
} | ||
|
||
// Clock ////////////////////////////////////////////////////////////////////// | ||
|
||
export type EventLink<T> = Link<EventView<T>> | ||
|
||
export interface EventView<T> { | ||
parents: EventLink<T>[] | ||
data: T | ||
} | ||
|
||
export interface EventBlockView<T> extends BlockView<EventView<T>> {} | ||
|
||
// CRDT /////////////////////////////////////////////////////////////////////// | ||
|
||
export interface EventData { | ||
type: 'put'|'del' | ||
key: string | ||
value: UnknownLink | ||
root: ShardLink | ||
} |
Oops, something went wrong.