@xyo-network/chain-orchestration 1.17.2 → 1.17.3

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 (170) hide show
  1. package/dist/neutral/ChainInitializableParams.d.ts +11 -0
  2. package/dist/neutral/ChainInitializableParams.d.ts.map +1 -0
  3. package/dist/neutral/actor/Actor.d.ts.map +1 -1
  4. package/dist/neutral/actor/BalanceActor.d.ts +14 -0
  5. package/dist/neutral/actor/BalanceActor.d.ts.map +1 -0
  6. package/dist/neutral/actor/ValidatorActor.d.ts +23 -0
  7. package/dist/neutral/actor/ValidatorActor.d.ts.map +1 -0
  8. package/dist/neutral/actor/index.d.ts +2 -0
  9. package/dist/neutral/actor/index.d.ts.map +1 -1
  10. package/dist/neutral/archivists/ChainFinalized/archivist.d.ts +4 -0
  11. package/dist/neutral/archivists/ChainFinalized/archivist.d.ts.map +1 -0
  12. package/dist/neutral/archivists/ChainFinalized/index.d.ts +2 -0
  13. package/dist/neutral/archivists/ChainFinalized/index.d.ts.map +1 -0
  14. package/dist/neutral/archivists/ChainFinalized/local.d.ts +7 -0
  15. package/dist/neutral/archivists/ChainFinalized/local.d.ts.map +1 -0
  16. package/dist/neutral/archivists/PendingBlocks/archivist.d.ts +4 -0
  17. package/dist/neutral/archivists/PendingBlocks/archivist.d.ts.map +1 -0
  18. package/dist/neutral/archivists/PendingBlocks/index.d.ts +2 -0
  19. package/dist/neutral/archivists/PendingBlocks/index.d.ts.map +1 -0
  20. package/dist/neutral/archivists/PendingBlocks/local.d.ts +7 -0
  21. package/dist/neutral/archivists/PendingBlocks/local.d.ts.map +1 -0
  22. package/dist/neutral/archivists/PendingTransactions/archivist.d.ts +4 -0
  23. package/dist/neutral/archivists/PendingTransactions/archivist.d.ts.map +1 -0
  24. package/dist/neutral/archivists/PendingTransactions/index.d.ts +2 -0
  25. package/dist/neutral/archivists/PendingTransactions/index.d.ts.map +1 -0
  26. package/dist/neutral/archivists/PendingTransactions/local.d.ts +7 -0
  27. package/dist/neutral/archivists/PendingTransactions/local.d.ts.map +1 -0
  28. package/dist/neutral/archivists/RejectedTransactions/archivist.d.ts +4 -0
  29. package/dist/neutral/archivists/RejectedTransactions/archivist.d.ts.map +1 -0
  30. package/dist/neutral/archivists/RejectedTransactions/index.d.ts +2 -0
  31. package/dist/neutral/archivists/RejectedTransactions/index.d.ts.map +1 -0
  32. package/dist/neutral/archivists/RejectedTransactions/local.d.ts +4 -0
  33. package/dist/neutral/archivists/RejectedTransactions/local.d.ts.map +1 -0
  34. package/dist/neutral/archivists/StakeIntentState/archivist.d.ts +5 -0
  35. package/dist/neutral/archivists/StakeIntentState/archivist.d.ts.map +1 -0
  36. package/dist/neutral/archivists/StakeIntentState/index.d.ts +2 -0
  37. package/dist/neutral/archivists/StakeIntentState/index.d.ts.map +1 -0
  38. package/dist/neutral/archivists/StakeIntentState/local.d.ts +7 -0
  39. package/dist/neutral/archivists/StakeIntentState/local.d.ts.map +1 -0
  40. package/dist/neutral/archivists/index.d.ts +6 -0
  41. package/dist/neutral/archivists/index.d.ts.map +1 -0
  42. package/dist/neutral/archivists/lib/index.d.ts +2 -0
  43. package/dist/neutral/archivists/lib/index.d.ts.map +1 -0
  44. package/dist/neutral/archivists/lib/localPersistentArchivist.d.ts +21 -0
  45. package/dist/neutral/archivists/lib/localPersistentArchivist.d.ts.map +1 -0
  46. package/dist/neutral/buildTelemetryConfig.d.ts +13 -0
  47. package/dist/neutral/buildTelemetryConfig.d.ts.map +1 -0
  48. package/dist/neutral/health/index.d.ts +2 -0
  49. package/dist/neutral/health/index.d.ts.map +1 -0
  50. package/dist/neutral/health/initHealthEndpoints.d.ts +11 -0
  51. package/dist/neutral/health/initHealthEndpoints.d.ts.map +1 -0
  52. package/dist/neutral/host/implementation/DefaultHost.d.ts +12 -0
  53. package/dist/neutral/host/implementation/DefaultHost.d.ts.map +1 -0
  54. package/dist/neutral/host/implementation/DefaultServiceCollection.d.ts +24 -0
  55. package/dist/neutral/host/implementation/DefaultServiceCollection.d.ts.map +1 -0
  56. package/dist/neutral/host/implementation/DefaultServiceProvider.d.ts +7 -0
  57. package/dist/neutral/host/implementation/DefaultServiceProvider.d.ts.map +1 -0
  58. package/dist/neutral/host/implementation/index.d.ts +3 -0
  59. package/dist/neutral/host/implementation/index.d.ts.map +1 -0
  60. package/dist/neutral/host/index.d.ts +3 -0
  61. package/dist/neutral/host/index.d.ts.map +1 -0
  62. package/dist/neutral/host/model/Host.d.ts +19 -0
  63. package/dist/neutral/host/model/Host.d.ts.map +1 -0
  64. package/dist/neutral/host/model/ServiceCollection.d.ts +20 -0
  65. package/dist/neutral/host/model/ServiceCollection.d.ts.map +1 -0
  66. package/dist/neutral/host/model/ServiceProvider.d.ts +4 -0
  67. package/dist/neutral/host/model/ServiceProvider.d.ts.map +1 -0
  68. package/dist/neutral/host/model/index.d.ts +4 -0
  69. package/dist/neutral/host/model/index.d.ts.map +1 -0
  70. package/dist/neutral/index.d.ts +7 -2
  71. package/dist/neutral/index.d.ts.map +1 -1
  72. package/dist/neutral/index.mjs +701 -626
  73. package/dist/neutral/index.mjs.map +1 -1
  74. package/dist/neutral/init/index.d.ts +1 -2
  75. package/dist/neutral/init/index.d.ts.map +1 -1
  76. package/dist/neutral/init/initChainStakeViewer.d.ts +4 -1
  77. package/dist/neutral/init/initChainStakeViewer.d.ts.map +1 -1
  78. package/dist/neutral/init/initServerNode.d.ts +4 -2
  79. package/dist/neutral/init/initServerNode.d.ts.map +1 -1
  80. package/dist/neutral/init/initStatusReporter.d.ts +6 -0
  81. package/dist/neutral/init/initStatusReporter.d.ts.map +1 -0
  82. package/dist/neutral/manifest/getLocator.d.ts +1 -1
  83. package/dist/neutral/manifest/getLocator.d.ts.map +1 -1
  84. package/dist/neutral/manifest/loadNode.d.ts.map +1 -1
  85. package/dist/neutral/manifest/public/index.d.ts +5 -2
  86. package/dist/neutral/manifest/public/index.d.ts.map +1 -1
  87. package/dist/neutral/orchestrator/Orchestrator.d.ts +0 -2
  88. package/dist/neutral/orchestrator/Orchestrator.d.ts.map +1 -1
  89. package/dist/neutral/status/RuntimeStatusMonitor.d.ts +31 -0
  90. package/dist/neutral/status/RuntimeStatusMonitor.d.ts.map +1 -0
  91. package/dist/neutral/status/ServiceStatus.d.ts +8 -0
  92. package/dist/neutral/status/ServiceStatus.d.ts.map +1 -0
  93. package/dist/neutral/status/index.d.ts +3 -0
  94. package/dist/neutral/status/index.d.ts.map +1 -0
  95. package/package.json +15 -17
  96. package/src/ChainInitializableParams.ts +12 -0
  97. package/src/actor/Actor.ts +0 -1
  98. package/src/actor/BalanceActor.ts +36 -0
  99. package/src/actor/ValidatorActor.ts +126 -0
  100. package/src/actor/index.ts +2 -0
  101. package/src/archivists/ChainFinalized/archivist.ts +21 -0
  102. package/src/archivists/ChainFinalized/index.ts +1 -0
  103. package/src/archivists/ChainFinalized/local.ts +18 -0
  104. package/src/archivists/PendingBlocks/archivist.ts +21 -0
  105. package/src/archivists/PendingBlocks/index.ts +1 -0
  106. package/src/archivists/PendingBlocks/local.ts +18 -0
  107. package/src/archivists/PendingTransactions/archivist.ts +21 -0
  108. package/src/archivists/PendingTransactions/index.ts +1 -0
  109. package/src/archivists/PendingTransactions/local.ts +18 -0
  110. package/src/archivists/RejectedTransactions/archivist.ts +21 -0
  111. package/src/archivists/RejectedTransactions/index.ts +1 -0
  112. package/src/archivists/RejectedTransactions/local.ts +20 -0
  113. package/src/archivists/StakeIntentState/archivist.ts +24 -0
  114. package/src/archivists/StakeIntentState/index.ts +1 -0
  115. package/src/archivists/StakeIntentState/local.ts +19 -0
  116. package/src/archivists/index.ts +5 -0
  117. package/src/archivists/lib/index.ts +1 -0
  118. package/src/archivists/lib/localPersistentArchivist.ts +63 -0
  119. package/src/buildTelemetryConfig.ts +15 -0
  120. package/src/health/index.ts +1 -0
  121. package/src/health/initHealthEndpoints.ts +71 -0
  122. package/src/host/implementation/DefaultHost.ts +25 -0
  123. package/src/host/implementation/DefaultServiceCollection.ts +60 -0
  124. package/src/host/implementation/DefaultServiceProvider.ts +12 -0
  125. package/src/host/implementation/index.ts +2 -0
  126. package/src/host/index.ts +2 -0
  127. package/src/host/model/Host.ts +21 -0
  128. package/src/host/model/ServiceCollection.ts +22 -0
  129. package/src/host/model/ServiceProvider.ts +3 -0
  130. package/src/host/model/index.ts +3 -0
  131. package/src/index.ts +7 -2
  132. package/src/init/index.ts +1 -2
  133. package/src/init/initChainStakeViewer.ts +1 -1
  134. package/src/init/initServerNode.ts +26 -12
  135. package/src/init/initStatusReporter.ts +16 -0
  136. package/src/manifest/getLocator.ts +2 -33
  137. package/src/manifest/loadNode.ts +1 -3
  138. package/src/manifest/public/{WithoutMempool/Pending.json → Chain.json} +18 -18
  139. package/src/manifest/public/{WithMempool/Pending.json → Pending.json} +2 -2
  140. package/src/manifest/public/index.ts +20 -2
  141. package/src/orchestrator/Orchestrator.ts +0 -2
  142. package/src/status/RuntimeStatusMonitor.ts +117 -0
  143. package/src/status/ServiceStatus.ts +20 -0
  144. package/src/status/index.ts +2 -0
  145. package/dist/neutral/archivist/index.d.ts +0 -3
  146. package/dist/neutral/archivist/index.d.ts.map +0 -1
  147. package/dist/neutral/archivist/initArchivistSync.d.ts +0 -6
  148. package/dist/neutral/archivist/initArchivistSync.d.ts.map +0 -1
  149. package/dist/neutral/archivist/wrapWithReadCachingArchivist.d.ts +0 -5
  150. package/dist/neutral/archivist/wrapWithReadCachingArchivist.d.ts.map +0 -1
  151. package/dist/neutral/bridge.d.ts +0 -3
  152. package/dist/neutral/bridge.d.ts.map +0 -1
  153. package/dist/neutral/init/initPendingBlockArchivist.d.ts +0 -4
  154. package/dist/neutral/init/initPendingBlockArchivist.d.ts.map +0 -1
  155. package/dist/neutral/init/initPendingTransactionArchivist.d.ts +0 -4
  156. package/dist/neutral/init/initPendingTransactionArchivist.d.ts.map +0 -1
  157. package/dist/neutral/manifest/public/WithMempool/index.d.ts +0 -6
  158. package/dist/neutral/manifest/public/WithMempool/index.d.ts.map +0 -1
  159. package/dist/neutral/manifest/public/WithoutMempool/index.d.ts +0 -6
  160. package/dist/neutral/manifest/public/WithoutMempool/index.d.ts.map +0 -1
  161. package/src/archivist/index.ts +0 -2
  162. package/src/archivist/initArchivistSync.ts +0 -61
  163. package/src/archivist/wrapWithReadCachingArchivist.ts +0 -56
  164. package/src/bridge.ts +0 -25
  165. package/src/init/initPendingBlockArchivist.ts +0 -31
  166. package/src/init/initPendingTransactionArchivist.ts +0 -31
  167. package/src/manifest/public/WithMempool/Chain.json +0 -175
  168. package/src/manifest/public/WithMempool/index.ts +0 -20
  169. package/src/manifest/public/WithoutMempool/Chain.json +0 -97
  170. package/src/manifest/public/WithoutMempool/index.ts +0 -20
