File tree Expand file tree Collapse file tree 2 files changed +35
-0
lines changed
protocol/production/trigger Expand file tree Collapse file tree 2 files changed +35
-0
lines changed Original file line number Diff line number Diff line change @@ -28,6 +28,7 @@ export * from "./protocol/production/tasks/StateTransitionTaskParameters";
2828export * from "./protocol/production/trigger/BlockTrigger" ;
2929export * from "./protocol/production/trigger/ManualBlockTrigger" ;
3030export * from "./protocol/production/trigger/TimedBlockTrigger" ;
31+ export * from "./protocol/production/trigger/AutomaticBlockTrigger" ;
3132export * from "./protocol/production/BlockProducerModule" ;
3233export * from "./protocol/production/BlockTaskFlowService" ;
3334export * from "./protocol/production/TransactionTraceService" ;
Original file line number Diff line number Diff line change 1+ import { inject } from "tsyringe" ;
2+ import { log } from "@proto-kit/common" ;
3+
4+ import { SequencerModule } from "../../../sequencer/builder/SequencerModule" ;
5+ import { UnprovenProducerModule } from "../unproven/UnprovenProducerModule" ;
6+ import { Mempool } from "../../../mempool/Mempool" ;
7+
8+ import { BlockTrigger } from "./BlockTrigger" ;
9+
10+ /**
11+ * Only unproven invocation at the moment, because
12+ * this is primarily for development and testing purposes
13+ */
14+ export class AutomaticBlockTrigger
15+ extends SequencerModule < Record < string , never > >
16+ implements BlockTrigger
17+ {
18+ public constructor (
19+ @inject ( "UnprovenProducerModule" )
20+ private readonly unprovenProducerModule : UnprovenProducerModule ,
21+ @inject ( "Mempool" )
22+ private readonly mempool : Mempool
23+ ) {
24+ super ( ) ;
25+ }
26+
27+ public async start ( ) : Promise < void > {
28+ // eslint-disable-next-line @typescript-eslint/no-misused-promises
29+ this . mempool . events . on ( "transactionAdded" , async ( ) => {
30+ log . info ( "Transaction received, creating block..." ) ;
31+ await this . unprovenProducerModule . tryProduceUnprovenBlock ( ) ;
32+ } ) ;
33+ }
34+ }
You can’t perform that action at this time.
0 commit comments