Skip to content

Instantly share code, notes, and snippets.

@Gozala
Created August 12, 2020 17:27
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Gozala/df4764a57ff5497334afdd3b3296070a to your computer and use it in GitHub Desktop.
Save Gozala/df4764a57ff5497334afdd3b3296070a to your computer and use it in GitHub Desktop.
interface CID {
code: number
version: number
multihash: Uint8Array
bytes: Uint8Array
}
type Future<T> =
| T
| Promise<T>
interface Block {
cid():Future<CID>
encode():Future<Uint8Array>
}
interface Codec<T> {
code: number
name: string
encode(value:T):Uint8Array
decode(bytes:Uint8Array):T
}
interface MultiHasher {
code: number,
name: string,
digest(bytes:Uint8Array):Digest
}
type Digest = Uint8Array
interface BlockDecoder {
encode <T>(value:T, codec:Codec<T>, hasher?:MultiHasher):Block
}
interface BlockDecoder {
decode <T>(bytes:Uint8Array, codec:Codec<T>, hasher?:MultiHasher):Block
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment