Created
August 12, 2020 17:27
-
-
Save Gozala/df4764a57ff5497334afdd3b3296070a to your computer and use it in GitHub Desktop.
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
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