Skip to content

Commit 324ecbf

Browse files
committed
fix: remove dead code, simplify
1 parent 860ecfa commit 324ecbf

File tree

2 files changed

+4
-69
lines changed

2 files changed

+4
-69
lines changed

packages/sds/src/message_channel/message_channel.ts

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -141,12 +141,7 @@ export class MessageChannel extends TypedEventEmitter<MessageChannelEvents> {
141141
* Useful for adaptive sync intervals - increase frequency when repairs pending.
142142
*/
143143
public hasPendingRepairRequests(currentTime = Date.now()): boolean {
144-
if (!this.repairManager) {
145-
return false;
146-
}
147-
148-
const nextRequestTime = this.repairManager.getNextRequestTime();
149-
return nextRequestTime !== undefined && nextRequestTime <= currentTime;
144+
return this.repairManager?.hasRequestsReady(currentTime) ?? false;
150145
}
151146

152147
/**

packages/sds/src/message_channel/repair/repair.ts

Lines changed: 3 additions & 63 deletions
Original file line numberDiff line numberDiff line change
@@ -307,70 +307,10 @@ export class RepairManager {
307307
}
308308

309309
/**
310-
* Check if there are any pending outgoing repair requests
310+
* Check if there are repair requests ready to be sent
311311
*/
312-
public hasPendingRequests(): boolean {
313-
return this.outgoingBuffer.size > 0;
314-
}
315-
316-
/**
317-
* Get count of pending repair requests
318-
*/
319-
public getPendingRequestCount(): number {
320-
return this.outgoingBuffer.size;
321-
}
322-
323-
/**
324-
* Get count of pending repair responses
325-
*/
326-
public getPendingResponseCount(): number {
327-
return this.incomingBuffer.size;
328-
}
329-
330-
/**
331-
* Get next scheduled repair request time (earliest T_req)
332-
*/
333-
public getNextRequestTime(): number | undefined {
312+
public hasRequestsReady(currentTime = Date.now()): boolean {
334313
const items = this.outgoingBuffer.getItems();
335-
return items.length > 0 ? items[0].tReq : undefined;
336-
}
337-
338-
/**
339-
* Get next scheduled repair response time (earliest T_resp)
340-
*/
341-
public getNextResponseTime(): number | undefined {
342-
const items = this.incomingBuffer.getItems();
343-
return items.length > 0 ? items[0].tResp : undefined;
344-
}
345-
346-
/**
347-
* Check if a specific message has a pending repair request
348-
*/
349-
public isPendingRequest(messageId: string): boolean {
350-
return this.outgoingBuffer.has(messageId);
351-
}
352-
353-
/**
354-
* Check if we have a pending response for a message
355-
*/
356-
public isPendingResponse(messageId: string): boolean {
357-
return this.incomingBuffer.has(messageId);
358-
}
359-
360-
/**
361-
* Get stats for monitoring/debugging
362-
*/
363-
public getStats(): {
364-
pendingRequests: number;
365-
pendingResponses: number;
366-
nextRequestTime?: number;
367-
nextResponseTime?: number;
368-
} {
369-
return {
370-
pendingRequests: this.getPendingRequestCount(),
371-
pendingResponses: this.getPendingResponseCount(),
372-
nextRequestTime: this.getNextRequestTime(),
373-
nextResponseTime: this.getNextResponseTime()
374-
};
314+
return items.length > 0 && items[0].tReq <= currentTime;
375315
}
376316
}

0 commit comments

Comments
 (0)