mirror of
https://github.com/logos-messaging/js-waku.git
synced 2026-01-07 00:03:07 +00:00
fix: remove dead code, simplify
This commit is contained in:
parent
860ecfaca7
commit
324ecbf4d0
@ -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;
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@ -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;
|
||||
}
|
||||
}
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user