From b1a4201a7dcf85c8f2a43278fa1f71c8039c2593 Mon Sep 17 00:00:00 2001 From: Lilleman auf Larv Date: Mon, 28 Sep 2026 01:13:51 +0200 Subject: [PATCH] Record a group's weight through weigh() alone --- src/expiring-groups.ts | 5 ++--- src/held-messages.ts | 3 ++- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/src/expiring-groups.ts b/src/expiring-groups.ts index 80440b6..ee40936 100644 --- a/src/expiring-groups.ts +++ b/src/expiring-groups.ts @@ -54,10 +54,9 @@ export class ExpiringGroups { } /** Starts the group's deadline, and the sweeper if this is the only group held. */ - set(key: string, group: T, weight = 0): void { + set(key: string, group: T): void { this.remove(key); - this.entries.set(key, { deadline: this.now() + this.timeout, group, weight }); - this.total += weight; + this.entries.set(key, { deadline: this.now() + this.timeout, group, weight: 0 }); if (this.sweeper) return; diff --git a/src/held-messages.ts b/src/held-messages.ts index a519d1a..cfacbd9 100644 --- a/src/held-messages.ts +++ b/src/held-messages.ts @@ -106,7 +106,8 @@ export class HeldMessages { this.log.warn('heldMessages - replacing a message on a re-used sequence number', { seqNr: Number(key) }); } - this.held.set(key, pduObjs, pduObjs.reduce((sum, pduObj) => sum + retainedOctets(pduObj), 0)); + this.held.set(key, pduObjs); + this.held.weigh(key, pduObjs.reduce((sum, pduObj) => sum + retainedOctets(pduObj), 0)); return hold; }