@olane/o-node 0.7.12-alpha.3 → 0.7.12-alpha.31

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.
Files changed (254) hide show
  1. package/dist/o-core/src/connection/o-response.d.ts +12 -0
  2. package/dist/o-core/src/connection/o-response.d.ts.map +1 -0
  3. package/dist/o-core/src/connection/o-response.js +18 -0
  4. package/dist/o-core/src/error/enums/codes.error.d.ts +20 -0
  5. package/dist/o-core/src/error/enums/codes.error.d.ts.map +1 -0
  6. package/dist/o-core/src/error/enums/codes.error.js +20 -0
  7. package/dist/o-core/src/error/interfaces/o-error.interface.d.ts +6 -0
  8. package/dist/o-core/src/error/interfaces/o-error.interface.d.ts.map +1 -0
  9. package/dist/o-core/src/error/interfaces/o-error.interface.js +1 -0
  10. package/dist/o-core/src/error/o-error.d.ts +15 -0
  11. package/dist/o-core/src/error/o-error.d.ts.map +1 -0
  12. package/dist/o-core/src/error/o-error.js +27 -0
  13. package/dist/o-core/src/streaming/index.d.ts +11 -0
  14. package/dist/o-core/src/streaming/index.d.ts.map +1 -0
  15. package/dist/o-core/src/streaming/index.js +14 -0
  16. package/dist/o-core/src/streaming/protocol-builder.d.ts +62 -0
  17. package/dist/o-core/src/streaming/protocol-builder.d.ts.map +1 -0
  18. package/dist/o-core/src/streaming/protocol-builder.js +93 -0
  19. package/dist/o-core/src/streaming/stream-config.d.ts +36 -0
  20. package/dist/o-core/src/streaming/stream-config.d.ts.map +1 -0
  21. package/dist/o-core/src/streaming/stream-config.js +19 -0
  22. package/dist/o-core/src/streaming/stream-handler.base.d.ts +85 -0
  23. package/dist/o-core/src/streaming/stream-handler.base.d.ts.map +1 -0
  24. package/dist/o-core/src/streaming/stream-handler.base.js +112 -0
  25. package/dist/o-core/src/streaming/stream-transport.interface.d.ts +61 -0
  26. package/dist/o-core/src/streaming/stream-transport.interface.d.ts.map +1 -0
  27. package/dist/o-core/src/streaming/stream-transport.interface.js +10 -0
  28. package/dist/o-core/src/utils/streaming.utils.d.ts +22 -0
  29. package/dist/o-core/src/utils/streaming.utils.d.ts.map +1 -0
  30. package/dist/o-core/src/utils/streaming.utils.js +45 -0
  31. package/dist/o-node/src/connection/index.d.ts +5 -0
  32. package/dist/o-node/src/connection/index.d.ts.map +1 -0
  33. package/dist/o-node/src/connection/index.js +4 -0
  34. package/dist/o-node/src/connection/interfaces/o-node-connection-manager.config.d.ts +6 -0
  35. package/dist/o-node/src/connection/interfaces/o-node-connection-manager.config.d.ts.map +1 -0
  36. package/dist/o-node/src/connection/interfaces/o-node-connection-manager.config.js +1 -0
  37. package/dist/o-node/src/connection/interfaces/o-node-connection.config.d.ts +6 -0
  38. package/dist/o-node/src/connection/interfaces/o-node-connection.config.d.ts.map +1 -0
  39. package/dist/o-node/src/connection/interfaces/o-node-connection.config.js +1 -0
  40. package/dist/o-node/src/connection/o-node-connection.d.ts +13 -0
  41. package/dist/o-node/src/connection/o-node-connection.d.ts.map +1 -0
  42. package/dist/o-node/src/connection/o-node-connection.js +80 -0
  43. package/dist/o-node/src/connection/o-node-connection.manager.d.ts +19 -0
  44. package/dist/o-node/src/connection/o-node-connection.manager.d.ts.map +1 -0
  45. package/dist/o-node/src/connection/o-node-connection.manager.js +93 -0
  46. package/dist/o-node/src/connection/o-stream.request.d.ts +11 -0
  47. package/dist/o-node/src/connection/o-stream.request.d.ts.map +1 -0
  48. package/dist/o-node/src/connection/o-stream.request.js +7 -0
  49. package/dist/o-node/src/index.d.ts +11 -0
  50. package/dist/o-node/src/index.d.ts.map +1 -0
  51. package/dist/o-node/src/index.js +10 -0
  52. package/dist/o-node/src/interfaces/i-heartbeatable-node.d.ts +49 -0
  53. package/dist/o-node/src/interfaces/i-heartbeatable-node.d.ts.map +1 -0
  54. package/dist/o-node/src/interfaces/i-heartbeatable-node.js +1 -0
  55. package/dist/o-node/src/interfaces/i-reconnectable-node.d.ts +46 -0
  56. package/dist/o-node/src/interfaces/i-reconnectable-node.d.ts.map +1 -0
  57. package/dist/o-node/src/interfaces/i-reconnectable-node.js +1 -0
  58. package/dist/o-node/src/interfaces/o-node.config.d.ts +66 -0
  59. package/dist/o-node/src/interfaces/o-node.config.d.ts.map +1 -0
  60. package/dist/o-node/src/interfaces/o-node.config.js +1 -0
  61. package/dist/o-node/src/interfaces/o-node.tool-config.d.ts +4 -0
  62. package/dist/o-node/src/interfaces/o-node.tool-config.d.ts.map +1 -0
  63. package/dist/o-node/src/interfaces/o-node.tool-config.js +1 -0
  64. package/dist/o-node/src/lib/network-activity.lib.d.ts +1 -0
  65. package/dist/o-node/src/lib/network-activity.lib.d.ts.map +1 -0
  66. package/dist/o-node/src/lib/network-activity.lib.js +34 -0
  67. package/dist/o-node/src/managers/o-connection-heartbeat.manager.d.ts +62 -0
  68. package/dist/o-node/src/managers/o-connection-heartbeat.manager.d.ts.map +1 -0
  69. package/dist/o-node/src/managers/o-connection-heartbeat.manager.js +213 -0
  70. package/dist/o-node/src/managers/o-reconnection.manager.d.ts +51 -0
  71. package/dist/o-node/src/managers/o-reconnection.manager.d.ts.map +1 -0
  72. package/dist/o-node/src/managers/o-reconnection.manager.js +266 -0
  73. package/dist/o-node/src/nodes/client.node.d.ts +7 -0
  74. package/dist/o-node/src/nodes/client.node.d.ts.map +1 -0
  75. package/dist/o-node/src/nodes/client.node.js +16 -0
  76. package/dist/o-node/src/nodes/index.d.ts +4 -0
  77. package/dist/o-node/src/nodes/index.d.ts.map +1 -0
  78. package/dist/o-node/src/nodes/index.js +3 -0
  79. package/dist/o-node/src/nodes/server.node.d.ts +7 -0
  80. package/dist/o-node/src/nodes/server.node.d.ts.map +1 -0
  81. package/dist/o-node/src/nodes/server.node.js +20 -0
  82. package/dist/o-node/src/nodes/websocket.node.d.ts +7 -0
  83. package/dist/o-node/src/nodes/websocket.node.d.ts.map +1 -0
  84. package/dist/o-node/src/nodes/websocket.node.js +18 -0
  85. package/dist/o-node/src/o-node.d.ts +73 -0
  86. package/dist/o-node/src/o-node.d.ts.map +1 -0
  87. package/dist/o-node/src/o-node.hierarchy-manager.d.ts +15 -0
  88. package/dist/o-node/src/o-node.hierarchy-manager.d.ts.map +1 -0
  89. package/dist/o-node/src/o-node.hierarchy-manager.js +15 -0
  90. package/dist/o-node/src/o-node.js +414 -0
  91. package/dist/o-node/src/o-node.notification-manager.d.ts +52 -0
  92. package/dist/o-node/src/o-node.notification-manager.d.ts.map +1 -0
  93. package/dist/o-node/src/o-node.notification-manager.js +185 -0
  94. package/dist/o-node/src/o-node.tool.d.ts +18 -0
  95. package/dist/o-node/src/o-node.tool.d.ts.map +1 -0
  96. package/dist/o-node/src/o-node.tool.js +90 -0
  97. package/dist/o-node/src/router/index.d.ts +6 -0
  98. package/dist/o-node/src/router/index.d.ts.map +1 -0
  99. package/dist/o-node/src/router/index.js +5 -0
  100. package/dist/o-node/src/router/interfaces/o-node-router.config.d.ts +3 -0
  101. package/dist/o-node/src/router/interfaces/o-node-router.config.d.ts.map +1 -0
  102. package/dist/o-node/src/router/interfaces/o-node-router.config.js +1 -0
  103. package/dist/o-node/src/router/interfaces/o-node-router.response.d.ts +8 -0
  104. package/dist/o-node/src/router/interfaces/o-node-router.response.d.ts.map +1 -0
  105. package/dist/o-node/src/router/interfaces/o-node-router.response.js +1 -0
  106. package/dist/o-node/src/router/o-node.address.d.ts +18 -0
  107. package/dist/o-node/src/router/o-node.address.d.ts.map +1 -0
  108. package/dist/o-node/src/router/o-node.address.js +29 -0
  109. package/dist/o-node/src/router/o-node.router.d.ts +45 -0
  110. package/dist/o-node/src/router/o-node.router.d.ts.map +1 -0
  111. package/dist/o-node/src/router/o-node.router.js +135 -0
  112. package/dist/o-node/src/router/o-node.routing-policy.d.ts +30 -0
  113. package/dist/o-node/src/router/o-node.routing-policy.d.ts.map +1 -0
  114. package/dist/o-node/src/router/o-node.routing-policy.js +57 -0
  115. package/dist/o-node/src/router/o-node.transport.d.ts +11 -0
  116. package/dist/o-node/src/router/o-node.transport.d.ts.map +1 -0
  117. package/dist/o-node/src/router/o-node.transport.js +18 -0
  118. package/dist/o-node/src/router/resolvers/index.d.ts +4 -0
  119. package/dist/o-node/src/router/resolvers/index.d.ts.map +1 -0
  120. package/dist/o-node/src/router/resolvers/index.js +3 -0
  121. package/dist/o-node/src/router/resolvers/o-node.leader-resolver-fallback.d.ts +8 -0
  122. package/dist/o-node/src/router/resolvers/o-node.leader-resolver-fallback.d.ts.map +1 -0
  123. package/dist/o-node/src/router/resolvers/o-node.leader-resolver-fallback.js +35 -0
  124. package/dist/{src/router/resolvers/o-node.child-resolver.d.ts → o-node/src/router/resolvers/o-node.resolver.d.ts} +2 -2
  125. package/dist/o-node/src/router/resolvers/o-node.resolver.d.ts.map +1 -0
  126. package/dist/o-node/src/router/resolvers/o-node.resolver.js +41 -0
  127. package/dist/o-node/src/router/resolvers/o-node.search-resolver.d.ts +170 -0
  128. package/dist/o-node/src/router/resolvers/o-node.search-resolver.d.ts.map +1 -0
  129. package/dist/o-node/src/router/resolvers/o-node.search-resolver.js +285 -0
  130. package/dist/o-node/src/router/route.request.d.ts +14 -0
  131. package/dist/o-node/src/router/route.request.d.ts.map +1 -0
  132. package/dist/o-node/src/router/route.request.js +1 -0
  133. package/dist/o-node/src/streaming/index.d.ts +10 -0
  134. package/dist/o-node/src/streaming/index.d.ts.map +1 -0
  135. package/dist/o-node/src/streaming/index.js +12 -0
  136. package/dist/o-node/src/streaming/libp2p-stream-transport.d.ts +50 -0
  137. package/dist/o-node/src/streaming/libp2p-stream-transport.d.ts.map +1 -0
  138. package/dist/o-node/src/streaming/libp2p-stream-transport.js +137 -0
  139. package/dist/o-node/src/streaming/node-stream-handler.d.ts +65 -0
  140. package/dist/o-node/src/streaming/node-stream-handler.d.ts.map +1 -0
  141. package/dist/o-node/src/streaming/node-stream-handler.js +101 -0
  142. package/dist/o-node/src/utils/circuit-breaker.d.ts +107 -0
  143. package/dist/o-node/src/utils/circuit-breaker.d.ts.map +1 -0
  144. package/dist/o-node/src/utils/circuit-breaker.js +175 -0
  145. package/dist/o-node/src/utils/index.d.ts +5 -0
  146. package/dist/o-node/src/utils/index.d.ts.map +1 -0
  147. package/dist/o-node/src/utils/index.js +4 -0
  148. package/dist/o-node/src/utils/leader-request-wrapper.d.ts +66 -0
  149. package/dist/o-node/src/utils/leader-request-wrapper.d.ts.map +1 -0
  150. package/dist/o-node/src/utils/leader-request-wrapper.js +160 -0
  151. package/dist/o-node/src/utils/network.utils.d.ts +20 -0
  152. package/dist/o-node/src/utils/network.utils.d.ts.map +1 -0
  153. package/dist/o-node/src/utils/network.utils.js +74 -0
  154. package/dist/o-node/src/utils/stream.utils.d.ts +6 -0
  155. package/dist/o-node/src/utils/stream.utils.d.ts.map +1 -0
  156. package/dist/o-node/src/utils/stream.utils.js +27 -0
  157. package/dist/o-node/test/circuit-breaker.test.d.ts +2 -0
  158. package/dist/o-node/test/circuit-breaker.test.d.ts.map +1 -0
  159. package/dist/o-node/test/circuit-breaker.test.js +262 -0
  160. package/dist/o-node/test/leader-request-wrapper.test.d.ts +1 -0
  161. package/dist/o-node/test/leader-request-wrapper.test.d.ts.map +1 -0
  162. package/dist/o-node/test/leader-request-wrapper.test.js +246 -0
  163. package/dist/o-node/test/o-node.spec.d.ts +2 -0
  164. package/dist/o-node/test/o-node.spec.d.ts.map +1 -0
  165. package/dist/o-node/test/o-node.spec.js +20 -0
  166. package/dist/o-node/test/search-resolver.spec.d.ts +2 -0
  167. package/dist/o-node/test/search-resolver.spec.d.ts.map +1 -0
  168. package/dist/o-node/test/search-resolver.spec.js +693 -0
  169. package/dist/src/connection/o-node-connection.d.ts +1 -2
  170. package/dist/src/connection/o-node-connection.d.ts.map +1 -1
  171. package/dist/src/connection/o-node-connection.js +25 -18
  172. package/dist/src/connection/o-node-connection.manager.d.ts +3 -1
  173. package/dist/src/connection/o-node-connection.manager.d.ts.map +1 -1
  174. package/dist/src/connection/o-node-connection.manager.js +45 -20
  175. package/dist/src/connection/o-stream.request.d.ts +11 -0
  176. package/dist/src/connection/o-stream.request.d.ts.map +1 -0
  177. package/dist/src/connection/o-stream.request.js +7 -0
  178. package/dist/src/index.d.ts +2 -1
  179. package/dist/src/index.d.ts.map +1 -1
  180. package/dist/src/index.js +2 -1
  181. package/dist/src/interfaces/i-heartbeatable-node.d.ts +49 -0
  182. package/dist/src/interfaces/i-heartbeatable-node.d.ts.map +1 -0
  183. package/dist/src/interfaces/i-heartbeatable-node.js +1 -0
  184. package/dist/src/interfaces/i-reconnectable-node.d.ts +46 -0
  185. package/dist/src/interfaces/i-reconnectable-node.d.ts.map +1 -0
  186. package/dist/src/interfaces/i-reconnectable-node.js +1 -0
  187. package/dist/src/interfaces/o-node.config.d.ts +42 -0
  188. package/dist/src/interfaces/o-node.config.d.ts.map +1 -1
  189. package/dist/src/managers/o-connection-heartbeat.manager.d.ts +62 -0
  190. package/dist/src/managers/o-connection-heartbeat.manager.d.ts.map +1 -0
  191. package/dist/src/managers/o-connection-heartbeat.manager.js +213 -0
  192. package/dist/src/managers/o-reconnection.manager.d.ts +51 -0
  193. package/dist/src/managers/o-reconnection.manager.d.ts.map +1 -0
  194. package/dist/src/managers/o-reconnection.manager.js +266 -0
  195. package/dist/src/o-node.d.ts +20 -2
  196. package/dist/src/o-node.d.ts.map +1 -1
  197. package/dist/src/o-node.js +161 -32
  198. package/dist/src/o-node.notification-manager.d.ts +52 -0
  199. package/dist/src/o-node.notification-manager.d.ts.map +1 -0
  200. package/dist/src/o-node.notification-manager.js +185 -0
  201. package/dist/src/o-node.tool.d.ts.map +1 -1
  202. package/dist/src/o-node.tool.js +29 -22
  203. package/dist/src/router/o-node.router.d.ts +1 -0
  204. package/dist/src/router/o-node.router.d.ts.map +1 -1
  205. package/dist/src/router/o-node.router.js +61 -5
  206. package/dist/src/router/o-node.routing-policy.d.ts.map +1 -1
  207. package/dist/src/router/o-node.routing-policy.js +7 -2
  208. package/dist/src/router/resolvers/o-node.resolver.d.ts.map +1 -1
  209. package/dist/src/router/resolvers/o-node.resolver.js +5 -1
  210. package/dist/src/router/resolvers/o-node.search-resolver.d.ts.map +1 -1
  211. package/dist/src/router/resolvers/o-node.search-resolver.js +40 -10
  212. package/dist/src/streaming/index.d.ts +10 -0
  213. package/dist/src/streaming/index.d.ts.map +1 -0
  214. package/dist/src/streaming/index.js +12 -0
  215. package/dist/src/streaming/libp2p-stream-transport.d.ts +50 -0
  216. package/dist/src/streaming/libp2p-stream-transport.d.ts.map +1 -0
  217. package/dist/src/streaming/libp2p-stream-transport.js +137 -0
  218. package/dist/src/streaming/node-stream-handler.d.ts +65 -0
  219. package/dist/src/streaming/node-stream-handler.d.ts.map +1 -0
  220. package/dist/src/streaming/node-stream-handler.js +101 -0
  221. package/dist/src/streaming/o-node-streaming-client.d.ts +33 -0
  222. package/dist/src/streaming/o-node-streaming-client.d.ts.map +1 -0
  223. package/dist/src/streaming/o-node-streaming-client.js +130 -0
  224. package/dist/src/utils/circuit-breaker.d.ts +107 -0
  225. package/dist/src/utils/circuit-breaker.d.ts.map +1 -0
  226. package/dist/src/utils/circuit-breaker.js +175 -0
  227. package/dist/src/utils/circuit-breaker.test.d.ts +2 -0
  228. package/dist/src/utils/circuit-breaker.test.d.ts.map +1 -0
  229. package/dist/src/utils/circuit-breaker.test.js +262 -0
  230. package/dist/src/utils/index.d.ts +3 -0
  231. package/dist/src/utils/index.d.ts.map +1 -0
  232. package/dist/src/utils/index.js +2 -0
  233. package/dist/src/utils/leader-request-wrapper.d.ts +66 -0
  234. package/dist/src/utils/leader-request-wrapper.d.ts.map +1 -0
  235. package/dist/src/utils/leader-request-wrapper.js +160 -0
  236. package/dist/src/utils/leader-request-wrapper.test.d.ts +1 -0
  237. package/dist/src/utils/leader-request-wrapper.test.d.ts.map +1 -0
  238. package/dist/src/utils/leader-request-wrapper.test.js +246 -0
  239. package/dist/src/utils/stream.utils.d.ts +6 -0
  240. package/dist/src/utils/stream.utils.d.ts.map +1 -0
  241. package/dist/src/utils/stream.utils.js +31 -0
  242. package/dist/test/circuit-breaker.test.d.ts +2 -0
  243. package/dist/test/circuit-breaker.test.d.ts.map +1 -0
  244. package/dist/test/circuit-breaker.test.js +262 -0
  245. package/dist/test/helpers/test-node.tool.d.ts +15 -0
  246. package/dist/test/helpers/test-node.tool.d.ts.map +1 -0
  247. package/dist/test/helpers/test-node.tool.js +27 -0
  248. package/dist/test/leader-request-wrapper.test.d.ts +1 -0
  249. package/dist/test/leader-request-wrapper.test.d.ts.map +1 -0
  250. package/dist/test/leader-request-wrapper.test.js +246 -0
  251. package/dist/test/search-resolver.spec.js +79 -0
  252. package/package.json +6 -6
  253. package/dist/src/router/resolvers/o-node.child-resolver.d.ts.map +0 -1
  254. package/dist/src/router/resolvers/o-node.child-resolver.js +0 -58
