@peerbit/shared-log 7.0.10 → 8.0.0

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.
@@ -125,7 +125,7 @@ ResponseIPrune = __decorate([
125
125
  __metadata("design:paramtypes", [Object])
126
126
  ], ResponseIPrune);
127
127
  export { ResponseIPrune };
128
- const MAX_EXCHANGE_MESSAGE_SIZE = 5e6; // 5mb (since stream limits are 10mb)
128
+ const MAX_EXCHANGE_MESSAGE_SIZE = 1e5; // 100kb. Too large size might not be faster (even if we can do 5mb)
129
129
  export const createExchangeHeadsMessages = async (log, heads, gidParentCache) => {
130
130
  const messages = [];
131
131
  let size = 0;
@@ -1 +1 @@
1
- {"version":3,"file":"exchange-heads.js","sourceRoot":"","sources":["../../src/exchange-heads.ts"],"names":[],"mappings":";;;;;;;;;AAAA,OAAO,EAAE,OAAO,EAAE,KAAK,EAAE,GAAG,EAAE,UAAU,EAAE,MAAM,gBAAgB,CAAC;AACjE,OAAO,EAAE,KAAK,EAAE,SAAS,EAAgB,MAAM,cAAc,CAAC;AAE9D,OAAO,EAAE,MAAM,IAAI,QAAQ,EAAE,MAAM,iBAAiB,CAAC;AACrD,OAAO,EAAE,gBAAgB,EAAE,MAAM,cAAc,CAAC;AAGhD,MAAM,MAAM,GAAG,QAAQ,CAAC,EAAE,MAAM,EAAE,gBAAgB,EAAE,CAAC,CAAC;AAEtD;;;;GAIG;AAEI,IAAM,aAAa,GAAnB,MAAM,aAAa;IAEzB,KAAK,CAAW;IAGhB,YAAY,CAAW,CAAC,gCAAgC;IAExD,YAAY,UAAuD;QAClE,IAAI,CAAC,KAAK,GAAG,UAAU,CAAC,KAAK,CAAC;QAC9B,IAAI,CAAC,YAAY,GAAG,UAAU,CAAC,YAAY,CAAC;IAC7C,CAAC;CACD,CAAA;AATA;IADC,KAAK,CAAC,EAAE,IAAI,EAAE,KAAK,EAAE,CAAC;8BAChB,KAAK;4CAAI;AAGhB;IADC,KAAK,CAAC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AY,CAAC,CAAC;wBAC1B,CAAC;oBACF,CAAC;gBACF,CAAC;YACF,CAAC;YACD,IAAI,GAAG,KAAK,CAAC;QACd,CAAC;IACF,CAAC;IACD,MAAM,KAAK,GAAG;QACb,GAAG,CAAC,MAAM,OAAO,CAAC,GAAG,CACpB,CAAC,GAAG,GAAG,CAAC,MAAM,EAAE,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,GAAG,CAAC,UAAU,CAAC,GAAG,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,CACxD,CAAC;KACF,CAAC,MAAM,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,CAAC,CAAiB,CAAC;IACrC,cAAc,CAAC,GAAG,CAAC,KAAK,CAAC,IAAI,EAAE,KAAK,CAAC,CAAC;IACtC,OAAO,KAAK,CAAC;AACd,CAAC,CAAC"}
@@ -18,21 +18,21 @@ export type ReplicationLimitsOptions = Partial<ReplicationLimits> | {
18
18
  max?: number;
19
19
  };
20
20
  type StringRoleOptions = "observer" | "replicator";
21
- type AdaptiveReplicatorOptions = {
21
+ export type AdaptiveReplicatorOptions = {
22
22
  type: "replicator";
23
23
  limits?: {
24
- memory?: number;
24
+ storage?: number;
25
25
  cpu?: number | {
26
26
  max: number;
27
27
  monitor?: CPUUsage;
28
28
  };
29
29
  };
30
30
  };
31
- type FixedReplicatorOptions = {
31
+ export type FixedReplicatorOptions = {
32
32
  type: "replicator";
33
33
  factor: number;
34
34
  };
35
- type ObserverType = {
35
+ export type ObserverType = {
36
36
  type: "observer";
37
37
  };
38
38
  export type RoleOptions = StringRoleOptions | ObserverType | FixedReplicatorOptions | AdaptiveReplicatorOptions;
@@ -64,7 +64,7 @@ export declare class SharedLog<T = Uint8Array> extends Program<Args<T>, SharedLo
64
64
  log: Log<T>;
65
65
  rpc: RPC<TransportMessage, TransportMessage>;
66
66
  private _role;
67
- private _roleOptions;
67
+ private _roleConfig;
68
68
  private _sortedPeersCache;
69
69
  private _totalParticipation;
70
70
  private _gidPeersHistory;
@@ -80,12 +80,14 @@ export declare class SharedLog<T = Uint8Array> extends Program<Args<T>, SharedLo
80
80
  private latestRoleMessages;
81
81
  private remoteBlocks;
82
82
  private openTime;
83
+ private oldestOpenTime;
83
84
  private sync?;
84
85
  private rebalanceParticipationDebounced;
85
86
  private distributeInterval;
86
87
  private syncMoreInterval?;
87
88
  private syncInFlightQueue;
88
89
  private syncInFlightQueueInverted;
90
+ private syncInFlight;
89
91
  replicas: ReplicationLimits;
90
92
  private cpuUsage?;
91
93
  timeUntilRoleMaturity: number;
@@ -93,7 +95,14 @@ export declare class SharedLog<T = Uint8Array> extends Program<Args<T>, SharedLo
93
95
  constructor(properties?: {
94
96
  id?: Uint8Array;
95
97
  });
98
+ /**
99
+ * Returns the current role
100
+ */
96
101
  get role(): Observer | Replicator;
102
+ /**
103
+ * Return the
104
+ */
105
+ get roleConfig(): Observer | Replicator | AdaptiveReplicatorOptions;
97
106
  get totalParticipation(): number;
98
107
  private setupRebalanceDebounceFunction;
99
108
  private setupRole;
@@ -120,12 +129,14 @@ export declare class SharedLog<T = Uint8Array> extends Program<Args<T>, SharedLo
120
129
  candidates?: string[];
121
130
  roleAge?: number;
122
131
  }): Promise<boolean>;
132
+ private getReplicationOffset;
123
133
  private waitForIsLeader;
124
134
  findLeaders(subject: {
125
135
  toString(): string;
126
136
  }, numberOfLeaders: number, options?: {
127
137
  roleAge?: number;
128
138
  }): Promise<string[]>;
139
+ getDefaultMinRoleAge(): number;
129
140
  private findLeadersFromUniformNumber;
130
141
  /**
131
142
  *
@@ -147,6 +158,7 @@ export declare class SharedLog<T = Uint8Array> extends Program<Args<T>, SharedLo
147
158
  private _queue;
148
159
  distribute(): Promise<false | void>;
149
160
  _distribute(): Promise<false | undefined>;
161
+ private requestSync;
150
162
  _onUnsubscription(evt: CustomEvent<UnsubcriptionEvent>): Promise<void>;
151
163
  _onSubscription(evt: CustomEvent<SubscriptionEvent>): Promise<void>;
152
164
  replicationController: PIDReplicationController;
package/lib/esm/index.js CHANGED
@@ -22,7 +22,7 @@ import pDefer from "p-defer";
22
22
  import { Cache } from "@peerbit/cache";
23
23
  import { CustomEvent } from "@libp2p/interface";
24
24
  import yallist from "yallist";
25
- import { AcknowledgeDelivery, SeekDelivery, SilentDelivery, NotStartedError } from "@peerbit/stream-interface";
25
+ import { AcknowledgeDelivery, SilentDelivery, NotStartedError } from "@peerbit/stream-interface";
26
26
  import { AnyBlockStore, RemoteBlocks } from "@peerbit/blocks";
27
27
  import { BlocksMessage } from "./blocks.js";
28
28
  import debounce from "p-debounce";
@@ -30,7 +30,7 @@ import { PIDReplicationController } from "./pid.js";
30
30
  export * from "./replication.js";
31
31
  import PQueue from "p-queue";
32
32
  import { CPUUsageIntervalLag } from "./cpu.js";
33
- import { collectNodesAroundPoint, getCover } from "./ranges.js";
33
+ import { getCoverSet, getSamples, isMatured } from "./ranges.js";
34
34
  export { CPUUsageIntervalLag };
35
35
  export { Observer, Replicator, Role };
36
36
  export const logger = loggerFn({ module: "shared-log" });
@@ -65,7 +65,7 @@ let SharedLog = class SharedLog extends Program {
65
65
  rpc;
66
66
  // options
67
67
  _role;
68
- _roleOptions;
68
+ _roleConfig;
69
69
  _sortedPeersCache;
70
70
  _totalParticipation;
71
71
  _gidPeersHistory;
@@ -81,6 +81,7 @@ let SharedLog = class SharedLog extends Program {
81
81
  latestRoleMessages;
82
82
  remoteBlocks;
83
83
  openTime;
84
+ oldestOpenTime;
84
85
  sync;
85
86
  // A fn that we can call many times that recalculates the participation role
86
87
  rebalanceParticipationDebounced;
@@ -90,6 +91,7 @@ let SharedLog = class SharedLog extends Program {
90
91
  syncMoreInterval;
91
92
  syncInFlightQueue;
92
93
  syncInFlightQueueInverted;
94
+ syncInFlight;
93
95
  replicas;
94
96
  cpuUsage;
95
97
  timeUntilRoleMaturity;
@@ -99,9 +101,18 @@ let SharedLog = class SharedLog extends Program {
99
101
  this.log = new Log(properties);
100
102
  this.rpc = new RPC();
101
103
  }
104
+ /**
105
+ * Returns the current role
106
+ */
102
107
  get role() {
103
108
  return this._role;
104
109
  }
110
+ /**
111
+ * Return the
112
+ */
113
+ get roleConfig() {
114
+ return this._roleConfig;
115
+ }
105
116
  get totalParticipation() {
106
117
  return this._totalParticipation;
107
118
  }
@@ -114,8 +125,8 @@ let SharedLog = class SharedLog extends Program {
114
125
  const setupDebouncedRebalancing = (options) => {
115
126
  this.cpuUsage?.stop?.();
116
127
  this.replicationController = new PIDReplicationController(this.node.identity.publicKey.hashcode(), {
117
- memory: options?.limits?.memory != null
118
- ? { max: options?.limits?.memory }
128
+ storage: options?.limits?.storage != null
129
+ ? { max: options?.limits?.storage }
119
130
  : undefined,
120
131
  cpu: options?.limits?.cpu != null
121
132
  ? {
@@ -136,51 +147,51 @@ let SharedLog = class SharedLog extends Program {
136
147
  throw new Error("Unsupported role option type");
137
148
  }
138
149
  else if (options === "observer") {
139
- this._roleOptions = new Observer();
150
+ this._roleConfig = new Observer();
140
151
  }
141
152
  else if (options === "replicator") {
142
153
  setupDebouncedRebalancing();
143
- this._roleOptions = { type: options };
154
+ this._roleConfig = { type: options };
144
155
  }
145
156
  else if (options) {
146
157
  if (options.type === "replicator") {
147
158
  if (isAdaptiveReplicatorOption(options)) {
148
159
  setupDebouncedRebalancing(options);
149
- this._roleOptions = options;
160
+ this._roleConfig = options;
150
161
  }
151
162
  else {
152
- this._roleOptions = new Replicator({
163
+ this._roleConfig = new Replicator({
153
164
  factor: options.factor,
154
- offset: hashToUniformNumber(this.node.identity.publicKey.bytes)
165
+ offset: this.getReplicationOffset()
155
166
  });
156
167
  }
157
168
  }
158
169
  else {
159
- this._roleOptions = new Observer();
170
+ this._roleConfig = new Observer();
160
171
  }
161
172
  }
162
173
  else {
163
174
  // Default option
164
175
  setupDebouncedRebalancing();
165
- this._roleOptions = { type: "replicator" };
176
+ this._roleConfig = { type: "replicator" };
166
177
  }
167
178
  // setup the initial role
168
- if (this._roleOptions instanceof Replicator ||
169
- this._roleOptions instanceof Observer) {
170
- this._role = this._roleOptions;
179
+ if (this._roleConfig instanceof Replicator ||
180
+ this._roleConfig instanceof Observer) {
181
+ this._role = this._roleConfig;
171
182
  }
172
183
  else {
173
184
  // initial role in a dynamic setup
174
- if (this._roleOptions?.limits) {
185
+ if (this._roleConfig?.limits) {
175
186
  this._role = new Replicator({
176
187
  factor: this._role instanceof Replicator ? this._role.factor : 0,
177
- offset: hashToUniformNumber(this.node.identity.publicKey.bytes)
188
+ offset: this.getReplicationOffset()
178
189
  });
179
190
  }
180
191
  else {
181
192
  this._role = new Replicator({
182
193
  factor: this._role instanceof Replicator ? this._role.factor : 1,
183
- offset: hashToUniformNumber(this.node.identity.publicKey.bytes)
194
+ offset: this.getReplicationOffset()
184
195
  });
185
196
  }
186
197
  }
@@ -193,11 +204,7 @@ let SharedLog = class SharedLog extends Program {
193
204
  this._role = role;
194
205
  const { changed } = await this._modifyReplicators(this.role, this.node.identity.publicKey);
195
206
  await this.rpc.subscribe();
196
- await this.rpc.send(new ResponseRoleMessage({ role: this._role }), {
197
- mode: new SeekDelivery({
198
- redundancy: 1
199
- })
200
- });
207
+ await this.rpc.send(new ResponseRoleMessage({ role: this._role }));
201
208
  if (onRoleChange && changed !== "none") {
202
209
  this.onRoleChange(this._role, this.node.identity.publicKey);
203
210
  }
@@ -234,6 +241,16 @@ let SharedLog = class SharedLog extends Program {
234
241
  }
235
242
  leaders = newAndOldLeaders;
236
243
  }
244
+ let set = this._gidPeersHistory.get(result.entry.meta.gid);
245
+ if (!set) {
246
+ set = new Set(leaders);
247
+ this._gidPeersHistory.set(result.entry.meta.gid, set);
248
+ }
249
+ else {
250
+ for (const receiver of leaders) {
251
+ set.add(receiver);
252
+ }
253
+ }
237
254
  mode = isLeader
238
255
  ? new SilentDelivery({ redundancy: 1, to: leaders })
239
256
  : new AcknowledgeDelivery({ redundancy: 1, to: leaders });
@@ -265,7 +282,9 @@ let SharedLog = class SharedLog extends Program {
265
282
  this.latestRoleMessages = new Map();
266
283
  this.syncInFlightQueue = new Map();
267
284
  this.syncInFlightQueueInverted = new Map();
285
+ this.syncInFlight = new Map();
268
286
  this.openTime = +new Date();
287
+ this.oldestOpenTime = this.openTime;
269
288
  this.timeUntilRoleMaturity =
270
289
  options?.timeUntilRoleMaturity || WAIT_FOR_ROLE_MATURITY;
271
290
  this.waitForReplicatorTimeout =
@@ -277,7 +296,7 @@ let SharedLog = class SharedLog extends Program {
277
296
  this._logProperties = options;
278
297
  this.setupRole(options?.role);
279
298
  const id = sha256Base64Sync(this.log.id);
280
- const storage = await this.node.memory.sublevel(id);
299
+ const storage = await this.node.storage.sublevel(id);
281
300
  const localBlocks = await new AnyBlockStore(await storage.sublevel("blocks"));
282
301
  this.remoteBlocks = new RemoteBlocks({
283
302
  local: localBlocks,
@@ -378,13 +397,19 @@ let SharedLog = class SharedLog extends Program {
378
397
  this.syncInFlightQueue.delete(key);
379
398
  }
380
399
  }
381
- this.rpc
382
- .send(new ResponseMaybeSync({
383
- hashes: requestHashes
384
- }), {
385
- mode: new SilentDelivery({ to: from, redundancy: 1 })
386
- })
387
- .finally(() => {
400
+ const nowMin10s = +new Date() - 1e4;
401
+ for (const [key, map] of this.syncInFlight) {
402
+ // cleanup "old" missing syncs
403
+ for (const [hash, { timestamp }] of map) {
404
+ if (timestamp < nowMin10s) {
405
+ map.delete(hash);
406
+ }
407
+ }
408
+ if (map.size === 0) {
409
+ this.syncInFlight.delete(key);
410
+ }
411
+ }
412
+ this.requestSync(requestHashes, from).finally(() => {
388
413
  if (this.closed) {
389
414
  return;
390
415
  }
@@ -432,6 +457,7 @@ let SharedLog = class SharedLog extends Program {
432
457
  this._pendingIHave.clear();
433
458
  this.syncInFlightQueue.clear();
434
459
  this.syncInFlightQueueInverted.clear();
460
+ this.syncInFlight.clear();
435
461
  this.latestRoleMessages.clear();
436
462
  this._gidPeersHistory.clear();
437
463
  this._sortedPeersCache = undefined;
@@ -546,6 +572,16 @@ let SharedLog = class SharedLog extends Program {
546
572
  });
547
573
  this.rebalanceParticipationDebounced?.();
548
574
  }
575
+ /// we clear sync in flight here because we want to join before that, so that entries are totally accounted for
576
+ for (const head of heads) {
577
+ const set = this.syncInFlight.get(context.from.hashcode());
578
+ if (set) {
579
+ set.delete(head.entry.hash);
580
+ if (set?.size === 0) {
581
+ this.syncInFlight.delete(context.from.hashcode());
582
+ }
583
+ }
584
+ }
549
585
  if (maybeDelete) {
550
586
  for (const entries of maybeDelete) {
551
587
  const headsWithGid = this.log.headsIndex.gids.get(entries[0].entry.meta.gid);
@@ -629,14 +665,10 @@ let SharedLog = class SharedLog extends Program {
629
665
  }
630
666
  else if (!this.log.has(hash)) {
631
667
  this.syncInFlightQueue.set(hash, []);
632
- requestHashes.push(hash);
668
+ requestHashes.push(hash); // request immediately (first time we have seen this hash)
633
669
  }
634
670
  }
635
- await this.rpc.send(new ResponseMaybeSync({
636
- hashes: requestHashes
637
- }), {
638
- mode: new SilentDelivery({ to: [context.from], redundancy: 1 })
639
- });
671
+ await this.requestSync(requestHashes, [context.from.hashcode()]);
640
672
  }
641
673
  else if (msg instanceof ResponseMaybeSync) {
642
674
  // TODO better choice of step size
@@ -716,9 +748,11 @@ let SharedLog = class SharedLog extends Program {
716
748
  async waitForReplicator(...keys) {
717
749
  const check = () => {
718
750
  for (const k of keys) {
719
- if (!this.getReplicatorsSorted()
751
+ const rect = this.getReplicatorsSorted()
720
752
  ?.toArray()
721
- ?.find((x) => x.publicKey.equals(k))) {
753
+ ?.find((x) => x.publicKey.equals(k));
754
+ if (!rect ||
755
+ !isMatured(rect.role, +new Date(), this.getDefaultMinRoleAge())) {
722
756
  return false;
723
757
  }
724
758
  }
@@ -730,6 +764,9 @@ let SharedLog = class SharedLog extends Program {
730
764
  const isLeader = (await this.findLeaders(slot, numberOfLeaders, options)).find((l) => l === this.node.identity.publicKey.hashcode());
731
765
  return !!isLeader;
732
766
  }
767
+ getReplicationOffset() {
768
+ return hashToUniformNumber(this.node.identity.publicKey.bytes);
769
+ }
733
770
  async waitForIsLeader(slot, numberOfLeaders, timeout = this.waitForReplicatorTimeout) {
734
771
  return new Promise((res, rej) => {
735
772
  const removeListeners = () => {
@@ -776,29 +813,24 @@ let SharedLog = class SharedLog extends Program {
776
813
  const cursor = hashToUniformNumber(seed); // bounded between 0 and 1
777
814
  return this.findLeadersFromUniformNumber(cursor, numberOfLeaders, options);
778
815
  }
816
+ getDefaultMinRoleAge() {
817
+ const now = +new Date();
818
+ const replLength = this.getReplicatorsSorted().length;
819
+ const diffToOldest = replLength > 1 ? now - this.oldestOpenTime - 1 : Number.MAX_SAFE_INTEGER;
820
+ return Math.min(this.timeUntilRoleMaturity, diffToOldest, (this.timeUntilRoleMaturity * Math.log(replLength)) / 3); // / 3 so that if 2 replicators and timeUntilRoleMaturity = 1e4 the result will be 1
821
+ }
779
822
  findLeadersFromUniformNumber(cursor, numberOfLeaders, options) {
780
- const leaders = new Set();
781
- const width = 1;
782
- const peers = this.getReplicatorsSorted();
783
- if (!peers || peers?.length === 0) {
784
- return [];
785
- }
786
- numberOfLeaders = Math.min(numberOfLeaders, peers.length);
787
- const t = +new Date();
788
- const roleAge = options?.roleAge ??
789
- Math.min(this.timeUntilRoleMaturity, +new Date() - this.openTime - 500); // TODO -500 as is added so that i f someone else is just as new as us, then we treat them as mature as us. without -500 we might be slower syncing if two nodes starts almost at the same time
790
- for (let i = 0; i < numberOfLeaders; i++) {
791
- const point = ((cursor + i / numberOfLeaders) % 1) * width;
792
- const currentNode = peers.head;
793
- collectNodesAroundPoint(t, roleAge, peers, currentNode, leaders, point);
794
- }
795
- return [...leaders];
823
+ const roleAge = options?.roleAge ?? this.getDefaultMinRoleAge(); // TODO -500 as is added so that i f someone else is just as new as us, then we treat them as mature as us. without -500 we might be slower syncing if two nodes starts almost at the same time
824
+ const sampes = getSamples(cursor, this.getReplicatorsSorted(), numberOfLeaders, roleAge, this.role instanceof Replicator && this.role.factor === 0
825
+ ? this.node.identity.publicKey.hashcode()
826
+ : undefined);
827
+ return sampes;
796
828
  }
797
829
  /**
798
830
  *
799
831
  * @returns groups where at least one in any group will have the entry you are looking for
800
832
  */
801
- getReplicatorUnion(roleAge = this.timeUntilRoleMaturity) {
833
+ getReplicatorUnion(roleAge = this.getDefaultMinRoleAge()) {
802
834
  if (this.closed === true) {
803
835
  throw new Error("Closed");
804
836
  }
@@ -812,7 +844,12 @@ let SharedLog = class SharedLog extends Program {
812
844
  // to make sure we reach sufficient amount of nodes such that at least one one has
813
845
  // the entry we are looking for
814
846
  const coveringWidth = width / minReplicas;
815
- return getCover(coveringWidth, peers, roleAge, this.role instanceof Replicator ? this.node.identity.publicKey : undefined);
847
+ const set = getCoverSet(coveringWidth, peers, roleAge, this.role instanceof Replicator ? this.node.identity.publicKey : undefined);
848
+ // add all in flight
849
+ for (const [key, _] of this.syncInFlight) {
850
+ set.add(key);
851
+ }
852
+ return [...set];
816
853
  }
817
854
  async replicator(entry, options) {
818
855
  return this.isLeader(entry.gid, decodeReplicas(entry).getValue(this), options);
@@ -846,7 +883,7 @@ let SharedLog = class SharedLog extends Program {
846
883
  await this.rebalanceParticipationDebounced?.(); /* await this.rebalanceParticipation(false); */
847
884
  if (update.changed === "added") {
848
885
  await this.rpc.send(new ResponseRoleMessage({ role: this._role }), {
849
- mode: new SeekDelivery({
886
+ mode: new SilentDelivery({
850
887
  to: [publicKey.hashcode()],
851
888
  redundancy: 1
852
889
  })
@@ -881,6 +918,7 @@ let SharedLog = class SharedLog extends Program {
881
918
  // TODO should we remove replicators if they are already added?
882
919
  return { changed: "none" };
883
920
  }
921
+ this.oldestOpenTime = Math.min(this.oldestOpenTime, Number(role.timestamp));
884
922
  // insert or if already there do nothing
885
923
  const rect = {
886
924
  publicKey,
@@ -953,12 +991,26 @@ let SharedLog = class SharedLog extends Program {
953
991
  for (const [_a, b] of this._gidPeersHistory) {
954
992
  b.delete(publicKey.hashcode());
955
993
  }
994
+ this.syncInFlight.delete(publicKey.hashcode());
995
+ const waitingHashes = this.syncInFlightQueueInverted.get(publicKey.hashcode());
996
+ if (waitingHashes) {
997
+ for (const hash of waitingHashes) {
998
+ let arr = this.syncInFlightQueue.get(hash);
999
+ if (arr) {
1000
+ arr = arr.filter((x) => !x.equals(publicKey));
1001
+ }
1002
+ if (this.syncInFlightQueue.size === 0) {
1003
+ this.syncInFlightQueue.delete(hash);
1004
+ }
1005
+ }
1006
+ }
1007
+ this.syncInFlightQueueInverted.delete(publicKey.hashcode());
956
1008
  }
957
1009
  if (subscribed) {
958
1010
  if (this.role instanceof Replicator) {
959
1011
  this.rpc
960
1012
  .send(new ResponseRoleMessage({ role: this._role }), {
961
- mode: new SeekDelivery({ redundancy: 1, to: [publicKey] })
1013
+ mode: new SilentDelivery({ redundancy: 1, to: [publicKey] })
962
1014
  })
963
1015
  .catch((e) => logger.error(e.toString()));
964
1016
  }
@@ -1150,6 +1202,24 @@ let SharedLog = class SharedLog extends Program {
1150
1202
  }
1151
1203
  return changed;
1152
1204
  }
1205
+ async requestSync(hashes, to) {
1206
+ const now = +new Date();
1207
+ for (const node of to) {
1208
+ let map = this.syncInFlight.get(node);
1209
+ if (!map) {
1210
+ map = new Map();
1211
+ this.syncInFlight.set(node, map);
1212
+ }
1213
+ for (const hash of hashes) {
1214
+ map.set(hash, { timestamp: now });
1215
+ }
1216
+ }
1217
+ await this.rpc.send(new ResponseMaybeSync({
1218
+ hashes: hashes
1219
+ }), {
1220
+ mode: new SilentDelivery({ to, redundancy: 1 })
1221
+ });
1222
+ }
1153
1223
  async _onUnsubscription(evt) {
1154
1224
  logger.debug(`Peer disconnected '${evt.detail.from.hashcode()}' from '${JSON.stringify(evt.detail.unsubscriptions.map((x) => x))}'`);
1155
1225
  this.latestRoleMessages.delete(evt.detail.from.hashcode());
@@ -1196,11 +1266,11 @@ let SharedLog = class SharedLog extends Program {
1196
1266
  return false;
1197
1267
  }
1198
1268
  // The role is fixed (no changes depending on memory usage or peer count etc)
1199
- if (this._roleOptions instanceof Role) {
1269
+ if (this._roleConfig instanceof Role) {
1200
1270
  return false;
1201
1271
  }
1202
1272
  // TODO second condition: what if the current role is Observer?
1203
- if (this._roleOptions.type == "replicator" &&
1273
+ if (this._roleConfig.type == "replicator" &&
1204
1274
  this._role instanceof Replicator) {
1205
1275
  const peers = this.getReplicatorsSorted();
1206
1276
  const usedMemory = await this.getMemoryUsage();