@xyo-network/chain-orchestration 1.17.0 → 1.17.1

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 (34) hide show
  1. package/dist/neutral/actor/Actor.d.ts +45 -0
  2. package/dist/neutral/actor/Actor.d.ts.map +1 -0
  3. package/dist/neutral/actor/index.d.ts +2 -0
  4. package/dist/neutral/actor/index.d.ts.map +1 -0
  5. package/dist/neutral/index.d.ts +2 -0
  6. package/dist/neutral/index.d.ts.map +1 -1
  7. package/dist/neutral/index.mjs +293 -16
  8. package/dist/neutral/index.mjs.map +1 -1
  9. package/dist/neutral/init/index.d.ts +2 -0
  10. package/dist/neutral/init/index.d.ts.map +1 -1
  11. package/dist/neutral/init/initChainStakeViewer.d.ts +1 -1
  12. package/dist/neutral/init/initChainStakeViewer.d.ts.map +1 -1
  13. package/dist/neutral/init/initPendingBlockArchivist.d.ts +4 -0
  14. package/dist/neutral/init/initPendingBlockArchivist.d.ts.map +1 -0
  15. package/dist/neutral/init/initPendingTransactionArchivist.d.ts +4 -0
  16. package/dist/neutral/init/initPendingTransactionArchivist.d.ts.map +1 -0
  17. package/dist/neutral/orchestrator/Orchestrator.d.ts +27 -0
  18. package/dist/neutral/orchestrator/Orchestrator.d.ts.map +1 -0
  19. package/dist/neutral/orchestrator/index.d.ts +2 -0
  20. package/dist/neutral/orchestrator/index.d.ts.map +1 -0
  21. package/package.json +33 -32
  22. package/src/actor/Actor.ts +163 -0
  23. package/src/actor/index.ts +1 -0
  24. package/src/index.ts +2 -0
  25. package/src/init/index.ts +2 -0
  26. package/src/init/initChainStakeViewer.ts +1 -1
  27. package/src/init/initPendingBlockArchivist.ts +31 -0
  28. package/src/init/initPendingTransactionArchivist.ts +31 -0
  29. package/src/manifest/public/WithMempool/Chain.json +1 -1
  30. package/src/manifest/public/WithMempool/Pending.json +16 -2
  31. package/src/manifest/public/WithoutMempool/Chain.json +1 -1
  32. package/src/manifest/public/WithoutMempool/Pending.json +16 -2
  33. package/src/orchestrator/Orchestrator.ts +69 -0
  34. package/src/orchestrator/index.ts +1 -0
