Skip to content

Commit fcd0764

Browse files
committed
using SequencerIdProvider,
removed .vscode/launch.json
1 parent ddf7607 commit fcd0764

File tree

8 files changed

+30
-11
lines changed

8 files changed

+30
-11
lines changed

.vscode/launch.json

Whitespace-only changes.

packages/indexer/src/IndexerNotifier.ts

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ import {
55
SequencerModule,
66
TaskPayload,
77
TaskQueue,
8+
SequencerIdProvider,
89
} from "@proto-kit/sequencer";
910
import { log } from "@proto-kit/common";
1011
import { inject } from "tsyringe";
@@ -22,7 +23,8 @@ export class IndexerNotifier extends SequencerModule<Record<never, never>> {
2223
public sequencer: Sequencer<NotifierMandatorySequencerModules>,
2324
@inject("TaskQueue")
2425
public taskQueue: TaskQueue,
25-
public indexBlockTask: IndexBlockTask
26+
public indexBlockTask: IndexBlockTask,
27+
private readonly sequencerIdProvider: SequencerIdProvider
2628
) {
2729
super();
2830
}
@@ -37,7 +39,7 @@ export class IndexerNotifier extends SequencerModule<Record<never, never>> {
3739
block.block.height.toBigInt()
3840
);
3941
const payload = await inputSerializer.toJSON(block);
40-
const sequencerId = this.sequencer.id;
42+
const sequencerId = this.sequencerIdProvider.getSequencerId();
4143

4244
const task: TaskPayload = {
4345
name: this.indexBlockTask.name,

packages/sequencer/src/index.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ export * from "./mempool/CompressedSignature";
55
export * from "./mempool/private/PrivateMempool";
66
export * from "./sequencer/executor/Sequencer";
77
export * from "./sequencer/executor/Sequenceable";
8+
export * from "./sequencer/SequencerIdProvider";
89
export * from "./sequencer/builder/SequencerModule";
910
export * from "./sequencer/builder/Closeable";
1011
export * from "./worker/flow/Flow";
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
import { injectable, scoped, Lifecycle, singleton } from "tsyringe";
2+
import { Field } from "o1js";
3+
4+
@injectable()
5+
@singleton()
6+
export class SequencerIdProvider {
7+
private readonly sequencerId: string;
8+
9+
public constructor() {
10+
this.sequencerId = Field.random().toString();
11+
}
12+
13+
public getSequencerId(): string {
14+
return this.sequencerId;
15+
}
16+
}
17+

packages/sequencer/src/sequencer/executor/Sequencer.ts

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,6 @@ import {
1717
ProtocolModulesRecord,
1818
} from "@proto-kit/protocol";
1919
import { injectable } from "tsyringe";
20-
import { Field } from "o1js";
2120

2221
import { SequencerModule } from "../builder/SequencerModule";
2322
import { Closeable } from "../builder/Closeable";
@@ -36,11 +35,8 @@ export class Sequencer<Modules extends SequencerModulesRecord>
3635
extends ModuleContainer<Modules>
3736
implements Sequenceable
3837
{
39-
public readonly id: string;
40-
4138
public constructor(definition: Modules) {
4239
super(definition);
43-
this.id = Field.random().toString();
4440
}
4541

4642
/**

packages/sequencer/src/worker/flow/Flow.ts

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ import { log, mapSequential } from "@proto-kit/common";
33

44
import { InstantiatedQueue, TaskQueue } from "../queue/TaskQueue";
55
import { Closeable } from "../../sequencer/builder/Closeable";
6-
import type { Sequencer } from "../../sequencer/executor/Sequencer";
6+
import { SequencerIdProvider } from "../../sequencer/SequencerIdProvider";
77

88
import { Task, TaskPayload } from "./Task";
99

@@ -186,10 +186,15 @@ export class Flow<State> implements Closeable {
186186
export class FlowCreator {
187187
public constructor(
188188
@inject("TaskQueue") private readonly queueImpl: TaskQueue,
189-
@inject("Sequencer") private readonly sequencer: Sequencer<any>
189+
private readonly sequencerIdProvider: SequencerIdProvider
190190
) {}
191191

192192
public createFlow<State>(flowId: string, state: State): Flow<State> {
193-
return new Flow(this.queueImpl, flowId, state, this.sequencer.id);
193+
return new Flow(
194+
this.queueImpl,
195+
flowId,
196+
state,
197+
this.sequencerIdProvider.getSequencerId()
198+
);
194199
}
195200
}

packages/sequencer/test/protocol/production/flow/ReductionTaskFlow.test.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -90,7 +90,6 @@ describe("ReductionTaskFlow", () => {
9090
di.register("TaskQueue", {
9191
useValue: queue,
9292
});
93-
di.register("Sequencer", { useValue: { id: "1" } });
9493

9594
const worker = new FlowTaskWorker(di.resolve("TaskQueue"), [
9695
di.resolve(NumberIdentityTask),

packages/sequencer/test/worker/Flow.test.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -226,7 +226,6 @@ describe("flow", () => {
226226
await worker.start();
227227

228228
container.register("TaskQueue", { useValue: queue });
229-
container.register("Sequencer", { useValue: { id: "1" } });
230229
const flowCreator = container.resolve(FlowCreator);
231230

232231
const flow = flowCreator.createFlow("1", {

0 commit comments

Comments
 (0)