From 324ecbf4d0c1ee8eaa08427659a50106c48f174c Mon Sep 17 00:00:00 2001 From: jm-clius Date: Thu, 30 Oct 2025 17:03:00 +0000 Subject: [PATCH] fix: remove dead code, simplify --- .../src/message_channel/message_channel.ts | 7 +- .../sds/src/message_channel/repair/repair.ts | 66 +------------------ 2 files changed, 4 insertions(+), 69 deletions(-) diff --git a/packages/sds/src/message_channel/message_channel.ts b/packages/sds/src/message_channel/message_channel.ts index 05b8f49d80..f554e31f5f 100644 --- a/packages/sds/src/message_channel/message_channel.ts +++ b/packages/sds/src/message_channel/message_channel.ts @@ -141,12 +141,7 @@ export class MessageChannel extends TypedEventEmitter { * Useful for adaptive sync intervals - increase frequency when repairs pending. */ public hasPendingRepairRequests(currentTime = Date.now()): boolean { - if (!this.repairManager) { - return false; - } - - const nextRequestTime = this.repairManager.getNextRequestTime(); - return nextRequestTime !== undefined && nextRequestTime <= currentTime; + return this.repairManager?.hasRequestsReady(currentTime) ?? false; } /** diff --git a/packages/sds/src/message_channel/repair/repair.ts b/packages/sds/src/message_channel/repair/repair.ts index 6a2117cd1d..1a8a85f43e 100644 --- a/packages/sds/src/message_channel/repair/repair.ts +++ b/packages/sds/src/message_channel/repair/repair.ts @@ -307,70 +307,10 @@ export class RepairManager { } /** - * Check if there are any pending outgoing repair requests + * Check if there are repair requests ready to be sent */ - public hasPendingRequests(): boolean { - return this.outgoingBuffer.size > 0; - } - - /** - * Get count of pending repair requests - */ - public getPendingRequestCount(): number { - return this.outgoingBuffer.size; - } - - /** - * Get count of pending repair responses - */ - public getPendingResponseCount(): number { - return this.incomingBuffer.size; - } - - /** - * Get next scheduled repair request time (earliest T_req) - */ - public getNextRequestTime(): number | undefined { + public hasRequestsReady(currentTime = Date.now()): boolean { const items = this.outgoingBuffer.getItems(); - return items.length > 0 ? items[0].tReq : undefined; - } - - /** - * Get next scheduled repair response time (earliest T_resp) - */ - public getNextResponseTime(): number | undefined { - const items = this.incomingBuffer.getItems(); - return items.length > 0 ? items[0].tResp : undefined; - } - - /** - * Check if a specific message has a pending repair request - */ - public isPendingRequest(messageId: string): boolean { - return this.outgoingBuffer.has(messageId); - } - - /** - * Check if we have a pending response for a message - */ - public isPendingResponse(messageId: string): boolean { - return this.incomingBuffer.has(messageId); - } - - /** - * Get stats for monitoring/debugging - */ - public getStats(): { - pendingRequests: number; - pendingResponses: number; - nextRequestTime?: number; - nextResponseTime?: number; - } { - return { - pendingRequests: this.getPendingRequestCount(), - pendingResponses: this.getPendingResponseCount(), - nextRequestTime: this.getNextRequestTime(), - nextResponseTime: this.getNextResponseTime() - }; + return items.length > 0 && items[0].tReq <= currentTime; } }