@peerbit/stream 1.0.19 → 2.0.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/lib/esm/index.d.ts +82 -71
- package/lib/esm/index.js +643 -600
- package/lib/esm/index.js.map +1 -1
- package/lib/esm/logger.d.ts +1 -1
- package/lib/esm/logger.js +1 -1
- package/lib/esm/logger.js.map +1 -1
- package/lib/esm/metrics.d.ts +6 -25
- package/lib/esm/metrics.js +14 -58
- package/lib/esm/metrics.js.map +1 -1
- package/lib/esm/routes.d.ts +47 -35
- package/lib/esm/routes.js +214 -192
- package/lib/esm/routes.js.map +1 -1
- package/package.json +9 -13
- package/src/index.ts +976 -764
- package/src/logger.ts +1 -1
- package/src/metrics.ts +11 -63
- package/src/routes.ts +279 -228
- package/lib/esm/peer-map.d.ts +0 -1
- package/lib/esm/peer-map.js +0 -2
- package/lib/esm/peer-map.js.map +0 -1
- package/src/peer-map.ts +0 -1
package/lib/esm/routes.js
CHANGED
|
@@ -1,227 +1,249 @@
|
|
|
1
|
-
|
|
2
|
-
import { dijkstra, unweighted } from "graphology-shortest-path";
|
|
3
|
-
import { logger } from "./logger.js";
|
|
1
|
+
export const MAX_ROUTE_DISTANCE = Number.MAX_SAFE_INTEGER;
|
|
4
2
|
export class Routes {
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
3
|
+
me;
|
|
4
|
+
// END receiver -> Neighbour
|
|
5
|
+
routes = new Map();
|
|
6
|
+
pendingRoutes = new Map();
|
|
7
|
+
latestSession;
|
|
8
|
+
constructor(me) {
|
|
9
|
+
this.me = me;
|
|
10
|
+
this.latestSession = 0;
|
|
10
11
|
}
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
get nodeCount() {
|
|
15
|
-
return this.graph.nodes().length;
|
|
12
|
+
clear() {
|
|
13
|
+
this.routes.clear();
|
|
14
|
+
this.pendingRoutes.clear();
|
|
16
15
|
}
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
const toIsNowReachable = fromWasReachable;
|
|
33
|
-
const visited = new Set();
|
|
34
|
-
const newReachableNodes = [];
|
|
35
|
-
if (fromIsNowReachable) {
|
|
36
|
-
newReachableNodes.push(from);
|
|
16
|
+
add(from, neighbour, target, distance, session) {
|
|
17
|
+
let fromMap = this.routes.get(from);
|
|
18
|
+
if (!fromMap) {
|
|
19
|
+
fromMap = new Map();
|
|
20
|
+
this.routes.set(from, fromMap);
|
|
21
|
+
}
|
|
22
|
+
let prev = fromMap.get(target) || {
|
|
23
|
+
session: session ?? +new Date(),
|
|
24
|
+
list: []
|
|
25
|
+
};
|
|
26
|
+
this.latestSession = Math.max(this.latestSession, session);
|
|
27
|
+
if (session != null) {
|
|
28
|
+
// this condition means that when we add new routes in a session that is newer
|
|
29
|
+
if (prev.session < session) {
|
|
30
|
+
prev = { session, list: [] }; // reset route info how to reach this target
|
|
37
31
|
}
|
|
38
|
-
if (
|
|
39
|
-
|
|
32
|
+
else if (prev.session > session) {
|
|
33
|
+
return; // new routing information superseedes this
|
|
40
34
|
}
|
|
41
|
-
|
|
42
|
-
|
|
35
|
+
}
|
|
36
|
+
if (from === this.me && neighbour === target) {
|
|
37
|
+
// force distance to neighbour as targets to always favor directly sending to them
|
|
38
|
+
// i.e. if target is our neighbour, always assume the shortest path to them is the direct path
|
|
39
|
+
distance = -1;
|
|
40
|
+
}
|
|
41
|
+
for (const route of prev.list) {
|
|
42
|
+
if (route.hash === neighbour) {
|
|
43
|
+
route.distance = Math.min(route.distance, distance);
|
|
44
|
+
prev.list.sort((a, b) => a.distance - b.distance);
|
|
45
|
+
return;
|
|
43
46
|
}
|
|
44
|
-
|
|
45
|
-
|
|
47
|
+
}
|
|
48
|
+
prev.list.push({ distance, hash: neighbour });
|
|
49
|
+
prev.list.sort((a, b) => a.distance - b.distance);
|
|
50
|
+
fromMap.set(target, prev);
|
|
51
|
+
}
|
|
52
|
+
removeTarget(target) {
|
|
53
|
+
this.routes.delete(target);
|
|
54
|
+
for (const [fromMapKey, fromMap] of this.routes) {
|
|
55
|
+
// delete target
|
|
56
|
+
fromMap.delete(target);
|
|
57
|
+
if (fromMap.size === 0) {
|
|
58
|
+
this.routes.delete(fromMapKey);
|
|
46
59
|
}
|
|
47
|
-
|
|
48
|
-
|
|
60
|
+
}
|
|
61
|
+
return [target];
|
|
62
|
+
}
|
|
63
|
+
removeNeighbour(target) {
|
|
64
|
+
this.routes.delete(target);
|
|
65
|
+
const maybeUnreachable = new Set([target]);
|
|
66
|
+
for (const [fromMapKey, fromMap] of this.routes) {
|
|
67
|
+
// delete target
|
|
68
|
+
fromMap.delete(target);
|
|
69
|
+
// delete this as neighbour
|
|
70
|
+
for (const [remote, neighbours] of fromMap) {
|
|
71
|
+
neighbours.list = neighbours.list.filter((x) => x.hash !== target);
|
|
72
|
+
if (neighbours.list.length === 0) {
|
|
73
|
+
fromMap.delete(remote);
|
|
74
|
+
maybeUnreachable.add(remote);
|
|
75
|
+
}
|
|
49
76
|
}
|
|
50
|
-
if (
|
|
51
|
-
this.
|
|
77
|
+
if (fromMap.size === 0) {
|
|
78
|
+
this.routes.delete(fromMapKey);
|
|
52
79
|
}
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
if (attributes.time > currentTime) {
|
|
75
|
-
continue; // a new link has been added while we are iterating, dont follow this path
|
|
76
|
-
}
|
|
77
|
-
if (visited.has(neighbor)) {
|
|
78
|
-
continue;
|
|
79
|
-
}
|
|
80
|
-
stack.push(neighbor);
|
|
81
|
-
}
|
|
82
|
-
newReachableNodesFromOrigin.push(node);
|
|
83
|
-
}
|
|
80
|
+
}
|
|
81
|
+
return [...maybeUnreachable].filter((x) => !this.isReachable(this.me, x));
|
|
82
|
+
}
|
|
83
|
+
findNeighbor(from, target) {
|
|
84
|
+
return this.routes.get(from)?.get(target);
|
|
85
|
+
}
|
|
86
|
+
isReachable(from, target) {
|
|
87
|
+
return ((this.routes.get(from)?.get(target)?.list[0]?.distance ??
|
|
88
|
+
Number.MAX_SAFE_INTEGER) < MAX_ROUTE_DISTANCE);
|
|
89
|
+
}
|
|
90
|
+
hasShortestPath(target) {
|
|
91
|
+
const path = this.routes.get(this.me)?.get(target);
|
|
92
|
+
if (!path) {
|
|
93
|
+
return false;
|
|
94
|
+
}
|
|
95
|
+
return path.list[0].distance <= 0;
|
|
96
|
+
}
|
|
97
|
+
hasTarget(target) {
|
|
98
|
+
for (const [k, v] of this.routes) {
|
|
99
|
+
if (v.has(target)) {
|
|
100
|
+
return true;
|
|
84
101
|
}
|
|
85
102
|
}
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
103
|
+
return false;
|
|
104
|
+
}
|
|
105
|
+
getDependent(target) {
|
|
106
|
+
const dependent = [];
|
|
107
|
+
for (const [fromMapKey, fromMap] of this.routes) {
|
|
108
|
+
if (fromMapKey !== this.me && fromMap.has(target)) {
|
|
109
|
+
dependent.push(fromMapKey);
|
|
110
|
+
}
|
|
91
111
|
}
|
|
92
|
-
return
|
|
112
|
+
return dependent;
|
|
93
113
|
}
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
if (link) {
|
|
104
|
-
const date = +new Date();
|
|
105
|
-
const fromWasReachable = origin == from ||
|
|
106
|
-
this.getPath(origin, from, { unweighted: true }).length;
|
|
107
|
-
const toWasReachable = origin === to || this.getPath(origin, to, { unweighted: true }).length;
|
|
108
|
-
this.graph.dropEdge(link);
|
|
109
|
-
const unreachableNodesFromOrigin = [];
|
|
110
|
-
if (fromWasReachable &&
|
|
111
|
-
origin !== from &&
|
|
112
|
-
this.getPath(origin, from, { unweighted: true }).length === 0) {
|
|
113
|
-
unreachableNodesFromOrigin.push(from);
|
|
114
|
+
count(from = this.me) {
|
|
115
|
+
const set = new Set();
|
|
116
|
+
const map = this.routes.get(from);
|
|
117
|
+
if (map) {
|
|
118
|
+
for (const [k, v] of map) {
|
|
119
|
+
set.add(k);
|
|
120
|
+
for (const peer of v.list) {
|
|
121
|
+
set.add(peer.hash);
|
|
122
|
+
}
|
|
114
123
|
}
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
124
|
+
}
|
|
125
|
+
return set.size;
|
|
126
|
+
}
|
|
127
|
+
countAll() {
|
|
128
|
+
let size = 0;
|
|
129
|
+
for (const [from, map] of this.routes) {
|
|
130
|
+
for (const [k, v] of map) {
|
|
131
|
+
size += v.list.length;
|
|
119
132
|
}
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
133
|
+
}
|
|
134
|
+
return size;
|
|
135
|
+
}
|
|
136
|
+
// for all tos if
|
|
137
|
+
getFanout(from, tos, redundancy) {
|
|
138
|
+
if (tos.length === 0) {
|
|
139
|
+
return undefined;
|
|
140
|
+
}
|
|
141
|
+
let fanoutMap = undefined;
|
|
142
|
+
const fromKey = from.hashcode();
|
|
143
|
+
// Message to > 0
|
|
144
|
+
if (tos.length > 0) {
|
|
145
|
+
for (const to of tos) {
|
|
146
|
+
if (to === this.me || fromKey === to) {
|
|
147
|
+
continue; // don't send to me or backwards
|
|
125
148
|
}
|
|
126
|
-
const
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
}
|
|
134
|
-
if (visited.has(nodeId)) {
|
|
135
|
-
continue;
|
|
136
|
-
}
|
|
137
|
-
visited.add(nodeId);
|
|
138
|
-
const neighbors = this.graph.neighbors(node);
|
|
139
|
-
for (const neighbor of neighbors) {
|
|
140
|
-
const edge = this.graph.undirectedEdge(node, neighbor);
|
|
141
|
-
if (!edge) {
|
|
142
|
-
logger.warn(`Missing edge between: ${node} - ${neighbor}`);
|
|
143
|
-
continue;
|
|
149
|
+
const neighbour = this.findNeighbor(fromKey, to);
|
|
150
|
+
if (neighbour) {
|
|
151
|
+
let foundClosest = false;
|
|
152
|
+
for (let i = 0; i < Math.min(neighbour.list.length, redundancy); i++) {
|
|
153
|
+
const distance = neighbour.list[i].distance;
|
|
154
|
+
if (distance >= redundancy) {
|
|
155
|
+
break; // because neighbour listis sorted
|
|
144
156
|
}
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
continue; // don't follow path because this is a new link that might provide some new connectivity
|
|
157
|
+
if (distance <= 0) {
|
|
158
|
+
foundClosest = true;
|
|
148
159
|
}
|
|
149
|
-
|
|
150
|
-
|
|
160
|
+
const fanout = (fanoutMap || (fanoutMap = new Map())).get(neighbour.list[i].hash);
|
|
161
|
+
if (!fanout) {
|
|
162
|
+
fanoutMap.set(neighbour.list[i].hash, [
|
|
163
|
+
{ to, timestamp: neighbour.session }
|
|
164
|
+
]);
|
|
165
|
+
}
|
|
166
|
+
else {
|
|
167
|
+
fanout.push({ to, timestamp: neighbour.session });
|
|
151
168
|
}
|
|
152
|
-
stack.push(neighbor);
|
|
153
169
|
}
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
unreachableNodesFromOrigin.push(nodeId.toString());
|
|
170
|
+
if (!foundClosest && from.hashcode() === this.me) {
|
|
171
|
+
return undefined; // we dont have the shortest path to our target (yet). Send to all
|
|
157
172
|
}
|
|
173
|
+
continue;
|
|
158
174
|
}
|
|
175
|
+
// we can't find path, send message to all peers
|
|
176
|
+
return undefined;
|
|
159
177
|
}
|
|
160
|
-
|
|
178
|
+
}
|
|
179
|
+
return fanoutMap || (fanoutMap = new Map());
|
|
180
|
+
}
|
|
181
|
+
/**
|
|
182
|
+
* Returns a list of a prunable nodes that are not needed to reach all remote nodes
|
|
183
|
+
*/
|
|
184
|
+
getPrunable(neighbours) {
|
|
185
|
+
const map = this.routes.get(this.me);
|
|
186
|
+
if (map) {
|
|
187
|
+
// check if all targets can be reached without it
|
|
188
|
+
return neighbours.filter((candidate) => {
|
|
189
|
+
for (const [target, neighbours] of map) {
|
|
190
|
+
if (target !== candidate &&
|
|
191
|
+
neighbours.list.length === 1 &&
|
|
192
|
+
neighbours.list[0].hash === candidate) {
|
|
193
|
+
return false;
|
|
194
|
+
}
|
|
195
|
+
}
|
|
196
|
+
return true;
|
|
197
|
+
});
|
|
161
198
|
}
|
|
162
199
|
return [];
|
|
163
200
|
}
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
201
|
+
addPendingRouteConnection(session, route) {
|
|
202
|
+
let map = this.pendingRoutes.get(session);
|
|
203
|
+
if (!map) {
|
|
204
|
+
map = new Map();
|
|
205
|
+
this.pendingRoutes.set(session, map);
|
|
167
206
|
}
|
|
168
|
-
|
|
169
|
-
if (
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
.inboundNeighbors(blockId)
|
|
196
|
-
.map((x) => this.graph.edges(x, blockId))
|
|
197
|
-
.flat());
|
|
198
|
-
getEdgeWeight = (edge) => {
|
|
199
|
-
if (neighBourEdges.has(edge)) {
|
|
200
|
-
return Number.MAX_SAFE_INTEGER;
|
|
201
|
-
}
|
|
202
|
-
return this.graph.getEdgeAttribute(edge, "weight");
|
|
203
|
-
};
|
|
207
|
+
let arr = map.get(route.target);
|
|
208
|
+
if (!arr) {
|
|
209
|
+
arr = [];
|
|
210
|
+
map.set(route.target, arr);
|
|
211
|
+
}
|
|
212
|
+
arr.push(route);
|
|
213
|
+
const neighbour = this.findNeighbor(route.from, route.target);
|
|
214
|
+
if (!neighbour || neighbour.session === session) {
|
|
215
|
+
// Commit directly since we dont have any data at all (better have something than nothing)
|
|
216
|
+
this.commitPendingRouteConnection(session, route.target);
|
|
217
|
+
}
|
|
218
|
+
}
|
|
219
|
+
// always commit if we dont know the peer yet
|
|
220
|
+
// do pending commits per remote (?)
|
|
221
|
+
commitPendingRouteConnection(session, target) {
|
|
222
|
+
const map = this.pendingRoutes.get(session);
|
|
223
|
+
if (!map) {
|
|
224
|
+
return;
|
|
225
|
+
}
|
|
226
|
+
if (target) {
|
|
227
|
+
const routes = map.get(target);
|
|
228
|
+
if (routes) {
|
|
229
|
+
for (const route of routes) {
|
|
230
|
+
this.add(route.from, route.neighbour, target, route.distance, session);
|
|
231
|
+
}
|
|
232
|
+
map.delete(target);
|
|
233
|
+
return;
|
|
204
234
|
}
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
? unweighted.bidirectional(this.graph, from, to)
|
|
208
|
-
: dijkstra.bidirectional(this.graph, from, to, getEdgeWeight)) || [];
|
|
209
|
-
if (path?.length > 0 && path[0] !== from) {
|
|
210
|
-
path.reverse();
|
|
235
|
+
else {
|
|
236
|
+
return;
|
|
211
237
|
}
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
238
|
+
}
|
|
239
|
+
else {
|
|
240
|
+
for (const [target, routes] of map) {
|
|
241
|
+
for (const route of routes) {
|
|
242
|
+
this.add(route.from, route.neighbour, target, route.distance, session);
|
|
215
243
|
}
|
|
216
244
|
}
|
|
217
|
-
return path; // TODO fix types
|
|
218
245
|
}
|
|
219
|
-
|
|
220
|
-
return [];
|
|
221
|
-
}
|
|
222
|
-
}
|
|
223
|
-
clear() {
|
|
224
|
-
this.graph.clear();
|
|
246
|
+
this.pendingRoutes.delete(session);
|
|
225
247
|
}
|
|
226
248
|
}
|
|
227
249
|
//# sourceMappingURL=routes.js.map
|
package/lib/esm/routes.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"routes.js","sourceRoot":"","sources":["../../src/routes.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"routes.js","sourceRoot":"","sources":["../../src/routes.ts"],"names":[],"mappings":"AAEA,MAAM,CAAC,MAAM,kBAAkB,GAAG,MAAM,CAAC,gBAAgB,CAAC;AAC1D,MAAM,OAAO,MAAM;IAqBG;IApBrB,4BAA4B;IAE5B,MAAM,GAGF,IAAI,GAAG,EAAE,CAAC;IAEd,aAAa,GAUT,IAAI,GAAG,EAAE,CAAC;IACd,aAAa,CAAS;IAEtB,YAAqB,EAAU;QAAV,OAAE,GAAF,EAAE,CAAQ;QAC9B,IAAI,CAAC,aAAa,GAAG,CAAC,CAAC;IACxB,CAAC;IAED,KAAK;QACJ,IAAI,CAAC,MAAM,CAAC,KAAK,EAAE,CAAC;QACpB,IAAI,CAAC,aAAa,CAAC,KAAK,EAAE,CAAC;IAC5B,CAAC;IAED,GAAG,CACF,IAAY,EACZ,SAAiB,EACjB,MAAc,EACd,QAAgB,EAChB,OAAe;QAEf,IAAI,OAAO,GAAG,IAAI,CAAC,MAAM,CAAC,GAAG,CAAC,IAAI,CAAC,CAAC;QACpC,IAAI,CAAC,OAAO,EAAE,CAAC;YACd,OAAO,GAAG,IAAI,GAAG,EAAE,CAAC;YACpB,IAAI,CAAC,MAAM,CAAC,GAAG,CAAC,IAAI,EAAE,OAAO,CAAC,CAAC;QAChC,CAAC;QAED,IAAI,IAAI,GAAG,OAAO,CAAC,GAAG,CAAC,MAAM,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AM,EAAE,CAAC;gBACZ,KAAK,MAAM,KAAK,IAAI,MAAM,EAAE,CAAC;oBAC5B,IAAI,CAAC,GAAG,CACP,KAAK,CAAC,IAAI,EACV,KAAK,CAAC,SAAS,EACf,MAAM,EACN,KAAK,CAAC,QAAQ,EACd,OAAO,CACP,CAAC;gBACH,CAAC;gBACD,GAAG,CAAC,MAAM,CAAC,MAAM,CAAC,CAAC;gBACnB,OAAO;YACR,CAAC;iBAAM,CAAC;gBACP,OAAO;YACR,CAAC;QACF,CAAC;aAAM,CAAC;YACP,KAAK,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,IAAI,GAAG,EAAE,CAAC;gBACpC,KAAK,MAAM,KAAK,IAAI,MAAM,EAAE,CAAC;oBAC5B,IAAI,CAAC,GAAG,CACP,KAAK,CAAC,IAAI,EACV,KAAK,CAAC,SAAS,EACf,MAAM,EACN,KAAK,CAAC,QAAQ,EACd,OAAO,CACP,CAAC;gBACH,CAAC;YACF,CAAC;QACF,CAAC;QAED,IAAI,CAAC,aAAa,CAAC,MAAM,CAAC,OAAO,CAAC,CAAC;IACpC,CAAC;CACD"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@peerbit/stream",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "2.0.1",
|
|
4
4
|
"description": "A building block for direct streaming protocols",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"sideEffects": false,
|
|
@@ -50,21 +50,17 @@
|
|
|
50
50
|
"dao.xyz"
|
|
51
51
|
],
|
|
52
52
|
"devDependencies": {
|
|
53
|
-
"@peerbit/libp2p-test-utils": "
|
|
54
|
-
"@types/yallist": "^4.0.1"
|
|
55
|
-
"graphology-types": "^0.24.7"
|
|
53
|
+
"@peerbit/libp2p-test-utils": "2.0.0",
|
|
54
|
+
"@types/yallist": "^4.0.1"
|
|
56
55
|
},
|
|
57
56
|
"dependencies": {
|
|
58
57
|
"@dao-xyz/borsh": "^5.1.8",
|
|
59
|
-
"@peerbit/cache": "
|
|
60
|
-
"@peerbit/crypto": "
|
|
61
|
-
"@peerbit/stream-interface": "^
|
|
62
|
-
"
|
|
63
|
-
"
|
|
64
|
-
"graphology-shortest-path": "2.0.2",
|
|
65
|
-
"libp2p": "0.46.9",
|
|
66
|
-
"memory-level": "^1.0.0",
|
|
58
|
+
"@peerbit/cache": "2.0.0",
|
|
59
|
+
"@peerbit/crypto": "2.0.0",
|
|
60
|
+
"@peerbit/stream-interface": "^2.0.0",
|
|
61
|
+
"abortable-iterator": "^5.0.1",
|
|
62
|
+
"libp2p": "^1.1.0",
|
|
67
63
|
"yallist": "^4.0.0"
|
|
68
64
|
},
|
|
69
|
-
"gitHead": "
|
|
65
|
+
"gitHead": "c48cb37d237a25b0bcc849482b43f6941d53e3d5"
|
|
70
66
|
}
|