@@ -0,0 +1,45 @@
1
+ import type { CreatableInstance, CreatableParams, EmptyObject } from '@xylabs/sdk-js';
2
+ import { AbstractCreatable } from '@xylabs/sdk-js';
3
+ import type { Config } from '@xyo-network/xl1-protocol-sdk';
4
+ import { Semaphore } from 'async-mutex';
5
+ export type ActorParams<T extends EmptyObject | void = void> = CreatableParams & {
6
+ config: Config;
7
+ displayName?: string;
8
+ id: string;
9
+ } & (T extends void ? EmptyObject : T);
10
+ export type ActorInstance<T extends ActorParams = ActorParams> = CreatableInstance<T> & {
11
+ start(): Promise<boolean>;
12
+ stop(): Promise<boolean>;
13
+ };
14
+ export declare class Actor<TParams extends ActorParams = ActorParams> extends AbstractCreatable<TParams> {
15
+ protected readonly _intervals: Map<string, ReturnType<typeof setInterval>>;
16
+ protected readonly _semaphores: Map<string, Semaphore>;
17
+ protected readonly _timeouts: Map<string, ReturnType<typeof setTimeout>>;
18
+ private _active;
19
+ get displayName(): string;
20
+ get id(): string;
21
+ protected get logPrefix(): string;
22
+ static paramsHandler<T extends ActorParams>(params?: Partial<T>): Promise<{
23
+ displayName: import("@xylabs/sdk-js").CreatableName | NonNullable<T["displayName"]> | undefined;
24
+ id: import("@xylabs/sdk-js").CreatableName | T["id"] | undefined;
25
+ logger: import("@xylabs/sdk-js").Logger;
26
+ name?: import("@xylabs/sdk-js").CreatableName;
27
+ statusReporter?: import("@xylabs/sdk-js").CreatableStatusReporter<void> | undefined;
28
+ meterProvider?: import("@opentelemetry/api").MeterProvider;
29
+ traceProvider?: import("@opentelemetry/api").TracerProvider;
30
+ }>;
31
+ /**
32
+ * The timer runs until the actor is deactivated (or you manually stop it).
33
+ */
34
+ registerTimer(timerName: string, callback: () => Promise<void>, dueTimeMs: number, periodMs: number): void;
35
+ /**
36
+ * Called by the Orchestrator when the actor is activated.
37
+ */
38
+ startHandler(): Promise<void>;
39
+ /**
40
+ * Called by the Orchestrator when the actor is deactivated.
41
+ * Stop all running timers.
42
+ */
43
+ stopHandler(): Promise<void>;
44
+ }
45
+ //# sourceMappingURL=Actor.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"Actor.d.ts","sourceRoot":"","sources":["../../../src/actor/Actor.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,iBAAiB,EAAE,eAAe,EAAE,WAAW,EAChD,MAAM,gBAAgB,CAAA;AACvB,OAAO,EACL,iBAAiB,EAElB,MAAM,gBAAgB,CAAA;AAEvB,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,+BAA+B,CAAA;AAC3D,OAAO,EAAE,SAAS,EAAE,MAAM,aAAa,CAAA;AAEvC,MAAM,MAAM,WAAW,CAAC,CAAC,SAAS,WAAW,GAAG,IAAI,GAAG,IAAI,IAAI,eAAe,GAAG;IAC/E,MAAM,EAAE,MAAM,CAAA;IACd,WAAW,CAAC,EAAE,MAAM,CAAA;IACpB,EAAE,EAAE,MAAM,CAAA;CACX,GAAG,CAAC,CAAC,SAAS,IAAI,GAAG,WAAW,GAAG,CAAC,CAAC,CAAA;AAEtC,MAAM,MAAM,aAAa,CAAC,CAAC,SAAS,WAAW,GAAG,WAAW,IAAI,iBAAiB,CAAC,CAAC,CAAC,GAAG;IACtF,KAAK,IAAI,OAAO,CAAC,OAAO,CAAC,CAAA;IACzB,IAAI,IAAI,OAAO,CAAC,OAAO,CAAC,CAAA;CACzB,CAAA;AAED,qBACa,KAAK,CAAC,OAAO,SAAS,WAAW,GAAG,WAAW,CAAE,SAAQ,iBAAiB,CAAC,OAAO,CAAC;IAC9F,SAAS,CAAC,QAAQ,CAAC,UAAU,EAAE,GAAG,CAAC,MAAM,EAAE,UAAU,CAAC,OAAO,WAAW,CAAC,CAAC,CAAY;IACtF,SAAS,CAAC,QAAQ,CAAC,WAAW,EAAE,GAAG,CAAC,MAAM,EAAE,SAAS,CAAC,CAAY;IAClE,SAAS,CAAC,QAAQ,CAAC,SAAS,EAAE,GAAG,CAAC,MAAM,EAAE,UAAU,CAAC,OAAO,UAAU,CAAC,CAAC,CAAY;IACpF,OAAO,CAAC,OAAO,CAAQ;IAEvB,IAAI,WAAW,WAEd;IAED,IAAI,EAAE,WAEL;IAED,SAAS,KAAK,SAAS,WAEtB;WAEqB,aAAa,CAAC,CAAC,SAAS,WAAW,EAAE,MAAM,CAAC,EAAE,OAAO,CAAC,CAAC,CAAC;;;;;;;;;IAY9E;;OAEG;IACH,aAAa,CAAC,SAAS,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,OAAO,CAAC,IAAI,CAAC,EAAE,SAAS,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM;IA8DnG;;OAEG;IACY,YAAY;IAM3B;;;OAGG;IACY,WAAW;CA+B3B"}
@@ -0,0 +1,2 @@
1
+ export * from './Actor.ts';
2
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/actor/index.ts"],"names":[],"mappings":"AAAA,cAAc,YAAY,CAAA"}
@@ -1,7 +1,9 @@
1
+ export * from './actor/index.ts';
1
2
  export * from './archivist/index.ts';
2
3
  export * from './bridge.ts';
3
4
  export * from './ConfigContext.ts';
4
5
  export * from './createDeclarationIntentBlock.ts';
5
6
  export * from './init/index.ts';