@@ -0,0 +1,185 @@
1
+ import { oNotificationManager, NodeConnectedEvent, NodeDisconnectedEvent, NodeDiscoveredEvent, ChildJoinedEvent, ChildLeftEvent, ParentConnectedEvent, ParentDisconnectedEvent, } from '@olane/o-core';
2
+ /**
3
+ * libp2p-specific implementation of oNotificationManager
4
+ * Wraps libp2p events and enriches them with Olane context
5
+ */
6
+ export class oNodeNotificationManager extends oNotificationManager {
7
+ constructor(p2pNode, hierarchyManager, address) {
8
+ super();
9
+ this.p2pNode = p2pNode;
10
+ this.hierarchyManager = hierarchyManager;
11
+ this.address = address;
12
+ }
13
+ /**
14
+ * Wire up libp2p event listeners
15
+ */
16
+ setupListeners() {
17
+ this.logger.debug('Setting up libp2p event listeners...');
18
+ // Peer connection events
19
+ this.p2pNode.addEventListener('peer:connect', this.handlePeerConnect.bind(this));
20
+ this.p2pNode.addEventListener('peer:disconnect', this.handlePeerDisconnect.bind(this));
21
+ // Peer discovery events
22
+ this.p2pNode.addEventListener('peer:discovery', this.handlePeerDiscovery.bind(this));
23
+ // Connection events
24
+ this.p2pNode.addEventListener('connection:open', this.handleConnectionOpen.bind(this));
25
+ this.p2pNode.addEventListener('connection:close', this.handleConnectionClose.bind(this));
26
+ this.logger.debug('libp2p event listeners configured');
27
+ }
28
+ /**
29
+ * Handle peer connect event from libp2p
30
+ */
31
+ handlePeerConnect(evt) {
32
+ const peerId = evt.detail;
33
+ // this.logger.debug(`Peer connected: ${peerId.toString()}`);
34
+ // Try to resolve peer ID to Olane address
35
+ const nodeAddress = this.peerIdToAddress(peerId.toString());
36
+ if (!nodeAddress) {
37
+ // this.logger.debug(
38
+ // `Could not resolve peer ID ${peerId.toString()} to address`,
39
+ // );
40
+ return;
41
+ }
42
+ // Emit generic node connected event
43
+ this.emit(new NodeConnectedEvent({
44
+ source: this.address,
45
+ nodeAddress,
46
+ connectionMetadata: {
47
+ peerId: peerId.toString(),
48
+ transport: 'libp2p',
49
+ },
50
+ }));
51
+ // Check if this is a child node
52
+ if (this.isChild(nodeAddress)) {
53
+ // this.logger.debug(`Child node connected: ${nodeAddress.toString()}`);
54
+ this.emit(new ChildJoinedEvent({
55
+ source: this.address,
56
+ childAddress: nodeAddress,
57
+ parentAddress: this.address,
58
+ }));
59
+ }
60
+ // Check if this is a parent node
61
+ if (this.isParent(nodeAddress)) {
62
+ // this.logger.debug(`Parent node connected: ${nodeAddress.toString()}`);
63
+ this.emit(new ParentConnectedEvent({
64
+ source: this.address,
65
+ parentAddress: nodeAddress,
66
+ }));
67
+ }
68
+ }
69
+ /**
70
+ * Handle peer disconnect event from libp2p
71
+ */
72
+ handlePeerDisconnect(evt) {
73
+ const peerId = evt.detail;
74
+ // this.logger.debug(`Peer disconnected: ${peerId.toString()}`);
75
+ // Try to resolve peer ID to Olane address
76
+ const nodeAddress = this.peerIdToAddress(peerId.toString());
77
+ if (!nodeAddress) {
78
+ // this.logger.debug(
79
+ // `Could not resolve peer ID ${peerId.toString()} to address`,
80
+ // );
81
+ return;
82
+ }
83
+ // Emit generic node disconnected event
84
+ this.emit(new NodeDisconnectedEvent({
85
+ source: this.address,
86
+ nodeAddress,
87
+ reason: 'peer_disconnected',
88
+ }));
89
+ // Check if this is a child node
90
+ if (this.isChild(nodeAddress)) {
91
+ this.logger.debug(`Child node disconnected: ${nodeAddress.toString()}`);
92
+ this.emit(new ChildLeftEvent({
93
+ source: this.address,
94
+ childAddress: nodeAddress,
95
+ parentAddress: this.address,
96
+ reason: 'peer_disconnected',
97
+ }));
98
+ // Optionally remove from hierarchy (auto-cleanup)
99
+ // this.hierarchyManager.removeChild(nodeAddress);
100
+ }
101
+ // Check if this is a parent node
102
+ if (this.isParent(nodeAddress)) {
103
+ this.logger.debug(`Parent node disconnected: ${nodeAddress.toString()}`);
104
+ this.emit(new ParentDisconnectedEvent({
105
+ source: this.address,
106
+ parentAddress: nodeAddress,
107
+ reason: 'peer_disconnected',
108
+ }));
109
+ }
110
+ }
111
+ /**
112
+ * Handle peer discovery event from libp2p
113
+ */
114
+ handlePeerDiscovery(evt) {
115
+ const peerInfo = evt.detail;
116
+ // this.logger.debug(`Peer discovered: ${peerInfo.id.toString()}`);
117
+ // Try to resolve peer ID to Olane address
118
+ const nodeAddress = this.peerIdToAddress(peerInfo.id.toString());
119
+ if (!nodeAddress) {
120
+ return;
121
+ }
122
+ this.emit(new NodeDiscoveredEvent({
123
+ source: this.address,
124
+ nodeAddress,
125
+ }));
126
+ }
127
+ /**
128
+ * Handle connection open event from libp2p
129
+ */
130
+ handleConnectionOpen(evt) {
131
+ // do nothing for now
132
+ }
133
+ /**
134
+ * Handle connection close event from libp2p
135
+ */
136
+ handleConnectionClose(evt) {
137
+ // do nothing for now
138
+ }
139
+ /**
140
+ * Try to resolve a libp2p peer ID to an Olane address
141
+ * Checks hierarchy manager for known peers
142
+ */
143
+ peerIdToAddress(peerId) {
144
+ // Check children
145
+ for (const child of this.hierarchyManager.children) {
146
+ const childTransports = child.transports;
147
+ for (const transport of childTransports) {
148
+ if (transport.toString().includes(peerId)) {
149
+ return child;
150
+ }
151
+ }
152
+ }
153
+ // Check parents
154
+ for (const parent of this.hierarchyManager.parents) {
155
+ const parentTransports = parent.transports;
156
+ for (const transport of parentTransports) {
157
+ if (transport.toString().includes(peerId)) {
158
+ return parent;
159
+ }
160
+ }
161
+ }
162
+ // Check leaders
163
+ for (const leader of this.hierarchyManager.leaders) {
164
+ const leaderTransports = leader.transports;
165
+ for (const transport of leaderTransports) {
166
+ if (transport.toString().includes(peerId)) {
167
+ return leader;
168
+ }
169
+ }
170
+ }
171
+ return null;
172
+ }
173
+ /**
174
+ * Check if an address is a direct child
175
+ */
176
+ isChild(address) {
177
+ return this.hierarchyManager.children.some((child) => child.toString() === address.toString());
178
+ }
179
+ /**
180
+ * Check if an address is a parent
181
+ */
182
+ isParent(address) {
183
+ return this.hierarchyManager.parents.some((parent) => parent.toString() === address.toString());
184
+ }
185
+ }
@@ -0,0 +1,18 @@
1
+ import { oAddress, oRequest } from '@olane/o-core';
2
+ import { oServerNode } from './nodes/server.node.js';
3
+ import { Connection, Stream } from '@olane/o-config';
4
+ declare const oNodeTool_base: typeof oServerNode;
5
+ /**
6
+ * oTool is a mixin that extends the base class and implements the oTool interface
7
+ * @param Base - The base class to extend
8
+ * @returns A new class that extends the base class and implements the oTool interface
9
+ */
10
+ export declare class oNodeTool extends oNodeTool_base {
11
+ handleProtocol(address: oAddress): Promise<void>;
12
+ initialize(): Promise<void>;
13
+ handleStream(stream: Stream, connection: Connection): Promise<void>;
14
+ _tool_identify(): Promise<any>;
15
+ _tool_child_register(request: oRequest): Promise<any>;
16
+ }
17
+ export {};
18
+ //# sourceMappingURL=o-node.tool.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"o-node.tool.d.ts","sourceRoot":"","sources":["../../../src/o-node.tool.ts"],"names":[],"mappings":"AAAA,OAAO,EAEL,QAAQ,EAGR,QAAQ,EAGT,MAAM,eAAe,CAAC;AAMvB,OAAO,EAAE,WAAW,EAAE,MAAM,wBAAwB,CAAC;AACrD,OAAO,EAAE,UAAU,EAAE,MAAM,EAAE,MAAM,iBAAiB,CAAC;;AAIrD;;;;GAIG;AACH,qBAAa,SAAU,SAAQ,cAAkB;IACzC,cAAc,CAAC,OAAO,EAAE,QAAQ;IAQhC,UAAU,IAAI,OAAO,CAAC,IAAI,CAAC;IAW3B,YAAY,CAAC,MAAM,EAAE,MAAM,EAAE,UAAU,EAAE,UAAU,GAAG,OAAO,CAAC,IAAI,CAAC;IAoDnE,cAAc,IAAI,OAAO,CAAC,GAAG,CAAC;IAQ9B,oBAAoB,CAAC,OAAO,EAAE,QAAQ,GAAG,OAAO,CAAC,GAAG,CAAC;CA2B5D"}
@@ -0,0 +1,90 @@
1
+ import { CoreUtils, oError, oErrorCodes, oRequest, ChildJoinedEvent, } from '@olane/o-core';
2
+ import { oTool } from '@olane/o-tool';
3
+ import { oServerNode } from './nodes/server.node.js';
4
+ import { oNodeTransport } from './router/o-node.transport.js';
5
+ import { oNodeAddress } from './router/o-node.address.js';
6
+ /**
7
+ * oTool is a mixin that extends the base class and implements the oTool interface
8
+ * @param Base - The base class to extend
9
+ * @returns A new class that extends the base class and implements the oTool interface
10
+ */
11
+ export class oNodeTool extends oTool(oServerNode) {
12
+ async handleProtocol(address) {
13
+ this.logger.debug('Handling protocol: ' + address.protocol);
14
+ await this.p2pNode.handle(address.protocol, this.handleStream.bind(this), {
15
+ maxInboundStreams: Infinity,
16
+ maxOutboundStreams: Infinity,
17
+ });
18
+ }
19
+ async initialize() {
20
+ await super.initialize();
21
+ await this.handleProtocol(this.address);
22
+ if (this.staticAddress &&
23
+ this.staticAddress?.toString() !== this.address.toString()) {
24
+ await this.handleProtocol(this.staticAddress);
25
+ }
26
+ }
27
+ async handleStream(stream, connection) {
28
+ // CRITICAL: Attach message listener immediately to prevent buffer overflow (libp2p v3)
29
+ // Per libp2p migration guide: "If no message event handler is added, streams will
30
+ // buffer incoming data until a pre-configured limit is reached, after which the stream will be reset."
31
+ const messageHandler = async (event) => {
32
+ if (!event.data) {
33
+ this.logger.warn('Malformed event data');
34
+ return;
35
+ }
36
+ const requestConfig = await CoreUtils.processStreamRequest(event);
37
+ const request = new oRequest(requestConfig);
38
+ let success = true;
39
+ const result = await this.execute(request, stream).catch((error) => {
40
+ this.logger.error('Error executing tool: ', request.toString(), error, typeof error);
41
+ success = false;
42
+ const responseError = error instanceof oError
43
+ ? error
44
+ : new oError(oErrorCodes.UNKNOWN, error.message);
45
+ return {
46
+ error: responseError.toJSON(),
47
+ };
48
+ });
49
+ // Non-streaming response - original behavior
50
+ if (success) {
51
+ this.metrics.successCount++;
52
+ }
53
+ else {
54
+ this.metrics.errorCount++;
55
+ }
56
+ // compose the response & add the expected connection + request fields
57
+ const response = CoreUtils.buildResponse(request, result, result?.error);
58
+ // add the request method to the response
59
+ await CoreUtils.sendResponse(response, stream);
60
+ };
61
+ // Attach listener synchronously before any async operations
62
+ stream.addEventListener('message', messageHandler);
63
+ }
64
+ async _tool_identify() {
65
+ return {
66
+ address: this.address.toString(),
67
+ staticAddress: this.staticAddress?.toString(),
68
+ transports: this.transports.map((t) => t.toMultiaddr().toString()),
69
+ };
70
+ }
71
+ async _tool_child_register(request) {
72
+ this.logger.debug('Child register: ', request.params);
73
+ const { address, transports } = request.params;
74
+ const childAddress = new oNodeAddress(address, transports.map((t) => new oNodeTransport(t)));
75
+ // Add child to hierarchy
76
+ this.hierarchyManager.addChild(childAddress);
77
+ // Emit child joined event
78
+ if (this.notificationManager) {
79
+ this.notificationManager.emit(new ChildJoinedEvent({
80
+ source: this.address,
81
+ childAddress,
82
+ parentAddress: this.address,
83
+ }));
84
+ }
85
+ return {
86
+ message: `Child node registered with parent! ${childAddress.toString()}`,
87
+ parentTransports: this.parentTransports.map((t) => t.toString()),
88
+ };
89
+ }
90
+ }
@@ -0,0 +1,6 @@
1
+ export * from './o-node.address.js';
2
+ export * from './o-node.router.js';
3
+ export * from './o-node.transport.js';
4
+ export * from './resolvers/index.js';
5
+ export * from './route.request.js';
6
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/router/index.ts"],"names":[],"mappings":"AAAA,cAAc,qBAAqB,CAAC;AACpC,cAAc,oBAAoB,CAAC;AACnC,cAAc,uBAAuB,CAAC;AACtC,cAAc,sBAAsB,CAAC;AACrC,cAAc,oBAAoB,CAAC"}
@@ -0,0 +1,5 @@
1
+ export * from './o-node.address.js';
2
+ export * from './o-node.router.js';
3
+ export * from './o-node.transport.js';
4
+ export * from './resolvers/index.js';
5
+ export * from './route.request.js';
@@ -0,0 +1,3 @@
1
+ export interface oNodeRouterConfig {
2
+ }
3
+ //# sourceMappingURL=o-node-router.config.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"o-node-router.config.d.ts","sourceRoot":"","sources":["../../../../../src/router/interfaces/o-node-router.config.ts"],"names":[],"mappings":"AAAA,MAAM,WAAW,iBAAiB;CAAG"}
@@ -0,0 +1,8 @@
1
+ import { oNodeAddress } from '../o-node.address';
2
+ import { oRouterRequest, RouteResponse } from '@olane/o-core';
3
+ export interface oNodeRouterResponse extends RouteResponse {
4
+ nextHopAddress: oNodeAddress;
5
+ targetAddress: oNodeAddress;
6
+ requestOverride?: oRouterRequest;
7
+ }
8
+ //# sourceMappingURL=o-node-router.response.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"o-node-router.response.d.ts","sourceRoot":"","sources":["../../../../../src/router/interfaces/o-node-router.response.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,MAAM,mBAAmB,CAAC;AACjD,OAAO,EAAE,cAAc,EAAE,aAAa,EAAE,MAAM,eAAe,CAAC;AAE9D,MAAM,WAAW,mBAAoB,SAAQ,aAAa;IACxD,cAAc,EAAE,YAAY,CAAC;IAC7B,aAAa,EAAE,YAAY,CAAC;IAC5B,eAAe,CAAC,EAAE,cAAc,CAAC;CAClC"}
@@ -0,0 +1,18 @@
1
+ import { Multiaddr } from '@olane/o-config';
2
+ import { oNodeTransport } from './o-node.transport.js';
3
+ import { oAddress } from '@olane/o-core';
4
+ export declare class oNodeAddress extends oAddress {
5
+ readonly value: string;
6
+ transports: oNodeTransport[];
7
+ constructor(value: string, transports?: oNodeTransport[]);
8
+ static fromJSON(json: {
9
+ value: string;
10
+ transports: string[] | Multiaddr[];
11
+ }): oNodeAddress;
12
+ get libp2pTransports(): oNodeTransport[];
13
+ get customTransports(): oNodeTransport[];
14
+ toString(): string;
15
+ toMultiaddr(): Multiaddr;
16
+ static fromMultiaddr(ma: Multiaddr): oAddress;
17
+ }
18
+ //# sourceMappingURL=o-node.address.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"o-node.address.d.ts","sourceRoot":"","sources":["../../../../src/router/o-node.address.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAa,MAAM,iBAAiB,CAAC;AAEvD,OAAO,EAAE,cAAc,EAAE,MAAM,uBAAuB,CAAC;AACvD,OAAO,EAAqB,QAAQ,EAAiB,MAAM,eAAe,CAAC;AAE3E,qBAAa,YAAa,SAAQ,QAAQ;aAItB,KAAK,EAAE,MAAM;IAHxB,UAAU,EAAE,cAAc,EAAE,CAAM;gBAGvB,KAAK,EAAE,MAAM,EAC7B,UAAU,GAAE,cAAc,EAAO;IAMnC,MAAM,CAAC,QAAQ,CAAC,IAAI,EAAE;QACpB,KAAK,EAAE,MAAM,CAAC;QACd,UAAU,EAAE,MAAM,EAAE,GAAG,SAAS,EAAE,CAAC;KACpC,GAAG,YAAY;IAShB,IAAI,gBAAgB,IAAI,cAAc,EAAE,CAEvC;IAED,IAAI,gBAAgB,IAAI,cAAc,EAAE,CAEvC;IAED,QAAQ,IAAI,MAAM;IAIlB,WAAW,IAAI,SAAS;IAIxB,MAAM,CAAC,aAAa,CAAC,EAAE,EAAE,SAAS,GAAG,QAAQ;CAG9C"}
@@ -0,0 +1,29 @@
1
+ import { multiaddr } from '@olane/o-config';
2
+ import { oNodeTransport } from './o-node.transport.js';
3
+ import { oAddress, TransportType } from '@olane/o-core';
4
+ export class oNodeAddress extends oAddress {
5
+ constructor(value, transports = []) {
6
+ super(value);
7
+ this.value = value;
8
+ this.transports = [];
9
+ this.transports = transports;
10
+ }
11
+ static fromJSON(json) {
12
+ return new oNodeAddress(json.value, json.transports.map((t) => new oNodeTransport(t)));
13
+ }
14
+ get libp2pTransports() {
15
+ return this.transports.filter((t) => t.type === TransportType.LIBP2P) || [];
16
+ }
17
+ get customTransports() {
18
+ return this.transports.filter((t) => t.type === TransportType.CUSTOM) || [];
19
+ }
20
+ toString() {
21
+ return this.value;
22
+ }
23
+ toMultiaddr() {
24
+ return multiaddr(this.protocol);
25
+ }
26
+ static fromMultiaddr(ma) {
27
+ return new oAddress(ma.toString().replace('/o/', 'o://'));
28
+ }
29
+ }
@@ -0,0 +1,45 @@
1
+ import { oNodeAddress } from './o-node.address.js';
2
+ import { oRouterRequest, RouteResponse } from '@olane/o-core';
3
+ import type { oNode } from '../o-node.js';
4
+ import { oToolRouter } from '@olane/o-tool';
5
+ export declare class oNodeRouter extends oToolRouter {
6
+ private routingPolicy;
7
+ constructor();
8
+ /**
9
+ * Forwards a request to the specified address via libp2p transport.
10
+ * Handles self-routing (local execution) and destination detection.
11
+ *
12
+ * @param address The next hop address to forward to
13
+ * @param request The router request to forward
14
+ * @param node The current node context
15
+ * @returns The response from the forwarded request
16
+ */
17
+ protected forward(address: oNodeAddress, request: oRouterRequest, node: oNode): Promise<any>;
18
+ /**
19
+ * Executes a request locally when routing to self.
20
+ */
21
+ private executeSelfRouting;
22
+ /**
23
+ * Checks if the next hop is the final destination address.
24
+ */
25
+ private isDestinationAddress;
26
+ /**
27
+ * Unwraps the routing envelope when we've reached the destination.
28
+ */
29
+ private unwrapDestinationRequest;
30
+ /**
31
+ * Dials a remote node and transmits the request via libp2p.
32
+ */
33
+ private dialAndTransmit;
34
+ /**
35
+ * Translates an address to determine the next hop and target addresses.
36
+ * First checks routing policy for external routing, then applies resolver chain.
37
+ */
38
+ translate(address: oNodeAddress, node: oNode): Promise<RouteResponse>;
39
+ /**
40
+ * Determines if an address is internal to this node's hierarchy.
41
+ * Delegates to the routing policy for the decision.
42
+ */
43
+ isInternal(addressWithTransports: oNodeAddress, node: oNode): boolean;
44
+ }
45
+ //# sourceMappingURL=o-node.router.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"o-node.router.d.ts","sourceRoot":"","sources":["../../../../src/router/o-node.router.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,MAAM,qBAAqB,CAAC;AACnD,OAAO,EAML,cAAc,EACd,aAAa,EACd,MAAM,eAAe,CAAC;AACvB,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,cAAc,CAAC;AAC1C,OAAO,EAAE,WAAW,EAAE,MAAM,eAAe,CAAC;AAM5C,qBAAa,WAAY,SAAQ,WAAW;IAC1C,OAAO,CAAC,aAAa,CAAqB;;IAO1C;;;;;;;;OAQG;cACa,OAAO,CACrB,OAAO,EAAE,YAAY,EACrB,OAAO,EAAE,cAAc,EACvB,IAAI,EAAE,KAAK,GACV,OAAO,CAAC,GAAG,CAAC;IA0Bf;;OAEG;YACW,kBAAkB;IAgBhC;;OAEG;IACH,OAAO,CAAC,oBAAoB;IAS5B;;OAEG;IACH,OAAO,CAAC,wBAAwB;IAUhC;;OAEG;YACW,eAAe;IAsC7B;;;OAGG;IACG,SAAS,CAAC,OAAO,EAAE,YAAY,EAAE,IAAI,EAAE,KAAK,GAAG,OAAO,CAAC,aAAa,CAAC;IAyB3E;;;OAGG;IACH,UAAU,CAAC,qBAAqB,EAAE,YAAY,EAAE,IAAI,EAAE,KAAK,GAAG,OAAO;CAGtE"}
@@ -0,0 +1,135 @@
1
+ import { CoreUtils, oAddress, oError, oErrorCodes, oRequest, } from '@olane/o-core';
2
+ import { oToolRouter } from '@olane/o-tool';
3
+ import { oNodeConnection } from '../connection/o-node-connection.js';
4
+ import { oNodeRoutingPolicy } from './o-node.routing-policy.js';
5
+ export class oNodeRouter extends oToolRouter {
6
+ constructor() {
7
+ super();
8
+ this.routingPolicy = new oNodeRoutingPolicy();
9
+ }
10
+ /**
11
+ * Forwards a request to the specified address via libp2p transport.
12
+ * Handles self-routing (local execution) and destination detection.
13
+ *
14
+ * @param address The next hop address to forward to
15
+ * @param request The router request to forward
16
+ * @param node The current node context
17
+ * @returns The response from the forwarded request
18
+ */
19
+ async forward(address, request, node) {
20
+ if (!request.stream) {
21
+ throw new oError(oErrorCodes.INVALID_REQUEST, 'Stream is required');
22
+ }
23
+ let nextHopRequest = new oRequest({
24
+ method: request.method,
25
+ params: request.params,
26
+ id: request.id,
27
+ });
28
+ // Handle self-routing: execute locally instead of dialing
29
+ if (this.routingPolicy.isSelfAddress(address, node)) {
30
+ return this.executeSelfRouting(request, node);
31
+ }
32
+ // Check if we've reached the final destination
33
+ const isDestination = this.isDestinationAddress(address, request);
34
+ if (isDestination) {
35
+ nextHopRequest = this.unwrapDestinationRequest(request);
36
+ }
37
+ // Dial and transmit to remote node
38
+ return this.dialAndTransmit(address, nextHopRequest, node);
39
+ }
40
+ /**
41
+ * Executes a request locally when routing to self.
42
+ */
43
+ async executeSelfRouting(request, node) {
44
+ const { payload } = request.params;
45
+ const params = payload.params;
46
+ const localRequest = new oRequest({
47
+ method: payload.method,
48
+ params: { ...params },
49
+ id: request.id,
50
+ });
51
+ const result = await node.execute(localRequest);
52
+ return result;
53
+ }
54
+ /**
55
+ * Checks if the next hop is the final destination address.
56
+ */
57
+ isDestinationAddress(address, request) {
58
+ return address
59
+ ?.toStaticAddress()
60
+ .equals(new oAddress(request?.params?.address).toStaticAddress());
61
+ }
62
+ /**
63
+ * Unwraps the routing envelope when we've reached the destination.
64
+ */
65
+ unwrapDestinationRequest(request) {
66
+ const { payload } = request.params;
67
+ const params = payload.params;
68
+ return new oRequest({
69
+ method: payload.method,
70
+ params: { ...params },
71
+ id: request.id,
72
+ });
73
+ }
74
+ /**
75
+ * Dials a remote node and transmits the request via libp2p.
76
+ */
77
+ async dialAndTransmit(address, request, node) {
78
+ try {
79
+ const connection = await node.p2pNode.dial(address.libp2pTransports.map((t) => t.toMultiaddr()));
80
+ const nodeConnection = new oNodeConnection({
81
+ p2pConnection: connection,
82
+ nextHopAddress: address,
83
+ address: node.address,
84
+ callerAddress: node.address,
85
+ });
86
+ if (request.params._isStream) {
87
+ const routeRequest = request;
88
+ if (!routeRequest.stream) {
89
+ throw new oError(oErrorCodes.INVALID_REQUEST, 'Stream is required');
90
+ }
91
+ nodeConnection.onChunk((response) => {
92
+ CoreUtils.sendStreamResponse(response, routeRequest.stream);
93
+ });
94
+ // allow this to continue as we will tell the transmitter to stream the response and we will intercept via the above listener
95
+ }
96
+ const response = await nodeConnection.transmit(request);
97
+ return response.result.data;
98
+ }
99
+ catch (error) {
100
+ if (error?.name === 'UnsupportedProtocolError') {
101
+ throw new oError(oErrorCodes.NOT_FOUND, 'Address not found');
102
+ }
103
+ throw error;
104
+ }
105
+ }
106
+ /**
107
+ * Translates an address to determine the next hop and target addresses.
108
+ * First checks routing policy for external routing, then applies resolver chain.
109
+ */
110
+ async translate(address, node) {
111
+ // Check if external routing is needed
112
+ const externalRoute = this.routingPolicy.getExternalRoutingStrategy(address, node);
113
+ if (externalRoute) {
114
+ return externalRoute;
115
+ }
116
+ // Apply resolver chain for internal routing
117
+ const { nextHopAddress, targetAddress, requestOverride } = await this.addressResolution.resolve({
118
+ address,
119
+ node,
120
+ targetAddress: address,
121
+ });
122
+ return {
123
+ nextHopAddress,
124
+ targetAddress: targetAddress,
125
+ requestOverride,
126
+ };
127
+ }
128
+ /**
129
+ * Determines if an address is internal to this node's hierarchy.
130
+ * Delegates to the routing policy for the decision.
131
+ */
132
+ isInternal(addressWithTransports, node) {
133
+ return this.routingPolicy.isInternalAddress(addressWithTransports, node);
134
+ }
135
+ }
@@ -0,0 +1,30 @@
1
+ import { oAddress, oRoutingPolicy, RouteResponse } from '@olane/o-core';
2
+ import type { oNode } from '../o-node.js';
3
+ /**
4
+ * Routing policy implementation for oNode that handles internal/external routing decisions
5
+ * and leader-based routing strategies.
6
+ */
7
+ export declare class oNodeRoutingPolicy extends oRoutingPolicy {
8
+ /**
9
+ * Determines if an address is internal to the current node's hierarchy.
10
+ * An address is considered internal if:
11
+ * 1. It doesn't have leader references, OR
12
+ * 2. Its leader references match our known leaders
13
+ *
14
+ * @param address The address to check
15
+ * @param node The current node context
16
+ * @returns True if the address is internal to this hierarchy
17
+ */
18
+ isInternalAddress(address: oAddress, node: oNode): boolean;
19
+ /**
20
+ * Determines the routing strategy for external addresses.
21
+ * External addresses are routed to the leader of the external OS using
22
+ * the address's libp2p transports.
23
+ *
24
+ * @param address The address to evaluate
25
+ * @param node The current node context
26
+ * @returns RouteResponse if external routing is needed, null if internal
27
+ */
28
+ getExternalRoutingStrategy(address: oAddress, node: oNode): RouteResponse | null;
29
+ }
30
+ //# sourceMappingURL=o-node.routing-policy.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"o-node.routing-policy.d.ts","sourceRoot":"","sources":["../../../../src/router/o-node.routing-policy.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,cAAc,EAAE,aAAa,EAAE,MAAM,eAAe,CAAC;AACxE,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,cAAc,CAAC;AAG1C;;;GAGG;AACH,qBAAa,kBAAmB,SAAQ,cAAc;IACpD;;;;;;;;;OASG;IACH,iBAAiB,CAAC,OAAO,EAAE,QAAQ,EAAE,IAAI,EAAE,KAAK,GAAG,OAAO;IAuB1D;;;;;;;;OAQG;IACH,0BAA0B,CACxB,OAAO,EAAE,QAAQ,EACjB,IAAI,EAAE,KAAK,GACV,aAAa,GAAG,IAAI;CAmBxB"}