@streamr/dht 100.0.0 → 100.1.0
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/dist/package.json +6 -6
- package/dist/src/connection/ConnectionLockRpcLocal.d.ts +1 -1
- package/dist/src/connection/ConnectionLockRpcRemote.d.ts +1 -1
- package/dist/src/connection/ConnectionLockRpcRemote.js +1 -1
- package/dist/src/connection/ConnectionLockRpcRemote.js.map +1 -1
- package/dist/src/connection/{ConnectionLockHandler.d.ts → ConnectionLockStates.d.ts} +1 -1
- package/dist/src/connection/{ConnectionLockHandler.js → ConnectionLockStates.js} +4 -4
- package/dist/src/connection/ConnectionLockStates.js.map +1 -0
- package/dist/src/connection/ConnectionManager.d.ts +5 -3
- package/dist/src/connection/ConnectionManager.js +8 -11
- package/dist/src/connection/ConnectionManager.js.map +1 -1
- package/dist/src/connection/ConnectorFacade.js +1 -1
- package/dist/src/connection/ConnectorFacade.js.map +1 -1
- package/dist/src/connection/ManagedConnection.d.ts +2 -2
- package/dist/src/connection/ManagedConnection.js +8 -8
- package/dist/src/connection/ManagedConnection.js.map +1 -1
- package/dist/src/connection/connectivityChecker.js +3 -3
- package/dist/src/connection/connectivityChecker.js.map +1 -1
- package/dist/src/connection/connectivityRequestHandler.js +4 -4
- package/dist/src/connection/connectivityRequestHandler.js.map +1 -1
- package/dist/src/connection/websocket/AbstractWebsocketClientConnection.d.ts +28 -0
- package/dist/src/connection/websocket/{ClientWebsocket.js → AbstractWebsocketClientConnection.js} +42 -68
- package/dist/src/connection/websocket/AbstractWebsocketClientConnection.js.map +1 -0
- package/dist/src/connection/websocket/NodeWebsocketClientConnection.d.ts +7 -0
- package/dist/src/connection/websocket/NodeWebsocketClientConnection.js +39 -0
- package/dist/src/connection/websocket/NodeWebsocketClientConnection.js.map +1 -0
- package/dist/src/connection/websocket/WebsocketConnector.js +3 -3
- package/dist/src/connection/websocket/WebsocketConnector.js.map +1 -1
- package/dist/src/connection/websocket/WebsocketServerConnection.js +3 -3
- package/dist/src/connection/websocket/WebsocketServerConnection.js.map +1 -1
- package/dist/src/dht/DhtNode.d.ts +2 -2
- package/dist/src/dht/DhtNode.js +12 -16
- package/dist/src/dht/DhtNode.js.map +1 -1
- package/dist/src/dht/DhtNodeRpcRemote.js +1 -1
- package/dist/src/dht/DhtNodeRpcRemote.js.map +1 -1
- package/dist/src/dht/PeerManager.d.ts +4 -4
- package/dist/src/dht/PeerManager.js +33 -44
- package/dist/src/dht/PeerManager.js.map +1 -1
- package/dist/src/dht/contact/SortedContactList.d.ts +2 -1
- package/dist/src/dht/contact/SortedContactList.js +19 -17
- package/dist/src/dht/contact/SortedContactList.js.map +1 -1
- package/dist/src/dht/discovery/DiscoverySession.js +3 -1
- package/dist/src/dht/discovery/DiscoverySession.js.map +1 -1
- package/dist/src/dht/discovery/PeerDiscovery.d.ts +2 -2
- package/dist/src/dht/discovery/PeerDiscovery.js +6 -4
- package/dist/src/dht/discovery/PeerDiscovery.js.map +1 -1
- package/dist/src/dht/discovery/RingDiscoverySession.js +3 -1
- package/dist/src/dht/discovery/RingDiscoverySession.js.map +1 -1
- package/dist/src/dht/recursive-operation/RecursiveOperationManager.js +1 -1
- package/dist/src/dht/recursive-operation/RecursiveOperationManager.js.map +1 -1
- package/dist/src/dht/recursive-operation/RecursiveOperationRpcRemote.js +1 -1
- package/dist/src/dht/recursive-operation/RecursiveOperationRpcRemote.js.map +1 -1
- package/dist/src/dht/routing/Router.d.ts +0 -1
- package/dist/src/dht/routing/Router.js +0 -1
- package/dist/src/dht/routing/Router.js.map +1 -1
- package/dist/src/dht/routing/RouterRpcLocal.d.ts +0 -1
- package/dist/src/dht/routing/RouterRpcLocal.js.map +1 -1
- package/dist/src/dht/routing/RouterRpcRemote.js +2 -2
- package/dist/src/dht/routing/RouterRpcRemote.js.map +1 -1
- package/dist/src/dht/routing/RoutingSession.js +2 -2
- package/dist/src/dht/routing/RoutingSession.js.map +1 -1
- package/dist/src/dht/store/LocalDataStore.js +2 -2
- package/dist/src/dht/store/LocalDataStore.js.map +1 -1
- package/dist/src/dht/store/StoreManager.js +1 -1
- package/dist/src/dht/store/StoreManager.js.map +1 -1
- package/dist/src/exports.d.ts +2 -2
- package/dist/src/exports.js +3 -3
- package/dist/src/exports.js.map +1 -1
- package/karma.config.js +4 -1
- package/package.json +6 -6
- package/src/connection/ConnectionLockRpcLocal.ts +1 -1
- package/src/connection/ConnectionLockRpcRemote.ts +2 -2
- package/src/connection/{ConnectionLockHandler.ts → ConnectionLockStates.ts} +1 -1
- package/src/connection/ConnectionManager.ts +11 -12
- package/src/connection/ConnectorFacade.ts +1 -1
- package/src/connection/ManagedConnection.ts +8 -8
- package/src/connection/connectivityChecker.ts +3 -3
- package/src/connection/connectivityRequestHandler.ts +4 -4
- package/src/connection/webrtc/BrowserWebrtcConnection.ts +18 -0
- package/src/connection/websocket/{ClientWebsocket.ts → AbstractWebsocketClientConnection.ts} +57 -70
- package/src/connection/websocket/BrowserWebsocketClientConnection.ts +44 -0
- package/src/connection/websocket/NodeWebsocketClientConnection.ts +39 -0
- package/src/connection/websocket/WebsocketConnector.ts +3 -3
- package/src/connection/websocket/WebsocketServerConnection.ts +1 -1
- package/src/dht/DhtNode.ts +13 -16
- package/src/dht/DhtNodeRpcRemote.ts +1 -1
- package/src/dht/PeerManager.ts +36 -46
- package/src/dht/contact/SortedContactList.ts +22 -18
- package/src/dht/discovery/DiscoverySession.ts +3 -1
- package/src/dht/discovery/PeerDiscovery.ts +8 -6
- package/src/dht/discovery/RingDiscoverySession.ts +3 -1
- package/src/dht/recursive-operation/RecursiveOperationManager.ts +1 -1
- package/src/dht/recursive-operation/RecursiveOperationRpcRemote.ts +1 -1
- package/src/dht/routing/Router.ts +0 -2
- package/src/dht/routing/RouterRpcLocal.ts +0 -1
- package/src/dht/routing/RouterRpcRemote.ts +2 -2
- package/src/dht/routing/RoutingSession.ts +2 -2
- package/src/dht/store/LocalDataStore.ts +1 -1
- package/src/dht/store/StoreManager.ts +1 -1
- package/src/exports.ts +2 -2
- package/test/benchmark/WebsocketServerMemoryLeak.test.ts +2 -2
- package/test/integration/Find.test.ts +2 -2
- package/test/integration/ReplicateData.test.ts +3 -3
- package/test/integration/Store.test.ts +2 -2
- package/test/integration/StoreAndDelete.test.ts +2 -2
- package/test/integration/Websocket.test.ts +2 -2
- package/test/unit/PeerManager.test.ts +42 -11
- package/test/unit/Router.test.ts +0 -1
- package/test/utils/utils.ts +17 -37
- package/tsconfig.browser.json +2 -1
- package/tsconfig.jest.json +2 -1
- package/tsconfig.node.json +2 -1
- package/dist/src/connection/ConnectionLockHandler.js.map +0 -1
- package/dist/src/connection/websocket/ClientWebsocket.d.ts +0 -17
- package/dist/src/connection/websocket/ClientWebsocket.js.map +0 -1
- package/dist/src/helpers/MapWithTtl.d.ts +0 -14
- package/dist/src/helpers/MapWithTtl.js +0 -60
- package/dist/src/helpers/MapWithTtl.js.map +0 -1
- package/src/helpers/MapWithTtl.ts +0 -71
|
@@ -1,71 +0,0 @@
|
|
|
1
|
-
interface ValueWrapper<V> {
|
|
2
|
-
value: V
|
|
3
|
-
timeout: NodeJS.Timeout
|
|
4
|
-
}
|
|
5
|
-
|
|
6
|
-
export class MapWithTtl<K, V> {
|
|
7
|
-
|
|
8
|
-
private readonly delegate: Map<K, ValueWrapper<V>> = new Map()
|
|
9
|
-
private readonly getTtl: (value: V) => number
|
|
10
|
-
|
|
11
|
-
constructor(getTtl: (value: V) => number) {
|
|
12
|
-
this.getTtl = getTtl
|
|
13
|
-
}
|
|
14
|
-
|
|
15
|
-
set(key: K, value: V): void {
|
|
16
|
-
const existing = this.delegate.get(key)
|
|
17
|
-
if (existing !== undefined) {
|
|
18
|
-
clearTimeout(existing.timeout)
|
|
19
|
-
}
|
|
20
|
-
this.delegate.set(key, {
|
|
21
|
-
value,
|
|
22
|
-
timeout: this.createTimeout(key, value)
|
|
23
|
-
})
|
|
24
|
-
}
|
|
25
|
-
|
|
26
|
-
get(key: K): V | undefined {
|
|
27
|
-
const wrapper = this.delegate.get(key)
|
|
28
|
-
return wrapper?.value
|
|
29
|
-
}
|
|
30
|
-
|
|
31
|
-
has(key: K): boolean {
|
|
32
|
-
return this.delegate.has(key)
|
|
33
|
-
}
|
|
34
|
-
|
|
35
|
-
delete(key: K): void {
|
|
36
|
-
const existing = this.delegate.get(key)
|
|
37
|
-
if (existing !== undefined) {
|
|
38
|
-
clearTimeout(existing.timeout)
|
|
39
|
-
this.delegate.delete(key)
|
|
40
|
-
}
|
|
41
|
-
}
|
|
42
|
-
|
|
43
|
-
clear(): void {
|
|
44
|
-
this.delegate.forEach((value) => {
|
|
45
|
-
clearTimeout(value.timeout)
|
|
46
|
-
})
|
|
47
|
-
this.delegate.clear()
|
|
48
|
-
}
|
|
49
|
-
|
|
50
|
-
size(): number {
|
|
51
|
-
return this.delegate.size
|
|
52
|
-
}
|
|
53
|
-
|
|
54
|
-
*values(): IterableIterator<V> {
|
|
55
|
-
for (const v of this.delegate.values()) {
|
|
56
|
-
yield v.value
|
|
57
|
-
}
|
|
58
|
-
}
|
|
59
|
-
|
|
60
|
-
forEach(cb: (value: V, key: K) => void): void {
|
|
61
|
-
this.delegate.forEach((valueWrapper: ValueWrapper<V>, key: K) => {
|
|
62
|
-
cb(valueWrapper.value, key)
|
|
63
|
-
})
|
|
64
|
-
}
|
|
65
|
-
|
|
66
|
-
private createTimeout(key: K, value: V): NodeJS.Timeout {
|
|
67
|
-
return setTimeout(() => {
|
|
68
|
-
this.delete(key)
|
|
69
|
-
}, this.getTtl(value))
|
|
70
|
-
}
|
|
71
|
-
}
|