@toon-protocol/client 5.2.0 → 5.2.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -6723,8 +6723,6 @@ var BatchSettlementPayer = class {
6723
6723
  config;
6724
6724
  /** Onboardings in flight, so concurrent first sends open one channel, not two. */
6725
6725
  onboarding = /* @__PURE__ */ new Map();
6726
- /** Channels whose last refusal said the connector holds more, without saying how much. */
6727
- inDoubt = /* @__PURE__ */ new Set();
6728
6726
  /**
6729
6727
  * A voucher for one packet charging `amount` on `chain`, or `undefined` when
6730
6728
  * this node offers no `batch-settlement` there — and so cannot be paid on
@@ -6862,7 +6860,7 @@ var BatchSettlementPayer = class {
6862
6860
  (await this.readChain(channel)).landed
6863
6861
  );
6864
6862
  await this.resync(channel, { recovering: true });
6865
- } else if (this.inDoubt.has(channel.channelId)) {
6863
+ } else if (manager.inDoubt(channel.channelId)) {
6866
6864
  await this.resync(channel);
6867
6865
  }
6868
6866
  if (manager.isClosing(channel.channelId)) return void 0;
@@ -6885,7 +6883,6 @@ var BatchSettlementPayer = class {
6885
6883
  }
6886
6884
  if (watermark === void 0) return;
6887
6885
  this.config.manager.adoptConnectorWatermark(channel.channelId, watermark, options);
6888
- this.inDoubt.delete(channel.channelId);
6889
6886
  }
6890
6887
  /**
6891
6888
  * The voucher claim-state challenge for `channel`, signed by its voucher
@@ -6996,7 +6993,7 @@ var BatchSettlementPayer = class {
6996
6993
  const reading = readVoucherRefusal(outcome.message, cumulative);
6997
6994
  manager.refused(channelId, cumulative, charge, reading);
6998
6995
  if (reading.notAdvancing && reading.connectorWatermark === void 0) {
6999
- this.inDoubt.add(channelId);
6996
+ manager.markInDoubt(channelId);
7000
6997
  }
7001
6998
  }
7002
6999
  };
@@ -7550,12 +7547,26 @@ var BatchChannelManager = class _BatchChannelManager {
7550
7547
  if (entry.provenFloor !== void 0 && adopted < entry.provenFloor) {
7551
7548
  adopted = entry.provenFloor;
7552
7549
  }
7550
+ const { watermarkUncertain: _settled, ...rest } = entry;
7553
7551
  this.store.save(channelId, {
7554
- ...entry,
7552
+ ...rest,
7555
7553
  cumulativeAmount: adopted,
7556
7554
  signedCeiling: adopted > ceiling ? adopted : ceiling
7557
7555
  });
7558
7556
  }
7557
+ /**
7558
+ * Mark `channelId`'s watermark as possibly out of step with the connector's.
7559
+ * Persisted, so the next invocation resyncs before it signs.
7560
+ */
7561
+ markInDoubt(channelId) {
7562
+ const entry = this.entry(channelId);
7563
+ if (entry.watermarkUncertain) return;
7564
+ this.store.save(channelId, { ...entry, watermarkUncertain: true });
7565
+ }
7566
+ /** Whether `channelId`'s watermark is in doubt, here or in an earlier invocation. */
7567
+ inDoubt(channelId) {
7568
+ return this.store.load(channelId)?.watermarkUncertain === true;
7569
+ }
7559
7570
  /** Whether this client still holds the watermark for `channelId`. */
7560
7571
  hasWatermark(channelId) {
7561
7572
  return this.store.load(channelId) !== void 0;
@@ -8634,4 +8645,4 @@ export {
8634
8645
  toEnvelopeRequest,
8635
8646
  ToonClient
8636
8647
  };
8637
- //# sourceMappingURL=chunk-KGT4XOBZ.js.map
8648
+ //# sourceMappingURL=chunk-IN75RK7V.js.map