fix: remove dead code, simplify

This commit is contained in:
jm-clius 2025-10-30 17:03:00 +00:00
parent 860ecfaca7
commit 324ecbf4d0
No known key found for this signature in database
GPG Key ID: 5FCD9D5211B952DA
2 changed files with 4 additions and 69 deletions

View File

@ -141,12 +141,7 @@ export class MessageChannel extends TypedEventEmitter<MessageChannelEvents> {
* 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;
}
/**

View File

@ -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;
}
}