@olane/o-node 0.7.12-alpha.71 → 0.7.12-alpha.73
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;IAoCtB;;;;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;CAuBhE"}
|
|
@@ -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,12 @@ 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
|
+
if (nextHopAddress.libp2pTransports.length) {
|
|
27
|
+
const peerIdString = nextHopAddress.libp2pTransports[0].toPeerId();
|
|
28
|
+
if (peerIdString) {
|
|
29
|
+
this.connections.set(peerIdString, p2pConnection);
|
|
30
|
+
}
|
|
31
|
+
}
|
|
25
32
|
return p2pConnection;
|
|
26
33
|
}
|
|
27
34
|
/**
|
|
@@ -82,20 +89,19 @@ export class oNodeConnectionManager extends oConnectionManager {
|
|
|
82
89
|
getCachedLibp2pConnection(address) {
|
|
83
90
|
try {
|
|
84
91
|
const nodeAddress = address;
|
|
85
|
-
if (!nodeAddress.libp2pTransports
|
|
86
|
-
nodeAddress.libp2pTransports.length === 0) {
|
|
92
|
+
if (!nodeAddress.libp2pTransports.length) {
|
|
87
93
|
return null;
|
|
88
94
|
}
|
|
89
|
-
// Extract peer ID from the first transport
|
|
90
95
|
const peerIdString = nodeAddress.libp2pTransports[0].toPeerId();
|
|
91
96
|
if (!peerIdString) {
|
|
92
97
|
return null;
|
|
93
98
|
}
|
|
94
|
-
const
|
|
95
|
-
|
|
99
|
+
const connection = this.connections.get(peerIdString);
|
|
100
|
+
if (connection?.status === 'open') {
|
|
101
|
+
return connection;
|
|
102
|
+
}
|
|
96
103
|
// Return the first open connection, or null if none exist
|
|
97
|
-
|
|
98
|
-
return openConnection || null;
|
|
104
|
+
return connection ?? null;
|
|
99
105
|
}
|
|
100
106
|
catch (error) {
|
|
101
107
|
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.73",
|
|
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.73",
|
|
58
|
+
"@olane/o-core": "0.7.12-alpha.73",
|
|
59
|
+
"@olane/o-protocol": "0.7.12-alpha.73",
|
|
60
|
+
"@olane/o-tool": "0.7.12-alpha.73",
|
|
61
61
|
"debug": "^4.4.1",
|
|
62
62
|
"dotenv": "^16.5.0"
|
|
63
63
|
},
|
|
64
|
-
"gitHead": "
|
|
64
|
+
"gitHead": "1fc100e9f575b957c9d6c6480eb3a3db10999e94"
|
|
65
65
|
}
|