Skip to content

Commit

Permalink
fix: switched new info level logs to debug
Browse files Browse the repository at this point in the history
  • Loading branch information
tegefaulkes committed Nov 8, 2022
1 parent dcb85cc commit ec5d32f
Show file tree
Hide file tree
Showing 4 changed files with 30 additions and 30 deletions.
8 changes: 4 additions & 4 deletions src/network/ConnectionForward.ts
Original file line number Diff line number Diff line change
Expand Up @@ -125,7 +125,7 @@ class ConnectionForward extends Connection {
// Promise for abortion and timeout
const { p: abortedP, resolveP: resolveAbortedP } = promise<void>();
if (ctx.signal.aborted) {
this.logger.info(`Failed to start Connection Forward: aborted`);
this.logger.debug(`Failed to start Connection Forward: aborted`);
// This is for arbitrary abortion reason provided by the caller
// Re-throw the default timeout error as a network timeout error
if (
Expand Down Expand Up @@ -186,7 +186,7 @@ class ConnectionForward extends Connection {
this.tlsSocket.destroy();
}
this.utpSocket.off('message', this.handleMessage);
this.logger.info(`Failed to start Connection Forward: ${e.message}`);
this.logger.debug(`Failed to start Connection Forward: ${e.message}`);
throw new networkErrors.ErrorConnectionStart(undefined, {
cause: e,
});
Expand All @@ -196,7 +196,7 @@ class ConnectionForward extends Connection {
this.tlsSocket.on('error', this.handleError);
this.tlsSocket.off('error', handleStartError);
if (ctx.signal.aborted) {
this.logger.info(`Failed to start Connection Forward: aborted`);
this.logger.debug(`Failed to start Connection Forward: aborted`);
// Clean up partial start
// TLSSocket isn't established yet, so it is destroyed
if (!this.tlsSocket.destroyed) {
Expand All @@ -220,7 +220,7 @@ class ConnectionForward extends Connection {
serverCertChain,
);
} catch (e) {
this.logger.info(
this.logger.debug(
`Failed to start Connection Forward: verification failed`,
);
// Clean up partial start
Expand Down
4 changes: 2 additions & 2 deletions src/nodes/NodeConnection.ts
Original file line number Diff line number Diff line change
Expand Up @@ -121,7 +121,7 @@ class NodeConnection<T extends GRPCClient> {
// Think about this
logger: clientLogger,
destroyCallback: async () => {
clientLogger.info(`GRPC client triggered destroyedCallback`);
clientLogger.debug(`GRPC client triggered destroyedCallback`);
if (
nodeConnection[asyncInit.status] !== 'destroying' &&
!nodeConnection[asyncInit.destroyed]
Expand Down Expand Up @@ -189,7 +189,7 @@ class NodeConnection<T extends GRPCClient> {
) {
await this.client.destroy({ timeout });
}
this.logger.info(`${this.constructor.name} triggered destroyedCallback`);
this.logger.debug(`${this.constructor.name} triggered destroyedCallback`);
await this.destroyCallback();
this.logger.info(`Destroyed ${this.constructor.name}`);
}
Expand Down
20 changes: 10 additions & 10 deletions src/nodes/NodeConnectionManager.ts
Original file line number Diff line number Diff line change
Expand Up @@ -295,24 +295,24 @@ class NodeConnectionManager {
): Promise<ConnectionAndTimer> {
const targetNodeIdString = targetNodeId.toString() as NodeIdString;
const targetNodeIdEncoded = nodesUtils.encodeNodeId(targetNodeId);
this.logger.info(`Getting NodeConnection for ${targetNodeIdEncoded}`);
this.logger.debug(`Getting NodeConnection for ${targetNodeIdEncoded}`);
return await this.connectionLocks.withF(
[targetNodeIdString, Lock],
async () => {
const connAndTimer = this.connections.get(targetNodeIdString);
if (connAndTimer != null) {
this.logger.info(
this.logger.debug(
`Found existing NodeConnection for ${targetNodeIdEncoded}`,
);
return connAndTimer;
}
// Creating the connection and set in map
this.logger.info(`Finding address for ${targetNodeIdEncoded}`);
this.logger.debug(`Finding address for ${targetNodeIdEncoded}`);
const targetAddress = await this.findNode(targetNodeId);
if (targetAddress == null) {
throw new nodesErrors.ErrorNodeGraphNodeIdNotFound();
}
this.logger.info(
this.logger.debug(
`Found address for ${targetNodeIdEncoded} at ${targetAddress.host}:${targetAddress.port}`,
);
// If the stored host is not a valid host (IP address),
Expand All @@ -323,7 +323,7 @@ class NodeConnectionManager {
const targetAddresses = await networkUtils.resolveHostnames([
targetAddress,
]);
this.logger.info(`Creating NodeConnection for ${targetNodeIdEncoded}`);
this.logger.debug(`Creating NodeConnection for ${targetNodeIdEncoded}`);
// Start the hole punching only if we are not connecting to seed nodes
const seedNodes = this.getSeedNodes();
if (this.isSeedNode(targetNodeId)) {
Expand Down Expand Up @@ -376,7 +376,7 @@ class NodeConnectionManager {
void nodeConnectionProm.then(
() => firstConnectionIndexProm.resolveP(index),
(e) => {
this.logger.info(
this.logger.debug(
`Creating NodeConnection failed for ${targetNodeIdEncoded}`,
);
// Disable destroyCallback clean up
Expand All @@ -394,7 +394,7 @@ class NodeConnectionManager {
newConnection = await Promise.any(nodeConnectionProms);
} catch (e) {
// All connections failed to establish
this.logger.info(
this.logger.debug(
`Failed NodeConnection for ${targetNodeIdEncoded} with ${errors}`,
);
if (errors.length === 1) {
Expand Down Expand Up @@ -423,7 +423,7 @@ class NodeConnectionManager {
);
// Final set up
void destroyCallbackProms[successfulIndex].p.then(async () => {
this.logger.info('DestroyedCallback was called');
this.logger.debug('DestroyedCallback was called');
// To avoid deadlock only in the case where this is called
// we want to check for destroying connection and read lock
const connAndTimer = this.connections.get(targetNodeIdString);
Expand Down Expand Up @@ -454,7 +454,7 @@ class NodeConnectionManager {
};
this.connections.set(targetNodeIdString, newConnAndTimer);
// Enable destroyCallback clean up
this.logger.info(`Created NodeConnection for ${targetNodeIdEncoded}`);
this.logger.debug(`Created NodeConnection for ${targetNodeIdEncoded}`);
return newConnAndTimer;
},
);
Expand All @@ -471,7 +471,7 @@ class NodeConnectionManager {
async () => {
const connAndTimer = this.connections.get(targetNodeIdString);
if (connAndTimer?.connection == null) return;
this.logger.info(
this.logger.debug(
`Destroying NodeConnection for ${nodesUtils.encodeNodeId(
targetNodeId,
)}`,
Expand Down
28 changes: 14 additions & 14 deletions src/nodes/NodeManager.ts
Original file line number Diff line number Diff line change
Expand Up @@ -123,15 +123,15 @@ class NodeManager {
ctx,
taskInfo,
) => {
this.logger.info('Checking seed connections');
this.logger.debug('Checking seed connections');
// Check for existing seed node connections
const seedNodes = this.nodeConnectionManager.getSeedNodes();
const allInactive = !seedNodes
.map((nodeId) => this.nodeConnectionManager.hasConnection(nodeId))
.reduce((a, b) => a || b);
try {
if (allInactive) {
this.logger.info(
this.logger.debug(
'No active seed connections were found, retrying network entry',
);
// If no seed node connections exist then we redo syncNodeGraph
Expand All @@ -142,7 +142,7 @@ class NodeManager {
seedNodes.map((nodeId) => {
// Retry any failed seed node connections
if (!this.nodeConnectionManager.hasConnection(nodeId)) {
this.logger.info(
this.logger.debug(
`Re-establishing seed connection for ${nodesUtils.encodeNodeId(
nodeId,
)}`,
Expand All @@ -159,7 +159,7 @@ class NodeManager {
);
}
} finally {
this.logger.info('Checked seed connections');
this.logger.debug('Checked seed connections');
// Re-schedule this task
await this.taskManager.scheduleTask({
delay: taskInfo.delay,
Expand Down Expand Up @@ -1126,12 +1126,12 @@ class NodeManager {
const filteredAddresses = addresses.filter(
(address) => address != null,
) as Array<NodeAddress>;
logger.info(
logger.debug(
`establishing multi-connection to the following seed nodes ${seedNodes.map(
(nodeId) => nodesUtils.encodeNodeId(nodeId),
)}`,
);
logger.info(
logger.debug(
`and addresses ${filteredAddresses.map(
(address) => `${address.host}:${address.port}`,
)}`,
Expand All @@ -1145,9 +1145,9 @@ class NodeManager {
undefined,
{ signal: ctx.signal },
);
logger.info(`Multi-connection established for`);
logger.debug(`Multi-connection established for`);
connections.forEach((address, key) => {
logger.info(
logger.debug(
`${nodesUtils.encodeNodeId(key)}@${address.host}:${address.port}`,
);
});
Expand All @@ -1162,7 +1162,7 @@ class NodeManager {
const closestNodesAll: Map<NodeId, NodeData> = new Map();
const localNodeId = this.keyManager.getNodeId();
let closestNode: NodeId | null = null;
logger.info('Getting closest nodes');
logger.debug('Getting closest nodes');
for (const [nodeId] of connections) {
const closestNodes =
await this.nodeConnectionManager.getRemoteNodeClosestNodes(
Expand All @@ -1187,11 +1187,11 @@ class NodeManager {
const distB = nodesUtils.nodeDistance(localNodeId, closestNode);
if (distA < distB) closestNode = closeNode;
}
logger.info('Starting pingsAndSet tasks');
logger.debug('Starting pingsAndSet tasks');
const pingTasks: Array<Task> = [];
for (const [nodeId, nodeData] of closestNodesAll) {
if (!localNodeId.equals(nodeId)) {
logger.info(
logger.debug(
`pingAndSetTask for ${nodesUtils.encodeNodeId(nodeId)}@${
nodeData.address.host
}:${nodeData.address.port}`,
Expand All @@ -1215,7 +1215,7 @@ class NodeManager {
}
if (block) {
// We want to wait for all the tasks
logger.info('Awaiting all pingAndSetTasks');
logger.debug('Awaiting all pingAndSetTasks');
await Promise.all(
pingTasks.map((task) => {
const prom = task.promise();
Expand All @@ -1233,7 +1233,7 @@ class NodeManager {
);
}
// Refreshing every bucket above the closest node
logger.info(`Triggering refreshBucket tasks`);
logger.debug(`Triggering refreshBucket tasks`);
let index = this.nodeGraph.nodeIdBits;
if (closestNode != null) {
const [bucketIndex] = this.nodeGraph.bucketIndex(closestNode);
Expand All @@ -1245,7 +1245,7 @@ class NodeManager {
refreshBuckets.push(task.promise());
}
if (block) {
logger.info(`Awaiting refreshBucket tasks`);
logger.debug(`Awaiting refreshBucket tasks`);
await Promise.all(refreshBuckets);
}
}
Expand Down

0 comments on commit ec5d32f

Please sign in to comment.