mirror of
https://github.com/logos-messaging/js-waku.git
synced 2026-01-08 00:33:12 +00:00
fix: remove some magic numbers
This commit is contained in:
parent
5580f2f1e9
commit
13ed84bd6f
@ -28,6 +28,11 @@ export const DEFAULT_BLOOM_FILTER_OPTIONS = {
|
||||
errorRate: 0.001
|
||||
};
|
||||
|
||||
/**
|
||||
* Maximum number of repair requests to include in a single message
|
||||
*/
|
||||
const MAX_REPAIR_REQUESTS_PER_MESSAGE = 3;
|
||||
|
||||
const DEFAULT_CAUSAL_HISTORY_SIZE = 200;
|
||||
const DEFAULT_POSSIBLE_ACKS_THRESHOLD = 2;
|
||||
|
||||
@ -421,7 +426,9 @@ export class MessageChannel extends TypedEventEmitter<MessageChannelEvents> {
|
||||
this.lamportTimestamp = lamportTimestampIncrement(this.lamportTimestamp);
|
||||
|
||||
// Get repair requests to include in sync message (SDS-R)
|
||||
const repairRequests = this.repairManager.getRepairRequests(3);
|
||||
const repairRequests = this.repairManager.getRepairRequests(
|
||||
MAX_REPAIR_REQUESTS_PER_MESSAGE
|
||||
);
|
||||
|
||||
const message = new SyncMessage(
|
||||
// does not need to be secure randomness
|
||||
@ -641,7 +648,9 @@ export class MessageChannel extends TypedEventEmitter<MessageChannelEvents> {
|
||||
log.info(this.senderId, "sending new message", messageId);
|
||||
|
||||
// Get repair requests to include in the message (SDS-R)
|
||||
const repairRequests = this.repairManager.getRepairRequests(3);
|
||||
const repairRequests = this.repairManager.getRepairRequests(
|
||||
MAX_REPAIR_REQUESTS_PER_MESSAGE
|
||||
);
|
||||
|
||||
message = new ContentMessage(
|
||||
messageId,
|
||||
|
||||
@ -15,6 +15,11 @@ import {
|
||||
|
||||
const log = new Logger("sds:repair:manager");
|
||||
|
||||
/**
|
||||
* Per SDS-R spec: One response group per 128 participants
|
||||
*/
|
||||
const PARTICIPANTS_PER_RESPONSE_GROUP = 128;
|
||||
|
||||
/**
|
||||
* Event emitter callback for repair events
|
||||
*/
|
||||
@ -42,7 +47,7 @@ export interface RepairConfig {
|
||||
export const DEFAULT_REPAIR_CONFIG: Required<RepairConfig> = {
|
||||
tMin: 30000, // 30 seconds
|
||||
tMax: 120000, // 120 seconds
|
||||
numResponseGroups: 1, // Recommendation is 1 group per 128 participants
|
||||
numResponseGroups: 1, // Recommendation is 1 group per PARTICIPANTS_PER_RESPONSE_GROUP participants
|
||||
bufferSize: 1000,
|
||||
enabled: true
|
||||
};
|
||||
@ -332,10 +337,10 @@ export class RepairManager {
|
||||
numParticipants = Number.MAX_SAFE_INTEGER;
|
||||
}
|
||||
|
||||
// Per spec: num_response_groups = max(1, num_participants / 128)
|
||||
// Per spec: num_response_groups = max(1, num_participants / PARTICIPANTS_PER_RESPONSE_GROUP)
|
||||
this.config.numResponseGroups = Math.max(
|
||||
1,
|
||||
Math.floor(numParticipants / 128)
|
||||
Math.floor(numParticipants / PARTICIPANTS_PER_RESPONSE_GROUP)
|
||||
);
|
||||
log.info(
|
||||
`Updated response groups to ${this.config.numResponseGroups} for ${numParticipants} participants`
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user