@@ -33,17 +33,20 @@ import * as networkUtils from '../network/utils';
33
33
import * as nodesUtils from '../nodes/utils' ;
34
34
import { never } from '../utils' ;
35
35
import config from '../config' ;
36
+ import agentClientManifest from './agent/callers' ;
37
+
38
+ type AgentClientManifest = typeof agentClientManifest ;
36
39
37
40
/**
38
41
* Encapsulates the unidirectional client-side connection of one node to another.
39
42
*/
40
43
// eslint-disable-next-line @typescript-eslint/no-unused-vars -- False positive for M
41
- interface NodeConnection < M extends ClientManifest > extends CreateDestroy { }
44
+ interface NodeConnection extends CreateDestroy { }
42
45
@CreateDestroy ( {
43
46
eventDestroy : nodesEvents . EventNodeConnectionDestroy ,
44
47
eventDestroyed : nodesEvents . EventNodeConnectionDestroyed ,
45
48
} )
46
- class NodeConnection < M extends ClientManifest > {
49
+ class NodeConnection {
47
50
/**
48
51
* Hostname is defined if the target's host was resolved from this hostname
49
52
* Undefined if a Host was directly provided
@@ -66,7 +69,7 @@ class NodeConnection<M extends ClientManifest> {
66
69
protected logger : Logger ;
67
70
public readonly quicClient : QUICClient | undefined ;
68
71
public readonly quicConnection : QUICConnection ;
69
- public readonly rpcClient : RPCClient < M > ;
72
+ public readonly rpcClient : RPCClient < AgentClientManifest > ;
70
73
71
74
/**
72
75
* Dispatches a `EventNodeConnectionClose` in response to any `NodeConnection`
@@ -167,7 +170,7 @@ class NodeConnection<M extends ClientManifest> {
167
170
}
168
171
} ;
169
172
170
- static createNodeConnection < M extends ClientManifest > (
173
+ static createNodeConnection (
171
174
{
172
175
targetNodeIds,
173
176
targetHost,
@@ -190,16 +193,16 @@ class NodeConnection<M extends ClientManifest> {
190
193
connectionKeepAliveIntervalTime ?: number ;
191
194
connectionKeepAliveTimeoutTime ?: number ;
192
195
quicSocket ?: QUICSocket ;
193
- manifest : M ;
196
+ manifest : AgentClientManifest ;
194
197
logger ?: Logger ;
195
198
} ,
196
199
ctx ?: Partial < ContextTimedInput > ,
197
- ) : PromiseCancellable < NodeConnection < M > > ;
200
+ ) : PromiseCancellable < NodeConnection > ;
198
201
@timedCancellable (
199
202
true ,
200
203
config . defaultsSystem . nodesConnectionConnectTimeoutTime ,
201
204
)
202
- static async createNodeConnection < M extends ClientManifest > (
205
+ static async createNodeConnection (
203
206
{
204
207
targetNodeIds,
205
208
targetHost,
@@ -220,14 +223,14 @@ class NodeConnection<M extends ClientManifest> {
220
223
targetHostname ?: Hostname ;
221
224
crypto : ClientCryptoOps ;
222
225
tlsConfig : TLSConfig ;
223
- manifest : M ;
226
+ manifest : AgentClientManifest ;
224
227
connectionKeepAliveIntervalTime ?: number ;
225
228
connectionKeepAliveTimeoutTime ?: number ;
226
229
quicSocket : QUICSocket ;
227
230
logger ?: Logger ;
228
231
} ,
229
232
@context ctx : ContextTimed ,
230
- ) : Promise < NodeConnection < M > > {
233
+ ) : Promise < NodeConnection > {
231
234
logger . info ( `Creating ${ this . name } ` ) ;
232
235
// Checking if attempting to connect to a wildcard IP
233
236
if ( networkUtils . isHostWildcard ( targetHost ) ) {
@@ -297,7 +300,7 @@ class NodeConnection<M extends ClientManifest> {
297
300
quicEvents . EventQUICConnectionStream . name ,
298
301
throwFunction ,
299
302
) ;
300
- const rpcClient = new RPCClient < M > ( {
303
+ const rpcClient = new RPCClient < AgentClientManifest > ( {
301
304
manifest,
302
305
middlewareFactory : rpcUtilsMiddleware . defaultClientMiddlewareWrapper ( ) ,
303
306
streamFactory : async ( ) => {
@@ -320,7 +323,7 @@ class NodeConnection<M extends ClientManifest> {
320
323
quicConnection . remoteHost
321
324
} :${ quicConnection . remotePort } ]`,
322
325
) ;
323
- const nodeConnection = new this < M > ( {
326
+ const nodeConnection = new this ( {
324
327
validatedNodeId,
325
328
nodeId,
326
329
host : targetHost ,
@@ -367,7 +370,7 @@ class NodeConnection<M extends ClientManifest> {
367
370
return nodeConnection ;
368
371
}
369
372
370
- static createNodeConnectionReverse < M extends ClientManifest > ( {
373
+ static createNodeConnectionReverse ( {
371
374
certChain,
372
375
nodeId,
373
376
quicConnection,
@@ -377,12 +380,12 @@ class NodeConnection<M extends ClientManifest> {
377
380
certChain : Array < Certificate > ;
378
381
nodeId : NodeId ;
379
382
quicConnection : QUICConnection ;
380
- manifest : M ;
383
+ manifest : AgentClientManifest ;
381
384
logger ?: Logger ;
382
- } ) : NodeConnection < M > {
385
+ } ) : NodeConnection {
383
386
logger . info ( `Creating ${ this . name } ` ) ;
384
387
// Creating RPCClient
385
- const rpcClient = new RPCClient < M > ( {
388
+ const rpcClient = new RPCClient < AgentClientManifest > ( {
386
389
manifest,
387
390
middlewareFactory : rpcUtilsMiddleware . defaultClientMiddlewareWrapper ( ) ,
388
391
streamFactory : async ( _ctx ) => {
@@ -392,7 +395,7 @@ class NodeConnection<M extends ClientManifest> {
392
395
logger : logger . getChild ( RPCClient . name ) ,
393
396
} ) ;
394
397
// Creating NodeConnection
395
- const nodeConnection = new this < M > ( {
398
+ const nodeConnection = new this ( {
396
399
validatedNodeId : nodeId ,
397
400
nodeId : nodeId ,
398
401
localHost : quicConnection . localHost as unknown as Host ,
@@ -461,7 +464,7 @@ class NodeConnection<M extends ClientManifest> {
461
464
hostname ?: Hostname ;
462
465
quicClient ?: QUICClient ;
463
466
quicConnection : QUICConnection ;
464
- rpcClient : RPCClient < M > ;
467
+ rpcClient : RPCClient < AgentClientManifest > ;
465
468
logger : Logger ;
466
469
} ) {
467
470
this . validatedNodeId = validatedNodeId ;
@@ -539,7 +542,7 @@ class NodeConnection<M extends ClientManifest> {
539
542
/**
540
543
* Gets RPCClient for this node connection
541
544
*/
542
- public getClient ( ) : RPCClient < M > {
545
+ public getClient ( ) : RPCClient < AgentClientManifest > {
543
546
return this . rpcClient ;
544
547
}
545
548
}
0 commit comments