MCPcopy
hub / github.com/evoluhq/evolu / insertIntoMerkleTree

Function insertIntoMerkleTree

packages/evolu/src/MerkleTree.ts:46–52  ·  view source on GitHub ↗
(timestamp: Timestamp)

Source from the content-addressed store, hash-verified

44
45export const insertIntoMerkleTree =
46 (timestamp: Timestamp) =>
47 (tree: MerkleTree): MerkleTree => {
48 const key = timestampToKey(timestamp);
49 const hash = timestampToHash(timestamp);
50 // @ts-expect-error undefined is OK
51 return insertKey({ ...tree, hash: tree.hash ^ hash }, key, hash);
52 };
53
54const keyToTimestamp = (key: string): Millis =>
55 (parseInt(key.length > 0 ? key : "0", 3) * 1000 * 60) as Millis;

Callers 5

addMessagesFunction · 0.90
MerkleTree.test.tsFile · 0.85
addTo1Function · 0.85
addTo2Function · 0.85
applyMessagesFunction · 0.85

Calls 3

timestampToKeyFunction · 0.85
timestampToHashFunction · 0.85
insertKeyFunction · 0.85

Tested by 2

addTo1Function · 0.68
addTo2Function · 0.68