@@ -0,0 +1,117 @@
1
+ import type { CreatableName, CreatableStatus } from '@xylabs/sdk-js'
2
+
3
+ import { LoggerStatusReporter } from './ServiceStatus.ts'
4
+
5
+ /**
6
+ * Enum-like record for statuses with priority allowing
7
+ * for determination of the aggregated status.
8
+ */
9
+ const statusPriority: Record<CreatableStatus, number> = {
10
+ error: 0,
11
+ stopped: 1,
12
+ stopping: 2,
13
+ creating: 3,
14
+ created: 4,
15
+ starting: 5,
16
+ started: 6,
17
+ }
18
+
19
+ /**
20
+ * A sentinel status that represents the initial state
21
+ * before any statuses are reported.
22
+ * It is used to ensure that the monitor has a valid status
23
+ * even when no statuses have been reported yet and to
24
+ * prevent the system from showing an "error" state
25
+ * when no statuses are available.
26
+ */
27
+ const SENTINEL_STATUS: CreatableStatus = 'starting'
28
+
29
+ /**
30
+ * Given an array of statuses, this function reduces them
31
+ * to the minimum status based on the defined priority.
32
+ * @param statuses An array of statuses to reduce.
33
+ * @returns The minimum status based on priority.
34
+ */
35
+ const reduceToMinimumStatus = (statuses: CreatableStatus[]): CreatableStatus => {
36
+ let minStatus: CreatableStatus = SENTINEL_STATUS
37
+ let minPriority = Infinity
38
+
39
+ for (const status of statuses) {
40
+ const priority = statusPriority[status]
41
+ if (priority < minPriority) {
42
+ minPriority = priority
43
+ minStatus = status
44
+ }
45
+ }
46
+ return minStatus
47
+ }
48
+
49
+ export type GlobalTransitionHandler = {
50
+ from?: CreatableStatus
51
+ handler: (from: CreatableStatus, to: CreatableStatus) => void
52
+ to?: CreatableStatus
53
+ }
54
+ export type TransitionHandler = GlobalTransitionHandler & {
55
+ name?: string
56
+ }
57
+
58
+ export class RuntimeStatusMonitor extends LoggerStatusReporter {
59
+ private globalTransitions: GlobalTransitionHandler[] = []
60
+ private transitions: TransitionHandler[] = []
61
+
62
+ getGlobalStatus(): CreatableStatus {
63
+ // If no statuses have been reported, return the sentinel status
64
+ if (Object.keys(this.statusMap).length === 0) return SENTINEL_STATUS
65
+ return reduceToMinimumStatus(Object.values(this.statusMap))
66
+ }
67
+
68
+ getStatus(name: CreatableName): CreatableStatus | undefined {
69
+ return this.statusMap[name]
70
+ }
71
+
72
+ onGlobalTransition(match: { from?: CreatableStatus; to?: CreatableStatus }, handler: (from: CreatableStatus, to: CreatableStatus) => void) {
73
+ this.globalTransitions.push({ ...match, handler })
74
+ }
75
+
76
+ /**
77
+ * Register a callback to be called on a specific transition.
78
+ */
79
+ onTransition(match: { from?: CreatableStatus; name: string; to?: CreatableStatus }, handler: (from: CreatableStatus, to: CreatableStatus) => void) {
80
+ this.transitions.push({ ...match, handler })
81
+ }
82
+
83
+ override report(name: CreatableName, status: CreatableStatus, progress?: number | Error): void {
84
+ // Capture the current status before updating
85
+ const previous = this.statusMap[name]
86
+ const previousGlobal = this.getGlobalStatus()
87
+
88
+ // Update the status map with the new status
89
+ super.report(name, status, progress)
90
+
91
+ // If the status hasn't changed, do not run handlers
92
+ if (previous === status) return
93
+ this.runTransitions(this.transitions, previous, status, name)
94
+
95
+ // If the global status hasn't changed, do not run handlers
96
+ const globalStatus = this.getGlobalStatus()
97
+ if (previousGlobal === globalStatus) return
98
+ this.runTransitions(this.globalTransitions, previousGlobal, globalStatus)
99
+ }
100
+
101
+ private runTransitions(
102
+ transitions: (TransitionHandler | GlobalTransitionHandler)[],
103
+ prev: CreatableStatus,
104
+ next: CreatableStatus,
105
+ name?: string,
106
+ ) {
107
+ for (const {
108
+ from, to, name: matchName, handler,
109
+ } of transitions as TransitionHandler[]) {
110
+ if ((matchName === undefined || matchName === name)
111
+ && (from === undefined || from === prev)
112
+ && (to === undefined || to === next)) {
113
+ handler(prev, next)
114
+ }
115
+ }
116
+ }
117
+ }
@@ -0,0 +1,20 @@
1
+ import type {
2
+ CreatableName, CreatableStatus, CreatableStatusReporter, Logger,
3
+ } from '@xylabs/sdk-js'
4
+
5
+ export class LoggerStatusReporter implements CreatableStatusReporter {
6
+ protected logger: Logger
7
+
8
+ protected statusMap: Record<CreatableName, CreatableStatus> = {}
9
+
10
+ constructor(logger: Logger) {
11
+ this.logger = logger
12
+ }
13
+
14
+ report(name: CreatableName, status: CreatableStatus, progress?: number | Error): void {
15
+ this.statusMap[name] = status
16
+ const starting = (Object.entries(this.statusMap).map(([, value]): number => value === 'starting' ? 1 : 0)).reduce((a, b) => a + b, 0)
17
+ const started = (Object.entries(this.statusMap).map(([, value]): number => value === 'started' ? 1 : 0)).reduce((a, b) => a + b, 0)
18
+ this.logger.info(`${started}/${starting + started} ${name} status: ${status}`, { progress })
19
+ }
20
+ }
@@ -0,0 +1,2 @@
1
+ export * from './RuntimeStatusMonitor.ts'
2
+ export * from './ServiceStatus.ts'
@@ -1,3 +0,0 @@
1
- export * from './initArchivistSync.ts';
2
- export * from './wrapWithReadCachingArchivist.ts';
3
- //# sourceMappingURL=index.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/archivist/index.ts"],"names":[],"mappings":"AAAA,cAAc,wBAAwB,CAAA;AACtC,cAAc,mCAAmC,CAAA"}
@@ -1,6 +0,0 @@
1
- import type { TracerProvider } from '@opentelemetry/api';
2
- import type { ArchivistInstance } from '@xyo-network/archivist-model';
3
- import type { ModuleIdentifier } from '@xyo-network/module-model';
4
- import { MemoryNode } from '@xyo-network/node-memory';
5
- export declare const initArchivistSync: (name: ModuleIdentifier, inArchivist: ArchivistInstance, outArchivist: ArchivistInstance, frequency?: number, max?: number, traceProvider?: TracerProvider) => Promise<MemoryNode<import("@xyo-network/node-memory").MemoryNodeParams, import("@xyo-network/node-model").NodeModuleEventData>>;
6
- //# sourceMappingURL=initArchivistSync.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"initArchivistSync.d.ts","sourceRoot":"","sources":["../../../src/archivist/initArchivistSync.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,oBAAoB,CAAA;AACxD,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,8BAA8B,CAAA;AAGrE,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,2BAA2B,CAAA;AACjE,OAAO,EAAE,UAAU,EAAE,MAAM,0BAA0B,CAAA;AAIrD,eAAO,MAAM,iBAAiB,GAC5B,MAAM,gBAAgB,EACtB,aAAa,iBAAiB,EAC9B,cAAc,iBAAiB,EAC/B,kBAAgB,EAChB,YAAU,EACV,gBAAgB,cAAc,oIA6C/B,CAAA"}
@@ -1,5 +0,0 @@
1
- import type { MemoryArchivistConfig } from '@xyo-network/archivist-memory';
2
- import type { AttachableArchivistInstance } from '@xyo-network/archivist-model';
3
- export declare const DefaultReadCachingArchivistConfig: MemoryArchivistConfig;
4
- export declare const wrapWithReadCachingArchivist: (archivist: AttachableArchivistInstance, config?: Partial<MemoryArchivistConfig>) => Promise<AttachableArchivistInstance>;
5
- //# sourceMappingURL=wrapWithReadCachingArchivist.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"wrapWithReadCachingArchivist.d.ts","sourceRoot":"","sources":["../../../src/archivist/wrapWithReadCachingArchivist.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,qBAAqB,EAAE,MAAM,+BAA+B,CAAA;AAE1E,OAAO,KAAK,EAAE,2BAA2B,EAAE,MAAM,8BAA8B,CAAA;AAI/E,eAAO,MAAM,iCAAiC,EAAE,qBAI/C,CAAA;AAkBD,eAAO,MAAM,4BAA4B,GACvC,WAAW,2BAA2B,EACtC,SAAQ,OAAO,CAAC,qBAAqB,CAAqC,KACzE,OAAO,CAAC,2BAA2B,CAwBrC,CAAA"}
@@ -1,3 +0,0 @@
1
- import type { AttachableBridgeInstance } from '@xyo-network/bridge-model';
2
- export declare const initBridge: (nodeUrl: string) => Promise<AttachableBridgeInstance>;
3
- //# sourceMappingURL=bridge.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"bridge.d.ts","sourceRoot":"","sources":["../../src/bridge.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,wBAAwB,EAAE,MAAM,2BAA2B,CAAA;AAMzE,eAAO,MAAM,UAAU,GAAU,SAAS,MAAM,KAAG,OAAO,CAAC,wBAAwB,CAiBlF,CAAA"}
@@ -1,4 +0,0 @@
1
- import type { ArchivistInstance } from '@xyo-network/archivist-model';
2
- import type { ConfigContext } from '../ConfigContext.ts';
3
- export declare function initPendingBlockArchivist({ config, logger }: ConfigContext): Promise<ArchivistInstance>;
4
- //# sourceMappingURL=initPendingBlockArchivist.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"initPendingBlockArchivist.d.ts","sourceRoot":"","sources":["../../../src/init/initPendingBlockArchivist.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,8BAA8B,CAAA;AAIrE,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,qBAAqB,CAAA;AAExD,wBAAsB,yBAAyB,CAAC,EAAE,MAAM,EAAE,MAAM,EAAE,EAAE,aAAa,GAAG,OAAO,CAAC,iBAAiB,CAAC,CAsB7G"}
@@ -1,4 +0,0 @@
1
- import type { ArchivistInstance } from '@xyo-network/archivist-model';
2
- import type { ConfigContext } from '../ConfigContext.ts';
3
- export declare function initPendingTransactionArchivist({ config, logger }: ConfigContext): Promise<ArchivistInstance>;
4
- //# sourceMappingURL=initPendingTransactionArchivist.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"initPendingTransactionArchivist.d.ts","sourceRoot":"","sources":["../../../src/init/initPendingTransactionArchivist.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,8BAA8B,CAAA;AAIrE,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,qBAAqB,CAAA;AAExD,wBAAsB,+BAA+B,CAAC,EAAE,MAAM,EAAE,MAAM,EAAE,EAAE,aAAa,GAAG,OAAO,CAAC,iBAAiB,CAAC,CAsBnH"}
@@ -1,6 +0,0 @@
1
- import type { ModuleManifest } from '@xyo-network/manifest-model';
2
- /**
3
- * Public Child Manifests
4
- */
5
- export declare const PublicChildManifestsWithMempool: ModuleManifest[];
6
- //# sourceMappingURL=index.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../../src/manifest/public/WithMempool/index.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,cAAc,EAA0B,MAAM,6BAA6B,CAAA;AAazF;;GAEG;AACH,eAAO,MAAM,+BAA+B,EAAE,cAAc,EAG3D,CAAA"}
@@ -1,6 +0,0 @@
1
- import type { ModuleManifest } from '@xyo-network/manifest-model';
2
- /**
3
- * Public Child Manifests
4
- */
5
- export declare const PublicChildManifestsWithoutMempool: ModuleManifest[];
6
- //# sourceMappingURL=index.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../../src/manifest/public/WithoutMempool/index.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,cAAc,EAA0B,MAAM,6BAA6B,CAAA;AAazF;;GAEG;AACH,eAAO,MAAM,kCAAkC,EAAE,cAAc,EAG9D,CAAA"}
@@ -1,2 +0,0 @@
1
- export * from './initArchivistSync.ts'
2
- export * from './wrapWithReadCachingArchivist.ts'
@@ -1,61 +0,0 @@
1
- import type { TracerProvider } from '@opentelemetry/api'
2
- import type { ArchivistInstance } from '@xyo-network/archivist-model'
3
- import { ArchivistSyncDiviner } from '@xyo-network/chain-modules'
4
- import { DivinerConfigSchema } from '@xyo-network/diviner-model'
5
- import type { ModuleIdentifier } from '@xyo-network/module-model'
6
- import { MemoryNode } from '@xyo-network/node-memory'
7
- import { MemorySentinel } from '@xyo-network/sentinel-memory'
8
- import { SentinelConfigSchema } from '@xyo-network/sentinel-model'
9
-
10
- export const initArchivistSync = async (
11
- name: ModuleIdentifier,
12
- inArchivist: ArchivistInstance,
13
- outArchivist: ArchivistInstance,
14
- frequency = 1000,
15
- max = 1000,
16
- traceProvider?: TracerProvider,
17
- ) => {
18
- const node = await MemoryNode.create({ account: 'random' })
19
- const finalizedArchivistSyncDiviner = await ArchivistSyncDiviner.create({
20
- account: 'random',
21
- inArchivist,
22
- outArchivist,
23
- traceProvider,
24
- config: {
25
- schema: DivinerConfigSchema, name, max,
26
- },
27
- })
28
-
29
- await node.register(finalizedArchivistSyncDiviner)
30
- await node.attach(finalizedArchivistSyncDiviner.address)
31
-
32
- const sentinel = await MemorySentinel.create({
33
- account: 'random',
34
- config: {
35
- name,
36
- synchronous: true,
37
- schema: SentinelConfigSchema,
38
- tasks: [
39
- {
40
- required: true,
41
- mod: finalizedArchivistSyncDiviner.address,
42
- endPoint: 'divine',
43
- },
44
- ],
45
- automations: [
46
- {
47
- frequency,
48
- frequencyUnits: 'millis',
49
- schema: 'network.xyo.automation.interval',
50
- start: Date.now(),
51
- type: 'interval',
52
- },
53
- ],
54
- },
55
- })
56
-
57
- await node.register(sentinel)
58
- await node.attach(sentinel.address)
59
-
60
- return node
61
- }
@@ -1,56 +0,0 @@
1
- import type { MemoryArchivistConfig } from '@xyo-network/archivist-memory'
2
- import { MemoryArchivist, MemoryArchivistConfigSchema } from '@xyo-network/archivist-memory'
3
- import type { AttachableArchivistInstance } from '@xyo-network/archivist-model'
4
-
5
- import { initArchivistSync } from './initArchivistSync.ts'
6
-
7
- export const DefaultReadCachingArchivistConfig: MemoryArchivistConfig = {
8
- max: 100_000,
9
- // requireAllParents: true,
10
- schema: MemoryArchivistConfigSchema,
11
- }
12
-
13
- const getDynamicDefaultReadCachingArchivistConfig = (archivist: AttachableArchivistInstance): Partial<MemoryArchivistConfig> => {
14
- const { id } = archivist
15
- const name = `${id}-CachingArchivist`
16
- const dynamicDefaults: Partial<MemoryArchivistConfig> = { name }
17
- return dynamicDefaults
18
- }
19
-
20
- const getDynamicReadCachingArchivistConfig = (_archivist: AttachableArchivistInstance): Partial<MemoryArchivistConfig> => {
21
- // const parents = {
22
- // read: [archivist.address], write: [], commit: [],
23
- // }
24
- // const dynamicConfig: Partial<MemoryArchivistConfig> = { parents }
25
- const dynamicConfig: Partial<MemoryArchivistConfig> = {}
26
- return dynamicConfig
27
- }
28
-
29
- export const wrapWithReadCachingArchivist = async (
30
- archivist: AttachableArchivistInstance,
31
- config: Partial<MemoryArchivistConfig> = DefaultReadCachingArchivistConfig,
32
- ): Promise<AttachableArchivistInstance> => {
33
- const dynamicDefaultReadCachingArchivistConfig = getDynamicDefaultReadCachingArchivistConfig(archivist)
34
- const dynamicReadCachingArchivistConfig = getDynamicReadCachingArchivistConfig(archivist)
35
-
36
- // Create a materialized config with precedence
37
- const materializedConfig: MemoryArchivistConfig = {
38
- // Use the static defaults
39
- ...DefaultReadCachingArchivistConfig,
40
- // Use the dynamic defaults
41
- ...dynamicDefaultReadCachingArchivistConfig,
42
- // Use the supplied config
43
- ...config,
44
- // Use they dynamic config
45
- ...dynamicReadCachingArchivistConfig,
46
- }
47
- const cachingArchivist = await MemoryArchivist.create({ account: 'random', config: materializedConfig })
48
- await initArchivistSync(
49
- `${cachingArchivist.id}-Sync`,
50
- archivist,
51
- cachingArchivist,
52
- 1000,
53
- )
54
-
55
- return cachingArchivist
56
- }
package/src/bridge.ts DELETED
@@ -1,25 +0,0 @@
1
- import { HttpBridge, HttpBridgeConfigSchema } from '@xyo-network/bridge-http'
2
- import type { AttachableBridgeInstance } from '@xyo-network/bridge-model'
3
- import { Mutex } from 'async-mutex'
4
-
5
- const initMutex = new Mutex()
6
- const bridgeSingletonMap = new Map<string, AttachableBridgeInstance>()
7
-
8
- export const initBridge = async (nodeUrl: string): Promise<AttachableBridgeInstance> => {
9
- return await initMutex.runExclusive(async () => {
10
- const existing = bridgeSingletonMap.get(nodeUrl)
11
- if (existing) return existing
12
- const bridge = await HttpBridge.create({
13
- account: 'random',
14
- config: {
15
- name: 'HttpBridge',
16
- client: { url: nodeUrl, discoverRoots: 'start' },
17
- schema: HttpBridgeConfigSchema,
18
- security: { allowAnonymous: true },
19
- },
20
- })
21
- await bridge.start()
22
- bridgeSingletonMap.set(nodeUrl, bridge)
23
- return bridge
24
- })
25
- }
@@ -1,31 +0,0 @@
1
- import { type BaseMongoSdkPrivateConfig } from '@xylabs/mongo'
2
- import { MemoryArchivist } from '@xyo-network/archivist-memory'
3
- import type { ArchivistInstance } from '@xyo-network/archivist-model'
4
- import { MongoDBArchivistV2 } from '@xyo-network/archivist-mongodb'
5
- import { hasMongoConfig } from '@xyo-network/xl1-protocol-sdk'
6
-
7
- import type { ConfigContext } from '../ConfigContext.ts'
8
-
9
- export async function initPendingBlockArchivist({ config, logger }: ConfigContext): Promise<ArchivistInstance> {
10
- const mongoConfig = config.storage?.mongo
11
- if (hasMongoConfig(mongoConfig)) {
12
- // Create the MongoDB SDK from the configuration
13
- const {
14
- connectionString: dbConnectionString, database: dbName, domain: dbDomain, password: dbPassword, username: dbUserName,
15
- } = mongoConfig
16
- const payloadSdkConfig: BaseMongoSdkPrivateConfig = {
17
- dbConnectionString, dbDomain, dbName, dbPassword, dbUserName,
18
- }
19
-
20
- return await MongoDBArchivistV2.create({
21
- payloadSdkConfig: {
22
- ...payloadSdkConfig,
23
- collection: 'pending_block_bundles',
24
- },
25
- logger,
26
- })
27
- } else {
28
- logger?.warn('[API] Mongo configuration not found. Using MemoryArchivist for TransferSummaryMap.')
29
- return await MemoryArchivist.create()
30
- }
31
- }
@@ -1,31 +0,0 @@
1
- import { type BaseMongoSdkPrivateConfig } from '@xylabs/mongo'
2
- import { MemoryArchivist } from '@xyo-network/archivist-memory'
3
- import type { ArchivistInstance } from '@xyo-network/archivist-model'
4
- import { MongoDBArchivistV2 } from '@xyo-network/archivist-mongodb'
5
- import { hasMongoConfig } from '@xyo-network/xl1-protocol-sdk'
6
-
7
- import type { ConfigContext } from '../ConfigContext.ts'
8
-
9
- export async function initPendingTransactionArchivist({ config, logger }: ConfigContext): Promise<ArchivistInstance> {
10
- const mongoConfig = config.storage?.mongo
11
- if (hasMongoConfig(mongoConfig)) {
12
- // Create the MongoDB SDK from the configuration
13
- const {
14
- connectionString: dbConnectionString, database: dbName, domain: dbDomain, password: dbPassword, username: dbUserName,
15
- } = mongoConfig
16
- const payloadSdkConfig: BaseMongoSdkPrivateConfig = {
17
- dbConnectionString, dbDomain, dbName, dbPassword, dbUserName,
18
- }
19
-
20
- return await MongoDBArchivistV2.create({
21
- payloadSdkConfig: {
22
- ...payloadSdkConfig,
23
- collection: 'pending_transaction_bundles',
24
- },
25
- logger,
26
- })
27
- } else {
28
- logger?.warn('[API] Mongo configuration not found. Using MemoryArchivist for TransferSummaryMap.')
29
- return await MemoryArchivist.create()
30
- }
31
- }
@@ -1,175 +0,0 @@
1
- {
2
- "$schema": "https://raw.githubusercontent.com/XYOracleNetwork/sdk-xyo-client-js/main/packages/manifest/src/schema.json",
3
- "nodes": [
4
- {
5
- "config": {
6
- "accountPath": "1",
7
- "name": "Chain",
8
- "schema": "network.xyo.node.config"
9
- },
10
- "modules": {
11
- "private": [
12
- {
13
- "config": {
14
- "accountPath": "1/1'/1'",
15
- "name": "Validated",
16
- "getCache": {
17
- "enabled": true,
18
- "maxEntries": 5000
19
- },
20
- "payloadSdkConfig": {
21
- "collection": "chain_validated"
22
- },
23
- "schema": "network.xyo.archivist.config"
24
- }
25
- },
26
- {
27
- "config": {
28
- "accountPath": "1/1'/2'",
29
- "schema": "network.xyo.diviner.chain.head.validation.config",
30
- "eventSubscriptions": [
31
- {
32
- "sourceEvent": "inserted",
33
- "sourceModule": "Submissions",
34
- "targetModuleFunction": "divine"
35
- }
36
- ],
37
- "inArchivist": "Submissions",
38
- "outArchivist": "Validated",
39
- "name": "HeadValidationDiviner"
40
- }
41
- },
42
- {
43
- "config": {
44
- "accountPath": "1/1'/3'",
45
- "automations": [
46
- {
47
- "frequency": 1000,
48
- "frequencyUnits": "millis",
49
- "schema": "network.xyo.automation.interval",
50
- "type": "interval"
51
- }
52
- ],
53
- "name": "ChainValidationSentinel",
54
- "schema": "network.xyo.sentinel.config",
55
- "synchronous": true,
56
- "tasks": [
57
- {
58
- "mod": "HeadValidationDiviner",
59
- "endPoint": "divine"
60
- }
61
- ]
62
- }
63
- },
64
- {
65
- "config": {
66
- "accountPath": "1/1'/4'",
67
- "automations": [
68
- {
69
- "frequency": 10000,
70
- "frequencyUnits": "millis",
71
- "schema": "network.xyo.automation.interval",
72
- "type": "interval"
73
- }
74
- ],
75
- "name": "AddressBalancePollingSentinel",
76
- "schema": "network.xyo.sentinel.config",
77
- "synchronous": true,
78
- "tasks": [
79
- {
80
- "mod": "AddressBalanceDiviner",
81
- "endPoint": "divine"
82
- }
83
- ]
84
- }
85
- },
86
- {
87
- "config": {
88
- "accountPath": "1/1'/5'",
89
- "automations": [
90
- {
91
- "frequency": 10000,
92
- "frequencyUnits": "millis",
93
- "schema": "network.xyo.automation.interval",
94
- "type": "interval"
95
- }
96
- ],
97
- "name": "AddressTransferPollingSentinel",
98
- "schema": "network.xyo.sentinel.config",
99
- "synchronous": true,
100
- "tasks": [
101
- {
102
- "mod": "AddressTransferDiviner",
103
- "endPoint": "divine"
104
- }
105
- ]
106
- }
107
- }
108
- ],
109
- "public": [
110
- {
111
- "config": {
112
- "accountPath": "1/1/1",
113
- "name": "Submissions",
114
- "getCache": {
115
- "enabled": true,
116
- "maxEntries": 5000
117
- },
118
- "payloadSdkConfig": {
119
- "collection": "chain_submissions"
120
- },
121
- "schema": "network.xyo.archivist.config"
122
- }
123
- },
124
- {
125
- "config": {
126
- "accountPath": "1/1/2",
127
- "name": "Finalized",
128
- "allowedQueries": [
129
- "network.xyo.query.archivist.get",
130
- "network.xyo.query.archivist.next"
131
- ],
132
- "getCache": {
133
- "enabled": true,
134
- "maxEntries": 50000
135
- },
136
- "originArchivist": "Validated",
137
- "schema": "network.xyo.archivist.view.config"
138
- }
139
- },
140
- {
141
- "config": {
142
- "accountPath": "1/1/3'",
143
- "name": "AddressBalanceDiviner",
144
- "schema": "network.xyo.diviner.chain.address.balance.config",
145
- "map": {
146
- "lmdb": {
147
- "dbName": "summaries",
148
- "storeName": "address_balance",
149
- "location": ".store"
150
- }
151
- },
152
- "archivist": "Validated"
153
- }
154
- },
155
- {
156
- "config": {
157
- "accountPath": "1/1/4'",
158
- "name": "AddressTransferDiviner",
159
- "schema": "network.xyo.diviner.chain.address.transfer.config",
160
- "map": {
161
- "lmdb": {
162
- "dbName": "summaries",
163
- "storeName": "address_transfer",
164
- "location": ".store"
165
- }
166
- },
167
- "archivist": "Validated"
168
- }
169
- }
170
- ]
171
- }
172
- }
173
- ],
174
- "schema": "network.xyo.manifest"
175
- }
@@ -1,20 +0,0 @@
1
- import type { ModuleManifest, PackageManifestPayload } from '@xyo-network/manifest-model'
2
-
3
- import Chain from './Chain.json' with { type: 'json' }
4
- import Pending from './Pending.json' with { type: 'json' }
5
-
6
- /**
7
- * Chain Node Manifest
8
- */
9
- const ChainNodeManifest = Chain as PackageManifestPayload
10
- /**
11
- * Pending Node Manifest
12
- */
13
- const PendingNodeManifest = Pending as PackageManifestPayload
14
- /**
15
- * Public Child Manifests
16
- */
17
- export const PublicChildManifestsWithMempool: ModuleManifest[] = [
18
- ...ChainNodeManifest.nodes,
19
- ...PendingNodeManifest.nodes,
20
- ]