@@ -129,7 +129,7 @@ class NodeConnectionManager {
129129 targetNodeId : NodeId ,
130130 ) : Promise < ResourceAcquire < NodeConnection < GRPCClientAgent > > > {
131131 return async ( ) => {
132- const connAndLock = await this . createConnection ( targetNodeId ) ;
132+ const connAndLock = await this . getConnection ( targetNodeId ) ;
133133 // Acquire the read lock and the release function
134134 const release = await connAndLock . lock . acquireRead ( ) ;
135135 // Resetting TTL timer
@@ -161,6 +161,11 @@ class NodeConnectionManager {
161161 return await withF (
162162 [ await this . acquireConnection ( targetNodeId ) ] ,
163163 async ( [ conn ] ) => {
164+ this . logger . info (
165+ `withConnF calling function with connection to ${ nodesUtils . encodeNodeId (
166+ targetNodeId ,
167+ ) } `,
168+ ) ;
164169 return await f ( conn ) ;
165170 } ,
166171 ) ;
@@ -219,11 +224,11 @@ class NodeConnectionManager {
219224 * @param targetNodeId Id of node we are creating connection to
220225 * @returns ConnectionAndLock that was create or exists in the connection map.
221226 */
222- protected async createConnection (
227+ protected async getConnection (
223228 targetNodeId : NodeId ,
224229 ) : Promise < ConnectionAndLock > {
225230 this . logger . info (
226- `Creating connection to ${ nodesUtils . encodeNodeId ( targetNodeId ) } ` ,
231+ `Getting connection to ${ nodesUtils . encodeNodeId ( targetNodeId ) } ` ,
227232 ) ;
228233 let connection : NodeConnection < GRPCClientAgent > | undefined ;
229234 let lock : RWLock ;
@@ -241,10 +246,13 @@ class NodeConnectionManager {
241246 targetNodeId . toString ( ) as NodeIdString ,
242247 ) ;
243248 if ( connAndLock != null && connAndLock . connection != null ) {
249+ this . logger . info (
250+ `existing entry found for ${ nodesUtils . encodeNodeId ( targetNodeId ) } ` ,
251+ ) ;
244252 return connAndLock ;
245253 }
246254 this . logger . info (
247- `existing lock: creating connection to ${ nodesUtils . encodeNodeId (
255+ `existing lock, creating connection to ${ nodesUtils . encodeNodeId (
248256 targetNodeId ,
249257 ) } `,
250258 ) ;
@@ -260,7 +268,7 @@ class NodeConnectionManager {
260268 ) ;
261269 return await lock . withWrite ( async ( ) => {
262270 this . logger . info (
263- `no existing entry: creating connection to ${ nodesUtils . encodeNodeId (
271+ `no existing entry, creating connection to ${ nodesUtils . encodeNodeId (
264272 targetNodeId ,
265273 ) } `,
266274 ) ;
@@ -318,7 +326,9 @@ class NodeConnectionManager {
318326 nodeConnectionManager : this ,
319327 destroyCallback,
320328 connConnectTime : this . connConnectTime ,
321- logger : this . logger . getChild ( `${ targetHost } :${ targetAddress . port } ` ) ,
329+ logger : this . logger . getChild (
330+ `${ NodeConnection . name } ${ targetHost } :${ targetAddress . port } ` ,
331+ ) ,
322332 clientFactory : async ( args ) =>
323333 GRPCClientAgent . createGRPCClientAgent ( args ) ,
324334 } ) ;
@@ -521,7 +531,7 @@ class NodeConnectionManager {
521531 // Add the node to the database so that we can find its address in
522532 // call to getConnectionToNode
523533 await this . nodeGraph . setNode ( nextNode . id , nextNode . address ) ;
524- await this . createConnection ( nextNode . id ) ;
534+ await this . getConnection ( nextNode . id ) ;
525535 } catch ( e ) {
526536 // If we can't connect to the node, then skip it
527537 continue ;
@@ -620,7 +630,7 @@ class NodeConnectionManager {
620630 for ( const seedNodeId of this . getSeedNodes ( ) ) {
621631 // Check if the connection is viable
622632 try {
623- await this . createConnection ( seedNodeId ) ;
633+ await this . getConnection ( seedNodeId ) ;
624634 } catch ( e ) {
625635 if ( e instanceof nodesErrors . ErrorNodeConnectionTimeout ) continue ;
626636 throw e ;
0 commit comments