6
7
  export * from './manifest/index.ts';
8
+ export * from './orchestrator/index.ts';
7
9
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,sBAAsB,CAAA;AACpC,cAAc,aAAa,CAAA;AAC3B,cAAc,oBAAoB,CAAA;AAClC,cAAc,mCAAmC,CAAA;AACjD,cAAc,iBAAiB,CAAA;AAC/B,cAAc,qBAAqB,CAAA"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,kBAAkB,CAAA;AAChC,cAAc,sBAAsB,CAAA;AACpC,cAAc,aAAa,CAAA;AAC3B,cAAc,oBAAoB,CAAA;AAClC,cAAc,mCAAmC,CAAA;AACjD,cAAc,iBAAiB,CAAA;AAC/B,cAAc,qBAAqB,CAAA;AACnC,cAAc,yBAAyB,CAAA"}
@@ -1,6 +1,128 @@
1
1
  var __defProp = Object.defineProperty;
2
2
  var __name = (target, value) => __defProp(target, "name", { value, configurable: true });
3
3
 
4
+ // src/actor/Actor.ts
5
+ import { AbstractCreatable, Base, creatable, delay, IdLogger } from "@xylabs/sdk-js";
6
+ import { Semaphore } from "async-mutex";
7
+ function _ts_decorate(decorators, target, key, desc) {
8
+ var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
9
+ if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
10
+ else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
11
+ return c > 3 && r && Object.defineProperty(target, key, r), r;
12
+ }
13
+ __name(_ts_decorate, "_ts_decorate");
14
+ var Actor = class extends AbstractCreatable {
15
+ static {
16
+ __name(this, "Actor");
17
+ }
18
+ _intervals = /* @__PURE__ */ new Map();
19
+ _semaphores = /* @__PURE__ */ new Map();
20
+ _timeouts = /* @__PURE__ */ new Map();
21
+ _active = false;
22
+ get displayName() {
23
+ return this.params.displayName;
24
+ }
25
+ get id() {
26
+ return this.params.id;
27
+ }
28
+ get logPrefix() {
29
+ return `[${this.displayName} (${this.id})] `;
30
+ }
31
+ static async paramsHandler(params) {
32
+ const baseParams = await super.paramsHandler(params);
33
+ const id = params?.id ?? baseParams.name;
34
+ const displayName = params?.displayName ?? baseParams.name;
35
+ return {
36
+ ...baseParams,
37
+ displayName,
38
+ id,
39
+ logger: baseParams.logger ?? new IdLogger(Base.defaultLogger ?? console, () => `[${displayName} (${id})] `)
40
+ };
41
+ }
42
+ /**
43
+ * The timer runs until the actor is deactivated (or you manually stop it).
44
+ */
45
+ registerTimer(timerName, callback, dueTimeMs, periodMs) {
46
+ if (!this._active) {
47
+ this.logger?.warn(`Cannot register timer '${timerName}' because actor is not active.`);
48
+ return;
49
+ }
50
+ let running = false;
51
+ this._semaphores.set(timerName, new Semaphore(1));
52
+ const timeoutId = setTimeout(() => {
53
+ const intervalId = setInterval(() => {
54
+ const semaphore = this._semaphores.get(timerName);
55
+ if (!this._active || !this._intervals.has(timerName) || !semaphore || running) return;
56
+ if (semaphore.isLocked()) {
57
+ this.logger?.warn(`Skipping timer '${this.name}:${timerName}' execution because previous execution is still running.`);
58
+ return;
59
+ }
60
+ semaphore.acquire().then(([, release]) => {
61
+ const startTime = Date.now();
62
+ running = true;
63
+ callback().then(() => {
64
+ const duration = Date.now() - startTime;
65
+ if (duration > periodMs) {
66
+ this.logger?.warn(`Timer '${this.name}:${timerName}' execution took longer (${duration}ms) than the period (${periodMs}ms).`);
67
+ } else if (duration > 5e3) {
68
+ this.logger?.warn(`Timer '${this.name}:${timerName}' execution took longer (${duration}ms) than 5000ms.`);
69
+ }
70
+ }).catch((error) => {
71
+ this.logger?.error(`Error in timer '${this.name}:${timerName}': ${error}`);
72
+ }).finally(() => {
73
+ release();
74
+ running = false;
75
+ });
76
+ }).catch((error) => {
77
+ this.logger?.error(`Error acquiring semaphore for timer '${this.name}:${timerName}': ${error}`);
78
+ });
79
+ }, periodMs);
80
+ this._intervals.set(timerName, intervalId);
81
+ }, dueTimeMs);
82
+ this._timeouts.set(timerName, timeoutId);
83
+ this.logger?.log(`Timer '${this.name}:${timerName}' registered: first call after ${dueTimeMs}ms, recurring every ${periodMs}ms.`);
84
+ }
85
+ /**
86
+ * Called by the Orchestrator when the actor is activated.
87
+ */
88
+ async startHandler() {
89
+ await super.startHandler();
90
+ this._active = true;
91
+ this.logger?.log("Started.");
92
+ }
93
+ /**
94
+ * Called by the Orchestrator when the actor is deactivated.
95
+ * Stop all running timers.
96
+ */
97
+ async stopHandler() {
98
+ await super.stopHandler();
99
+ this._active = false;
100
+ this.logger?.log("Stopping all timers...");
101
+ await Promise.all([
102
+ ...this._semaphores.values()
103
+ ].map(async (semaphore) => {
104
+ while (semaphore.isLocked()) {
105
+ this.logger?.log("Waiting for running timer task to complete...");
106
+ await delay(500);
107
+ }
108
+ await semaphore.acquire();
109
+ }));
110
+ this._semaphores.clear();
111
+ for (const [, timeoutRef] of this._timeouts.entries()) {
112
+ clearTimeout(timeoutRef);
113
+ }
114
+ this._timeouts.clear();
115
+ for (const [, intervalRef] of this._intervals.entries()) {
116
+ clearInterval(intervalRef);
117
+ }
118
+ this._intervals.clear();
119
+ this.logger?.log("Stopped.");
120
+ }
121
+ };
122
+ Actor = _ts_decorate([
123
+ creatable()
124
+ ], Actor);
125
+
4
126
  // src/archivist/initArchivistSync.ts
