Skip to content

Commit

Permalink
add useful logs
Browse files Browse the repository at this point in the history
  • Loading branch information
weboko committed Oct 13, 2024
1 parent cc089aa commit 857e9de
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 4 deletions.
11 changes: 7 additions & 4 deletions packages/sdk/src/protocols/filter/subscription_manager.ts
Original file line number Diff line number Diff line change
Expand Up @@ -242,18 +242,21 @@ export class SubscriptionManager implements ISubscription {
let result;
try {
result = await this.protocol.ping(peer);
return result;
} catch (error) {
return {
result = {
success: null,
failure: {
peerId,
error: ProtocolError.GENERIC_FAIL
}
};
} finally {
void this.reliabilityMonitor.handlePingResult(peerId, result);
}

log.info(
`Received result from filter ping peerId:${peerId.toString()}\tsuccess:${result.success?.toString()}\tfailure:${result.failure?.error}`
);
await this.reliabilityMonitor.handlePingResult(peerId, result);
return result;
}

private startSubscriptionsMaintenance(timeout: number): void {
Expand Down
3 changes: 3 additions & 0 deletions packages/sdk/src/reliability_monitor/receiver.ts
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,9 @@ export class ReceiverReliabilityMonitor {

if (failures >= this.maxPingFailures) {
try {
log.info(
`Attempting to renew ${peerId.toString()} due to ping failures.`
);
await this.renewAndSubscribePeer(peerId);
this.peerFailures.delete(peerId.toString());
} catch (error) {
Expand Down

0 comments on commit 857e9de

Please sign in to comment.