MCPcopy Create free account
hub / github.com/CommE2E/comm / addInfo

Method addInfo

keyserver/src/utils/depth-queue.js:21–41  ·  view source on GitHub ↗
(info: T)

Source from the content-addressed store, hash-verified

19 }
20
21 addInfo(info: T): void {
22 const depth = this.getDepth(info);
23 if (depth <= this.maxDequeuedDepth) {
24 throw new Error(
25 `try to addInfo at depth ${depth} after having dequeued at depth ` +
26 this.maxDequeuedDepth,
27 );
28 }
29 let map = this.depthQueues.get(depth);
30 if (!map) {
31 map = new Map();
32 this.depthQueues.set(depth, map);
33 }
34 const key = this.getKey(info);
35 const curInfo = map.get(key);
36 const mergedInfo = curInfo ? this.mergeFunction(curInfo, info) : info;
37 map.set(key, mergedInfo);
38 if (depth > this.maxEnqueuedDepth) {
39 this.maxEnqueuedDepth = depth;
40 }
41 }
42
43 addInfos(infos: $ReadOnlyArray<T>) {
44 for (const info of infos) {

Callers 1

addInfosMethod · 0.95

Calls 3

getMethod · 0.65
getKeyMethod · 0.65
setMethod · 0.45

Tested by

no test coverage detected