Skip to content

Instantly share code, notes, and snippets.

View dmaretskyi's full-sized avatar
🎯
Focusing

Dmytro Maretskyi dmaretskyi

🎯
Focusing
View GitHub Profile
const createStore = <T,> (initialValue: T): T => {
return initialValue;
}
type S<T> = T
interface Atom<T> {
// Get
(): T
}

Merkle Tree

https://en.wikipedia.org/wiki/Merkle_tree

image

A Merkle tree is a binary tree where each node's value is calculated by hashing both of it's child leaves: sha256(left_child + right_child). Uninitialized leafs should have the value of a hash of an empty string: sha256('').

Task

Merkle Tree

https://en.wikipedia.org/wiki/Merkle_tree

image

A Merkle tree is a binary tree where each node's value is calculated by concatenating and hashing both of it's child leaves: sha256(left_child + right_child). Uninitialized leafs should have the value of a hash of an empty string: sha256('').

Example

/**
* An EventEmitter variant that does not do event multiplexing and respresents a single event.
*
* ## Typical usage:
* ```javascript
* class Model {
* public readonly update = new Event<UpdateData>();
* private readonly privateEvent = new Event<void>();
*
* onUpdate(data: UpdateData) {
/**
* @typedef SecretProvider
*/
/**
* Drives a FeedStore such that messages received on that FeedStore's message stream
* correspond to the messages from the open Parties. Provides access to ancillary
* services: Identity management, Device management, Party invitation and greeting.
*
* @event PartyManager#'party' fires when a Party is added to the manager (whether a newly created Party, one joined
* on another device, or one loaded from storage)