5
127
  import { ArchivistSyncDiviner } from "@xyo-network/chain-modules";
6
128
  import { DivinerConfigSchema } from "@xyo-network/diviner-model";
@@ -317,7 +439,7 @@ async function initSimpleStakeViewer(config, logger) {
317
439
  return stakeChainViewer;
318
440
  }
319
441
  __name(initSimpleStakeViewer, "initSimpleStakeViewer");
320
- async function initChainStakeViewer(config, logger) {
442
+ async function initStakeViewer(config, logger) {
321
443
  if (canUseEvmProvider({
322
444
  config
323
445
  })) {
@@ -327,7 +449,65 @@ async function initChainStakeViewer(config, logger) {
327
449
  return await initSimpleStakeViewer(config, logger);
328
450
  }
329
451
  }
330
- __name(initChainStakeViewer, "initChainStakeViewer");
452
+ __name(initStakeViewer, "initStakeViewer");
453
+
454
+ // src/init/initPendingBlockArchivist.ts
455
+ import { MemoryArchivist as MemoryArchivist2 } from "@xyo-network/archivist-memory";
456
+ import { MongoDBArchivistV2 } from "@xyo-network/archivist-mongodb";
457
+ import { hasMongoConfig as hasMongoConfig2 } from "@xyo-network/xl1-protocol-sdk";
458
+ async function initPendingBlockArchivist({ config, logger }) {
459
+ const mongoConfig = config.storage?.mongo;
460
+ if (hasMongoConfig2(mongoConfig)) {
461
+ const { connectionString: dbConnectionString, database: dbName, domain: dbDomain, password: dbPassword, username: dbUserName } = mongoConfig;
462
+ const payloadSdkConfig = {
463
+ dbConnectionString,
464
+ dbDomain,
465
+ dbName,
466
+ dbPassword,
467
+ dbUserName
468
+ };
469
+ return await MongoDBArchivistV2.create({
470
+ payloadSdkConfig: {
471
+ ...payloadSdkConfig,
472
+ collection: "pending_block_bundles"
473
+ },
474
+ logger
475
+ });
476
+ } else {
477
+ logger?.warn("[API] Mongo configuration not found. Using MemoryArchivist for TransferSummaryMap.");
478
+ return await MemoryArchivist2.create();
479
+ }
480
+ }
481
+ __name(initPendingBlockArchivist, "initPendingBlockArchivist");
482
+
483
+ // src/init/initPendingTransactionArchivist.ts
484
+ import { MemoryArchivist as MemoryArchivist3 } from "@xyo-network/archivist-memory";
485
+ import { MongoDBArchivistV2 as MongoDBArchivistV22 } from "@xyo-network/archivist-mongodb";
486
+ import { hasMongoConfig as hasMongoConfig3 } from "@xyo-network/xl1-protocol-sdk";
487
+ async function initPendingTransactionArchivist({ config, logger }) {
488
+ const mongoConfig = config.storage?.mongo;
489
+ if (hasMongoConfig3(mongoConfig)) {
490
+ const { connectionString: dbConnectionString, database: dbName, domain: dbDomain, password: dbPassword, username: dbUserName } = mongoConfig;
491
+ const payloadSdkConfig = {
492
+ dbConnectionString,
493
+ dbDomain,
494
+ dbName,
495
+ dbPassword,
496
+ dbUserName
497
+ };
498
+ return await MongoDBArchivistV22.create({
499
+ payloadSdkConfig: {
500
+ ...payloadSdkConfig,
501
+ collection: "pending_transaction_bundles"
502
+ },
503
+ logger
504
+ });
505
+ } else {
506
+ logger?.warn("[API] Mongo configuration not found. Using MemoryArchivist for TransferSummaryMap.");
507
+ return await MemoryArchivist3.create();
508
+ }
509
+ }
510
+ __name(initPendingTransactionArchivist, "initPendingTransactionArchivist");
331
511
 
332
512
  // src/init/initProducerAccount.ts
333
513
  import { isUndefined } from "@xylabs/sdk-js";
@@ -384,8 +564,8 @@ import { asArchivistInstance } from "@xyo-network/archivist-model";
384
564
 
385
565
  // src/manifest/getLocator.ts
386
566
  import { asAddress as asAddress2, assertEx as assertEx9, isDefined as isDefined4, ZERO_ADDRESS } from "@xylabs/sdk-js";
387
- import { MemoryArchivist as MemoryArchivist2 } from "@xyo-network/archivist-memory";
388
- import { MongoDBArchivistV2 } from "@xyo-network/archivist-mongodb";
567
+ import { MemoryArchivist as MemoryArchivist4 } from "@xyo-network/archivist-memory";
568
+ import { MongoDBArchivistV2 as MongoDBArchivistV23 } from "@xyo-network/archivist-mongodb";
389
569
  import { ViewArchivist } from "@xyo-network/archivist-view";
390
570
  import { AddressBalanceDivinerV2, AddressTransferDiviner, ArchivistSyncDiviner as ArchivistSyncDiviner2, HeadValidationDiviner } from "@xyo-network/chain-modules";
391
571
  import { initTelemetry } from "@xyo-network/chain-telemetry";
@@ -393,8 +573,8 @@ import { AbstractModule, LoggerModuleStatusReporter } from "@xyo-network/module-
393
573
  import { ModuleFactoryLocator } from "@xyo-network/module-factory-locator";
394
574
  import { MemorySentinel as MemorySentinel2 } from "@xyo-network/sentinel-memory";
395
575
  import { StepSizes } from "@xyo-network/xl1-protocol";
396
- import { hasMongoConfig as hasMongoConfig2 } from "@xyo-network/xl1-protocol-sdk";
397
- import { Semaphore } from "async-mutex";
576
+ import { hasMongoConfig as hasMongoConfig4 } from "@xyo-network/xl1-protocol-sdk";
577
+ import { Semaphore as Semaphore2 } from "async-mutex";
398
578
  var getLocator = /* @__PURE__ */ __name(async ({ config, logger, balancesSummaryMap, transfersSummaryMap }) => {
399
579
  const { otlpEndpoint } = config.telemetry?.otel ?? {};
400
580
  const { path: endpoint = "/metrics", port = 9465 } = config.telemetry?.metrics?.scrape ?? {};
@@ -413,7 +593,7 @@ var getLocator = /* @__PURE__ */ __name(async ({ config, logger, balancesSummary
413
593
  const statusReporter = logger ? new LoggerModuleStatusReporter(logger) : void 0;
414
594
  const locator = new ModuleFactoryLocator();
415
595
  const mongoConfig = config.storage?.mongo;
416
- if (hasMongoConfig2(mongoConfig)) {
596
+ if (hasMongoConfig4(mongoConfig)) {
417
597
  const { connectionString: dbConnectionString, database: dbName, domain: dbDomain, password: dbPassword, username: dbUserName } = mongoConfig;
418
598
  const payloadSdkConfig = {
419
599
  dbConnectionString,
@@ -428,21 +608,21 @@ var getLocator = /* @__PURE__ */ __name(async ({ config, logger, balancesSummary
428
608
  statusReporter,
429
609
  traceProvider
430
610
  };
431
- locator.register(MongoDBArchivistV2.factory(params), void 0, true);
611
+ locator.register(MongoDBArchivistV23.factory(params), void 0, true);
432
612
  }
433
613
  locator.register(AddressBalanceDivinerV2.factory({
434
614
  traceProvider,
435
615
  meterProvider,
436
616
  statusReporter,
437
617
  summaryMap: balancesSummaryMap,
438
- stepSemaphores: StepSizes.map(() => new Semaphore(20))
618
+ stepSemaphores: StepSizes.map(() => new Semaphore2(20))
439
619
  }));
440
620
  locator.register(AddressTransferDiviner.factory({
441
621
  traceProvider,
442
622
  meterProvider,
443
623
  statusReporter,
444
624
  summaryMap: transfersSummaryMap,
445
- stepSemaphores: StepSizes.map(() => new Semaphore(20))
625
+ stepSemaphores: StepSizes.map(() => new Semaphore2(20))
446
626
  }));
447
627
  const chainId = isDefined4(config.chain.id) ? assertEx9(asAddress2(config.chain.id), () => "chain.id must be an Address") : ZERO_ADDRESS;
448
628
  locator.register(HeadValidationDiviner.factory({
@@ -452,7 +632,7 @@ var getLocator = /* @__PURE__ */ __name(async ({ config, logger, balancesSummary
452
632
  chainId,
453
633
  allowedProducers: config.producer.allowlist
454
634
  }));
455
- locator.register(MemoryArchivist2.factory({
635
+ locator.register(MemoryArchivist4.factory({
456
636
  traceProvider,
457
637
  meterProvider,
458
638
  statusReporter
@@ -705,7 +885,21 @@ var Pending_default = {
705
885
  "network.xyo.storage.class": "mongodb"
706
886
  },
707
887
  payloadSdkConfig: {
708
- collection: "pending_bundles"
888
+ collection: "pending_transaction_bundles"
889
+ },
890
+ schema: "network.xyo.archivist.config"
891
+ }
892
+ },
893
+ {
894
+ config: {
895
+ accountPath: "2/1/2",
896
+ name: "PendingBlocks",
897
+ getCache: {
898
+ enabled: true,
899
+ maxEntries: 5e3
900
+ },
901
+ payloadSdkConfig: {
902
+ collection: "pending_block_bundles"
709
903
  },
710
904
  schema: "network.xyo.archivist.config"
711
905
  }
@@ -849,7 +1043,21 @@ var Pending_default2 = {
849
1043
  "network.xyo.storage.class": "mongodb"
850
1044
  },
851
1045
  payloadSdkConfig: {
852
- collection: "pending_bundles"
1046
+ collection: "pending_transaction_bundles"
1047
+ },
1048
+ schema: "network.xyo.archivist.config"
1049
+ }
1050
+ },
1051
+ {
1052
+ config: {
1053
+ accountPath: "2/1/2",
1054
+ name: "PendingBlocks",
1055
+ getCache: {
1056
+ enabled: true,
1057
+ maxEntries: 5e3
1058
+ },
1059
+ payloadSdkConfig: {
1060
+ collection: "pending_block_bundles"
853
1061
  },
854
1062
  schema: "network.xyo.archivist.config"
855
1063
  }
@@ -940,10 +1148,10 @@ __name(initServerWallet, "initServerWallet");
940
1148
  import { BaseMongoSdk as BaseMongoSdk2 } from "@xylabs/mongo";
941
1149
  import { assertEx as assertEx11 } from "@xylabs/sdk-js";
942
1150
  import { MongoMap as MongoMap2 } from "@xyo-network/chain-protocol";
943
- import { hasMongoConfig as hasMongoConfig3, MemoryMap as MemoryMap2 } from "@xyo-network/xl1-protocol-sdk";
1151
+ import { hasMongoConfig as hasMongoConfig5, MemoryMap as MemoryMap2 } from "@xyo-network/xl1-protocol-sdk";
944
1152
  async function initTransferSummaryMap({ config, logger }) {
945
1153
  const mongoConfig = config.storage?.mongo;
946
- if (hasMongoConfig3(mongoConfig)) {
1154
+ if (hasMongoConfig5(mongoConfig)) {
947
1155
  const { connectionString: dbConnectionString, database: dbName, domain: dbDomain, password: dbPassword, username: dbUserName } = mongoConfig;
948
1156
  const payloadSdkConfig = {
949
1157
  dbConnectionString,
@@ -999,9 +1207,76 @@ var initElectionService = /* @__PURE__ */ __name((params) => {
999
1207
  return electionServiceSingleton;
1000
1208
  }, 2e3, true);
1001
1209
  }, "initElectionService");
1210
+
1211
+ // src/orchestrator/Orchestrator.ts
1212
+ import { AbstractCreatable as AbstractCreatable2, creatable as creatable2 } from "@xylabs/sdk-js";
1213
+ function _ts_decorate2(decorators, target, key, desc) {
1214
+ var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
1215
+ if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
1216
+ else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
1217
+ return c > 3 && r && Object.defineProperty(target, key, r), r;
1218
+ }
1219
+ __name(_ts_decorate2, "_ts_decorate");
1220
+ var Orchestrator = class extends AbstractCreatable2 {
1221
+ static {
1222
+ __name(this, "Orchestrator");
1223
+ }
1224
+ actors = [];
1225
+ keepAliveHandle = null;
1226
+ running = false;
1227
+ /**
1228
+ * Registers an actor.
1229
+ * (We won't activate the actor until `start()` is called.)
1230
+ */
1231
+ async registerActor(actor) {
1232
+ if (this.running) {
1233
+ await actor.start();
1234
+ }
1235
+ this.actors.push(actor);
1236
+ }
1237
+ /**
1238
+ * Starts the orchestrator: activates all actors.
1239
+ */
1240
+ async startHandler() {
1241
+ await super.startHandler();
1242
+ if (this.running) {
1243
+ this.logger?.warn("[Orchestrator] Already started.");
1244
+ return;
1245
+ }
1246
+ this.logger?.log("[Orchestrator] Starting...");
1247
+ this.running = true;
1248
+ for (const actor of this.actors) {
1249
+ await actor.start();
1250
+ }
1251
+ this.keepAliveHandle = setInterval(() => {
1252
+ }, 2147483647);
1253
+ }
1254
+ /**
1255
+ * Stops the orchestrator: deactivates all actors.
1256
+ */
1257
+ async stopHandler() {
1258
+ await super.stopHandler();
1259
+ if (!this.running) {
1260
+ this.logger?.log("[Orchestrator] Already stopped.");
1261
+ return;
1262
+ }
1263
+ this.logger?.log("[Orchestrator] Stopping...");
1264
+ for (const actor of this.actors) {
1265
+ await actor.stop();
1266
+ }
1267
+ this.running = false;
1268
+ if (this.keepAliveHandle) clearInterval(this.keepAliveHandle);
1269
+ this.logger?.log("[Orchestrator] Stopped...");
1270
+ }
1271
+ };
1272
+ Orchestrator = _ts_decorate2([
1273
+ creatable2()
1274
+ ], Orchestrator);
1002
1275
  export {
1276
+ Actor,
1003
1277
  DefaultReadCachingArchivistConfig,
1004
1278
  NodeManifest,
1279
+ Orchestrator,
1005
1280
  PrivateChildManifests,
1006
1281
  PublicChildManifestsWithMempool,
1007
1282
  PublicChildManifestsWithoutMempool,
@@ -1013,15 +1288,17 @@ export {
1013
1288
  initBridgedArchivistModule,
1014
1289
  initBridgedModule,
1015
1290
  initChainIterator,
1016
- initChainStakeViewer,
1017
1291
  initElectionService,
1018
1292
  initEvmChainStakeViewer,
1293
+ initPendingBlockArchivist,
1294
+ initPendingTransactionArchivist,
1019
1295
  initProducerAccount,
1020
1296
  initSeedPhrase,
1021
1297
  initServerNode,
1022
1298
  initServerWallet,
1023
1299
  initSimpleStakeViewer,
1024
1300
  initStakeIntentService,
1301
+ initStakeViewer,
1025
1302
  initTransferSummaryMap,
1026
1303
  loadNode,
1027
1304
  wrapWithReadCachingArchivist