11import type { BlockFactory } from "../crypto/block.js" ;
22import type { PublicKeyFactory , SignatureBls , SignatureEcdsa } from "../crypto/identities.js" ;
33import type { TransactionFactory } from "../crypto/transactions.js" ;
4- import type { Requests , Subprocess } from "../kernel/ipc.js" ;
4+ import type { MethodArguments , Requests } from "../kernel/ipc.js" ;
55import type { JsonObject } from "../types/index.js" ;
66
77export interface WorkerFlags extends JsonObject {
@@ -10,41 +10,61 @@ export interface WorkerFlags extends JsonObject {
1010
1111export interface WorkerScriptHandler {
1212 boot ( flags : WorkerFlags ) : Promise < void > ;
13+ dispose ( ) : Promise < void > ;
1314 consensusSignature < K extends Requests < SignatureBls > > (
1415 method : K ,
15- ... arguments_ : Parameters < SignatureBls [ K ] >
16+ arguments_ : MethodArguments < SignatureBls , K > ,
1617 ) : Promise < ReturnType < SignatureBls [ K ] > > ;
1718 walletSignature < K extends Requests < SignatureEcdsa > > (
1819 method : K ,
19- ... arguments_ : Parameters < SignatureEcdsa [ K ] >
20+ arguments_ : MethodArguments < SignatureEcdsa , K > ,
2021 ) : Promise < ReturnType < SignatureEcdsa [ K ] > > ;
2122 blockFactory < K extends Requests < BlockFactory > > (
2223 method : K ,
23- ... arguments_ : Parameters < BlockFactory [ K ] >
24+ arguments_ : MethodArguments < BlockFactory , K > ,
2425 ) : Promise < ReturnType < BlockFactory [ K ] > > ;
2526 transactionFactory < K extends Requests < TransactionFactory > > (
2627 method : K ,
27- ... arguments_ : Parameters < TransactionFactory [ K ] >
28+ arguments_ : MethodArguments < TransactionFactory , K > ,
2829 ) : Promise < ReturnType < TransactionFactory [ K ] > > ;
2930 publicKeyFactory < K extends Requests < PublicKeyFactory > > (
3031 method : K ,
31- ... arguments_ : Parameters < PublicKeyFactory [ K ] >
32+ arguments_ : MethodArguments < PublicKeyFactory , K > ,
3233 ) : Promise < ReturnType < PublicKeyFactory [ K ] > > ;
3334}
3435
3536export type WorkerFactory = ( ) => Worker ;
3637
37- export type WorkerSubprocess = Subprocess < WorkerScriptHandler > ;
38-
39- export type WorkerSubprocessFactory = ( ) => WorkerSubprocess ;
40-
41- export interface Worker extends WorkerScriptHandler {
38+ export interface Worker {
39+ boot ( flags : WorkerFlags ) : Promise < void > ;
40+ dispose ( ) : Promise < void > ;
4241 getQueueSize ( ) : number ;
42+ isStopped ( ) : boolean ;
4343 kill ( ) : Promise < number > ;
44+ consensusSignature < K extends Requests < SignatureBls > > (
45+ method : K ,
46+ ...arguments_ : Parameters < SignatureBls [ K ] >
47+ ) : Promise < ReturnType < SignatureBls [ K ] > > ;
48+ walletSignature < K extends Requests < SignatureEcdsa > > (
49+ method : K ,
50+ ...arguments_ : Parameters < SignatureEcdsa [ K ] >
51+ ) : Promise < ReturnType < SignatureEcdsa [ K ] > > ;
52+ blockFactory < K extends Requests < BlockFactory > > (
53+ method : K ,
54+ ...arguments_ : Parameters < BlockFactory [ K ] >
55+ ) : Promise < ReturnType < BlockFactory [ K ] > > ;
56+ transactionFactory < K extends Requests < TransactionFactory > > (
57+ method : K ,
58+ ...arguments_ : Parameters < TransactionFactory [ K ] >
59+ ) : Promise < ReturnType < TransactionFactory [ K ] > > ;
60+ publicKeyFactory < K extends Requests < PublicKeyFactory > > (
61+ method : K ,
62+ ...arguments_ : Parameters < PublicKeyFactory [ K ] >
63+ ) : Promise < ReturnType < PublicKeyFactory [ K ] > > ;
4464}
4565
4666export interface WorkerPool {
4767 boot ( ) : Promise < void > ;
48- shutdown ( ) : Promise < void > ;
49- getWorker ( ) : Promise < Worker > ;
68+ dispose ( ) : Promise < void > ;
69+ getWorker ( ) : Worker ;
5070}
0 commit comments