@olane/o-node 0.7.12-alpha.70 → 0.7.12-alpha.72
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.
|
@@ -7,6 +7,7 @@ export declare class oNodeConnectionManager extends oConnectionManager {
|
|
|
7
7
|
protected p2pNode: Libp2p;
|
|
8
8
|
private defaultReadTimeoutMs?;
|
|
9
9
|
private defaultDrainTimeoutMs?;
|
|
10
|
+
private connections;
|
|
10
11
|
constructor(config: oNodeConnectionManagerConfig);
|
|
11
12
|
getOrCreateConnection(nextHopAddress: oAddress, address: oAddress): Promise<Connection>;
|
|
12
13
|
/**
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"o-node-connection.manager.d.ts","sourceRoot":"","sources":["../../../src/connection/o-node-connection.manager.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,iBAAiB,EAAE,kBAAkB,EAAE,MAAM,eAAe,CAAC;AAChF,OAAO,EAAE,MAAM,EAAE,UAAU,EAAU,MAAM,iBAAiB,CAAC;AAC7D,OAAO,EAAE,4BAA4B,EAAE,MAAM,kDAAkD,CAAC;AAEhG,OAAO,EAAE,eAAe,EAAE,MAAM,wBAAwB,CAAC;AAGzD,qBAAa,sBAAuB,SAAQ,kBAAkB;
|
|
1
|
+
{"version":3,"file":"o-node-connection.manager.d.ts","sourceRoot":"","sources":["../../../src/connection/o-node-connection.manager.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,iBAAiB,EAAE,kBAAkB,EAAE,MAAM,eAAe,CAAC;AAChF,OAAO,EAAE,MAAM,EAAE,UAAU,EAAU,MAAM,iBAAiB,CAAC;AAC7D,OAAO,EAAE,4BAA4B,EAAE,MAAM,kDAAkD,CAAC;AAEhG,OAAO,EAAE,eAAe,EAAE,MAAM,wBAAwB,CAAC;AAGzD,qBAAa,sBAAuB,SAAQ,kBAAkB;IAMhD,QAAQ,CAAC,MAAM,EAAE,4BAA4B;IALzD,SAAS,CAAC,OAAO,EAAE,MAAM,CAAC;IAC1B,OAAO,CAAC,oBAAoB,CAAC,CAAS;IACtC,OAAO,CAAC,qBAAqB,CAAC,CAAS;IACvC,OAAO,CAAC,WAAW,CAAsC;gBAEpC,MAAM,EAAE,4BAA4B;IAOnD,qBAAqB,CACzB,cAAc,EAAE,QAAQ,EACxB,OAAO,EAAE,QAAQ,GAChB,OAAO,CAAC,UAAU,CAAC;IA6BtB;;;;OAIG;IACG,OAAO,CAAC,MAAM,EAAE,iBAAiB,GAAG,OAAO,CAAC,eAAe,CAAC;IA8BlE;;;;OAIG;IACH,QAAQ,CAAC,OAAO,EAAE,QAAQ,GAAG,OAAO;IA4BpC;;;;OAIG;IACH,yBAAyB,CAAC,OAAO,EAAE,QAAQ,GAAG,UAAU,GAAG,IAAI;CAehE"}
|
|
@@ -4,6 +4,7 @@ export class oNodeConnectionManager extends oConnectionManager {
|
|
|
4
4
|
constructor(config) {
|
|
5
5
|
super(config);
|
|
6
6
|
this.config = config;
|
|
7
|
+
this.connections = new Map();
|
|
7
8
|
this.p2pNode = config.p2pNode;
|
|
8
9
|
this.defaultReadTimeoutMs = config.defaultReadTimeoutMs;
|
|
9
10
|
this.defaultDrainTimeoutMs = config.defaultDrainTimeoutMs;
|
|
@@ -22,6 +23,7 @@ export class oNodeConnectionManager extends oConnectionManager {
|
|
|
22
23
|
this.logger.debug('Dialing new connection for address: ' + address.toString());
|
|
23
24
|
p2pConnection = await this.p2pNode.dial(nextHopAddress.libp2pTransports.map((ma) => ma.toMultiaddr()));
|
|
24
25
|
}
|
|
26
|
+
this.connections.set(nextHopAddress.toString(), p2pConnection);
|
|
25
27
|
return p2pConnection;
|
|
26
28
|
}
|
|
27
29
|
/**
|
|
@@ -82,19 +84,12 @@ export class oNodeConnectionManager extends oConnectionManager {
|
|
|
82
84
|
getCachedLibp2pConnection(address) {
|
|
83
85
|
try {
|
|
84
86
|
const nodeAddress = address;
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
return
|
|
87
|
+
const connection = this.connections.get(nodeAddress.toString());
|
|
88
|
+
if (connection?.status === 'open') {
|
|
89
|
+
return connection;
|
|
88
90
|
}
|
|
89
|
-
// Extract peer ID from the first transport
|
|
90
|
-
const peerIdString = nodeAddress.libp2pTransports[0].toPeerId();
|
|
91
|
-
if (!peerIdString) {
|
|
92
|
-
return null;
|
|
93
|
-
}
|
|
94
|
-
const connections = this.p2pNode.getConnections(peerIdString); // ignore since converting to a proper peer id breaks the browser implementation
|
|
95
91
|
// Return the first open connection, or null if none exist
|
|
96
|
-
|
|
97
|
-
return openConnection || null;
|
|
92
|
+
return connection ?? null;
|
|
98
93
|
}
|
|
99
94
|
catch (error) {
|
|
100
95
|
this.logger.debug('Error getting cached connection:', error);
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@olane/o-node",
|
|
3
|
-
"version": "0.7.12-alpha.
|
|
3
|
+
"version": "0.7.12-alpha.72",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"main": "dist/src/index.js",
|
|
6
6
|
"types": "dist/src/index.d.ts",
|
|
@@ -54,12 +54,12 @@
|
|
|
54
54
|
"typescript": "5.4.5"
|
|
55
55
|
},
|
|
56
56
|
"dependencies": {
|
|
57
|
-
"@olane/o-config": "0.7.12-alpha.
|
|
58
|
-
"@olane/o-core": "0.7.12-alpha.
|
|
59
|
-
"@olane/o-protocol": "0.7.12-alpha.
|
|
60
|
-
"@olane/o-tool": "0.7.12-alpha.
|
|
57
|
+
"@olane/o-config": "0.7.12-alpha.72",
|
|
58
|
+
"@olane/o-core": "0.7.12-alpha.72",
|
|
59
|
+
"@olane/o-protocol": "0.7.12-alpha.72",
|
|
60
|
+
"@olane/o-tool": "0.7.12-alpha.72",
|
|
61
61
|
"debug": "^4.4.1",
|
|
62
62
|
"dotenv": "^16.5.0"
|
|
63
63
|
},
|
|
64
|
-
"gitHead": "
|
|
64
|
+
"gitHead": "69b76ea2f2298b8487235c4e5eb882fc6372d8b9"
|
|
65
65
|
}
|