@olane/o-node 0.7.49 → 0.7.50
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/src/interfaces/i-registrable-node.d.ts +7 -0
- package/dist/src/interfaces/i-registrable-node.d.ts.map +1 -1
- package/dist/src/managers/o-registration.manager.d.ts.map +1 -1
- package/dist/src/managers/o-registration.manager.js +11 -1
- package/dist/src/o-node.tool.d.ts.map +1 -1
- package/dist/src/o-node.tool.js +16 -13
- package/package.json +7 -7
|
@@ -4,6 +4,9 @@ import { oNodeAddress } from '../router/o-node.address.js';
|
|
|
4
4
|
import { oNodeConfig } from './o-node.config.js';
|
|
5
5
|
import { oNodeTransport } from '../router/o-node.transport.js';
|
|
6
6
|
import { oNodeHierarchyManager } from '../o-node.hierarchy-manager.js';
|
|
7
|
+
export interface IReconnectionManager {
|
|
8
|
+
waitForParentAndReconnect(): Promise<void>;
|
|
9
|
+
}
|
|
7
10
|
/**
|
|
8
11
|
* Interface for nodes that support registration management.
|
|
9
12
|
* This interface defines the contract that oRegistrationManager needs
|
|
@@ -50,6 +53,10 @@ export interface IRegistrableNode {
|
|
|
50
53
|
* Hierarchy manager for tracking parent/child/leader relationships
|
|
51
54
|
*/
|
|
52
55
|
hierarchyManager: oNodeHierarchyManager;
|
|
56
|
+
/**
|
|
57
|
+
* Reconnection manager for handling parent discovery
|
|
58
|
+
*/
|
|
59
|
+
reconnectionManager?: IReconnectionManager;
|
|
53
60
|
/**
|
|
54
61
|
* Execute a method on another node
|
|
55
62
|
*/
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"i-registrable-node.d.ts","sourceRoot":"","sources":["../../../src/interfaces/i-registrable-node.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,QAAQ,EAAE,MAAM,eAAe,CAAC;AACnD,OAAO,EAAE,MAAM,EAAE,MAAM,iBAAiB,CAAC;AACzC,OAAO,EAAE,YAAY,EAAE,MAAM,6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AAC;IAE3C;;OAEG;IACH,GAAG,CACD,OAAO,EAAE,QAAQ,EACjB,IAAI,CAAC,EAAE;QACL,MAAM,CAAC,EAAE,MAAM,CAAC;QAChB,MAAM,CAAC,EAAE;YAAE,CAAC,GAAG,EAAE,MAAM,GAAG,GAAG,CAAA;SAAE,CAAC;QAChC,EAAE,CAAC,EAAE,MAAM,CAAC;KACb,GACA,OAAO,CAAC,GAAG,CAAC,CAAC;IAEhB;;OAEG;IACH,eAAe,CAAC,OAAO,EAAE,YAAY,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC;CACvD"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"o-registration.manager.d.ts","sourceRoot":"","sources":["../../../src/managers/o-registration.manager.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,OAAO,EAIR,MAAM,eAAe,CAAC;AACvB,OAAO,EAAE,gBAAgB,EAAE,MAAM,qCAAqC,CAAC;AAGvE,MAAM,MAAM,iBAAiB,GACzB,gBAAgB,GAChB,aAAa,GACb,YAAY,GACZ,QAAQ,CAAC;AAEb,MAAM,WAAW,kBAAkB;IACjC,MAAM,EAAE,iBAAiB,CAAC;IAC1B,MAAM,EAAE,iBAAiB,CAAC;IAC1B,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,WAAW,CAAC,EAAE,MAAM,CAAC;CACtB;AAED;;;;;;;;;;;;GAYG;AACH,qBAAa,oBAAqB,SAAQ,OAAO;IAMnC,OAAO,CAAC,IAAI;IALxB,OAAO,CAAC,WAAW,CAAuC;IAC1D,OAAO,CAAC,WAAW,CAAuC;IAC1D,OAAO,CAAC,WAAW,CAAC,CAAQ;IAC5B,OAAO,CAAC,WAAW,CAAC,CAAQ;gBAER,IAAI,EAAE,gBAAgB;IAI1C;;;OAGG;IACH,iBAAiB,IAAI,OAAO;IAM5B;;;OAGG;IACH,iBAAiB,IAAI,OAAO;IAM5B;;OAEG;IACH,kBAAkB,IAAI,OAAO;IAI7B;;OAEG;IACH,kBAAkB,IAAI,OAAO;IAI7B;;OAEG;IACH,iBAAiB,IAAI,OAAO;IAe5B;;OAEG;IACH,gBAAgB,IAAI,IAAI;IAMxB;;OAEG;IACH,gBAAgB,IAAI,IAAI;IAMxB;;OAEG;IACH,QAAQ,IAAI,IAAI;IAKhB;;OAEG;IACH,SAAS,IAAI,kBAAkB;IAS/B;;;OAGG;IACG,cAAc,IAAI,OAAO,CAAC,IAAI,CAAC;
|
|
1
|
+
{"version":3,"file":"o-registration.manager.d.ts","sourceRoot":"","sources":["../../../src/managers/o-registration.manager.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,OAAO,EAIR,MAAM,eAAe,CAAC;AACvB,OAAO,EAAE,gBAAgB,EAAE,MAAM,qCAAqC,CAAC;AAGvE,MAAM,MAAM,iBAAiB,GACzB,gBAAgB,GAChB,aAAa,GACb,YAAY,GACZ,QAAQ,CAAC;AAEb,MAAM,WAAW,kBAAkB;IACjC,MAAM,EAAE,iBAAiB,CAAC;IAC1B,MAAM,EAAE,iBAAiB,CAAC;IAC1B,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,WAAW,CAAC,EAAE,MAAM,CAAC;CACtB;AAED;;;;;;;;;;;;GAYG;AACH,qBAAa,oBAAqB,SAAQ,OAAO;IAMnC,OAAO,CAAC,IAAI;IALxB,OAAO,CAAC,WAAW,CAAuC;IAC1D,OAAO,CAAC,WAAW,CAAuC;IAC1D,OAAO,CAAC,WAAW,CAAC,CAAQ;IAC5B,OAAO,CAAC,WAAW,CAAC,CAAQ;gBAER,IAAI,EAAE,gBAAgB;IAI1C;;;OAGG;IACH,iBAAiB,IAAI,OAAO;IAM5B;;;OAGG;IACH,iBAAiB,IAAI,OAAO;IAM5B;;OAEG;IACH,kBAAkB,IAAI,OAAO;IAI7B;;OAEG;IACH,kBAAkB,IAAI,OAAO;IAI7B;;OAEG;IACH,iBAAiB,IAAI,OAAO;IAe5B;;OAEG;IACH,gBAAgB,IAAI,IAAI;IAMxB;;OAEG;IACH,gBAAgB,IAAI,IAAI;IAMxB;;OAEG;IACH,QAAQ,IAAI,IAAI;IAKhB;;OAEG;IACH,SAAS,IAAI,kBAAkB;IAS/B;;;OAGG;IACG,cAAc,IAAI,OAAO,CAAC,IAAI,CAAC;IAsFrC;;;OAGG;IACG,cAAc,IAAI,OAAO,CAAC,IAAI,CAAC;CAwDtC"}
|
|
@@ -128,7 +128,17 @@ export class oRegistrationManager extends oObject {
|
|
|
128
128
|
this.node.parent.setTransports(this.node.leader?.libp2pTransports || []);
|
|
129
129
|
}
|
|
130
130
|
else {
|
|
131
|
-
|
|
131
|
+
this.logger.debug('Waiting for parent and reconnecting...');
|
|
132
|
+
// Reset state since we're delegating to reconnection manager
|
|
133
|
+
this.parentState = 'not_registered';
|
|
134
|
+
if (this.node.reconnectionManager) {
|
|
135
|
+
await this.node.reconnectionManager.waitForParentAndReconnect();
|
|
136
|
+
}
|
|
137
|
+
else {
|
|
138
|
+
throw new Error('Parent has no transports and no reconnection manager available');
|
|
139
|
+
}
|
|
140
|
+
// If we get here, reconnection was successful and registration is complete
|
|
141
|
+
return;
|
|
132
142
|
}
|
|
133
143
|
}
|
|
134
144
|
// Register with parent via child_register call
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"o-node.tool.d.ts","sourceRoot":"","sources":["../../src/o-node.tool.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,QAAQ,EAAoB,MAAM,eAAe,CAAC;AAErE,OAAO,EAAE,WAAW,EAAE,MAAM,wBAAwB,CAAC;AACrD,OAAO,EAAE,UAAU,EAAE,MAAM,EAAE,MAAM,iBAAiB,CAAC;;AAMrD;;;;GAIG;AACH,qBAAa,SAAU,SAAQ,cAAkB;IAC/C,OAAO,CAAC,aAAa,CAAiB;IAEhC,mBAAmB,CAAC,OAAO,EAAE,QAAQ;
|
|
1
|
+
{"version":3,"file":"o-node.tool.d.ts","sourceRoot":"","sources":["../../src/o-node.tool.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,QAAQ,EAAoB,MAAM,eAAe,CAAC;AAErE,OAAO,EAAE,WAAW,EAAE,MAAM,wBAAwB,CAAC;AACrD,OAAO,EAAE,UAAU,EAAE,MAAM,EAAE,MAAM,iBAAiB,CAAC;;AAMrD;;;;GAIG;AACH,qBAAa,SAAU,SAAQ,cAAkB;IAC/C,OAAO,CAAC,aAAa,CAAiB;IAEhC,mBAAmB,CAAC,OAAO,EAAE,QAAQ;IAuBrC,cAAc,CAAC,OAAO,EAAE,QAAQ;IAsBhC,mBAAmB;IAWnB,UAAU,IAAI,OAAO,CAAC,IAAI,CAAC;IAM3B,iBAAiB,CACrB,MAAM,EAAE,MAAM,EACd,UAAU,EAAE,UAAU,GACrB,OAAO,CAAC,IAAI,CAAC;IAIV,YAAY,CAChB,MAAM,EAAE,MAAM,EACd,UAAU,EAAE,UAAU,EACtB,KAAK,CAAC,EAAE,OAAO,GACd,OAAO,CAAC,IAAI,CAAC;IAyCV,cAAc,IAAI,OAAO,CAAC,GAAG,CAAC;IAQ9B,oBAAoB,CAAC,OAAO,EAAE,QAAQ,GAAG,OAAO,CAAC,GAAG,CAAC;CAiC5D"}
|
package/dist/src/o-node.tool.js
CHANGED
|
@@ -25,6 +25,7 @@ export class oNodeTool extends oTool(oServerNode) {
|
|
|
25
25
|
await this.p2pNode.handle(reuseProtocol, this.handleStreamReuse.bind(this), {
|
|
26
26
|
maxInboundStreams: 10000,
|
|
27
27
|
maxOutboundStreams: maxOutboundsStreams,
|
|
28
|
+
runOnLimitedConnection: this.config.runOnLimitedConnection,
|
|
28
29
|
});
|
|
29
30
|
this.logger.debug('Handled protocol reuse: ' + reuseProtocol);
|
|
30
31
|
}
|
|
@@ -40,10 +41,12 @@ export class oNodeTool extends oTool(oServerNode) {
|
|
|
40
41
|
this.logger.debug('Handling protocol: ' + address.protocol, {
|
|
41
42
|
maxInboundStreams: 10000,
|
|
42
43
|
maxOutboundStreams: maxOutboundsStreams,
|
|
44
|
+
runOnLimitedConnection: this.config.runOnLimitedConnection,
|
|
43
45
|
});
|
|
44
46
|
await this.p2pNode.handle(address.protocol, this.handleStream.bind(this), {
|
|
45
47
|
maxInboundStreams: 10000,
|
|
46
48
|
maxOutboundStreams: maxOutboundsStreams,
|
|
49
|
+
runOnLimitedConnection: this.config.runOnLimitedConnection,
|
|
47
50
|
});
|
|
48
51
|
await this.handleProtocolReuse(address);
|
|
49
52
|
}
|
|
@@ -66,20 +69,20 @@ export class oNodeTool extends oTool(oServerNode) {
|
|
|
66
69
|
async handleStream(stream, connection, reuse) {
|
|
67
70
|
if (reuse) {
|
|
68
71
|
this.logger.debug('Handle stream with reuse = true');
|
|
72
|
+
// record inbound connection to manager
|
|
73
|
+
const remoteAddress = await ConnectionUtils.addressFromConnection({
|
|
74
|
+
currentNode: this,
|
|
75
|
+
connection: connection,
|
|
76
|
+
});
|
|
77
|
+
this.connectionManager.answer({
|
|
78
|
+
nextHopAddress: remoteAddress,
|
|
79
|
+
address: remoteAddress,
|
|
80
|
+
callerAddress: this.address,
|
|
81
|
+
p2pConnection: connection,
|
|
82
|
+
reuse,
|
|
83
|
+
// requestHandler: this.execute.bind(this), TODO: do we need this?
|
|
84
|
+
});
|
|
69
85
|
}
|
|
70
|
-
// record inbound connection to manager
|
|
71
|
-
const remoteAddress = await ConnectionUtils.addressFromConnection({
|
|
72
|
-
currentNode: this,
|
|
73
|
-
connection: connection,
|
|
74
|
-
});
|
|
75
|
-
this.connectionManager.answer({
|
|
76
|
-
nextHopAddress: remoteAddress,
|
|
77
|
-
address: remoteAddress,
|
|
78
|
-
callerAddress: this.address,
|
|
79
|
-
p2pConnection: connection,
|
|
80
|
-
reuse,
|
|
81
|
-
// requestHandler: this.execute.bind(this), TODO: do we need this?
|
|
82
|
-
});
|
|
83
86
|
// Use StreamHandler for consistent stream handling
|
|
84
87
|
// This follows libp2p v3 best practices for length-prefixed streaming
|
|
85
88
|
await this.streamHandler.handleIncomingStream(stream, connection, async (request, stream) => {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@olane/o-node",
|
|
3
|
-
"version": "0.7.
|
|
3
|
+
"version": "0.7.50",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"main": "dist/src/index.js",
|
|
6
6
|
"types": "dist/src/index.d.ts",
|
|
@@ -40,7 +40,7 @@
|
|
|
40
40
|
"devDependencies": {
|
|
41
41
|
"@eslint/eslintrc": "^3.3.1",
|
|
42
42
|
"@eslint/js": "^9.29.0",
|
|
43
|
-
"@olane/o-test": "0.7.
|
|
43
|
+
"@olane/o-test": "0.7.50",
|
|
44
44
|
"@tsconfig/node20": "^20.1.6",
|
|
45
45
|
"@types/jest": "^30.0.0",
|
|
46
46
|
"@types/json5": "^2.2.0",
|
|
@@ -60,13 +60,13 @@
|
|
|
60
60
|
"typescript": "5.4.5"
|
|
61
61
|
},
|
|
62
62
|
"dependencies": {
|
|
63
|
-
"@olane/o-config": "0.7.
|
|
64
|
-
"@olane/o-core": "0.7.
|
|
65
|
-
"@olane/o-protocol": "0.7.
|
|
66
|
-
"@olane/o-tool": "0.7.
|
|
63
|
+
"@olane/o-config": "0.7.50",
|
|
64
|
+
"@olane/o-core": "0.7.50",
|
|
65
|
+
"@olane/o-protocol": "0.7.50",
|
|
66
|
+
"@olane/o-tool": "0.7.50",
|
|
67
67
|
"debug": "^4.4.1",
|
|
68
68
|
"dotenv": "^16.5.0",
|
|
69
69
|
"json5": "^2.2.3"
|
|
70
70
|
},
|
|
71
|
-
"gitHead": "
|
|
71
|
+
"gitHead": "55f5464185ef16a164fa23dc46c0c08b317419a0"
|
|
72
72
|
}
|