@peerbit/shared-log 16.0.6 → 16.0.8

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.
package/src/index.ts CHANGED
@@ -915,6 +915,13 @@ type NativeAppendEntryPlan<R extends "u32" | "u64"> = {
915
915
  committedNativeCoordinateDeletes?: boolean;
916
916
  };
917
917
 
918
+ type NativeFullReplicaCandidateSource = {
919
+ fullReplicaCandidatesFor?: (
920
+ minReplicas: number,
921
+ selfHash: string,
922
+ ) => string[];
923
+ };
924
+
918
925
  type EntryLeaderBatchItem<R extends "u32" | "u64"> = {
919
926
  entry: ShallowOrFullEntry<any> | EntryReplicated<R>;
920
927
  replicas: number;
@@ -8050,6 +8057,21 @@ export class SharedLog<
8050
8057
  return candidates;
8051
8058
  }
8052
8059
 
8060
+ private async getNativeFullReplicaDeliveryCandidates(
8061
+ minReplicas: number,
8062
+ selfHash: string,
8063
+ ): Promise<Set<string>> {
8064
+ const source = (this._nativeBackbone ?? this._nativeSharedLogState) as
8065
+ | NativeFullReplicaCandidateSource
8066
+ | undefined;
8067
+ if (typeof source?.fullReplicaCandidatesFor === "function") {
8068
+ return new Set(source.fullReplicaCandidatesFor(minReplicas, selfHash));
8069
+ }
8070
+ return this.getFullReplicaRepairCandidates(undefined, {
8071
+ includeSubscribers: false,
8072
+ });
8073
+ }
8074
+
8053
8075
  private removeRepairFrontierTarget(
8054
8076
  target: string,
8055
8077
  options?: { expectedWarmupSession?: WarmupSession | null },
@@ -13566,9 +13588,10 @@ export class SharedLog<
13566
13588
  ownershipLifecycleController,
13567
13589
  );
13568
13590
  const fullReplicaDeliveryCandidates =
13569
- await this.getFullReplicaRepairCandidates(undefined, {
13570
- includeSubscribers: false,
13571
- });
13591
+ await this.getNativeFullReplicaDeliveryCandidates(
13592
+ replicas,
13593
+ context.selfHash,
13594
+ );
13572
13595
  this.throwIfReplicationOwnershipLifecycleInactive(
13573
13596
  ownershipLifecycleController,
13574
13597
  );
@@ -13712,9 +13735,10 @@ export class SharedLog<
13712
13735
  ownershipLifecycleController,
13713
13736
  );
13714
13737
  const fullReplicaDeliveryCandidates =
13715
- await this.getFullReplicaRepairCandidates(undefined, {
13716
- includeSubscribers: false,
13717
- });
13738
+ await this.getNativeFullReplicaDeliveryCandidates(
13739
+ replicas,
13740
+ context.selfHash,
13741
+ );
13718
13742
  this.throwIfReplicationOwnershipLifecycleInactive(
13719
13743
  ownershipLifecycleController,
13720
13744
  );
@@ -13924,9 +13948,10 @@ export class SharedLog<
13924
13948
  ownershipLifecycleController,
13925
13949
  );
13926
13950
  const fullReplicaDeliveryCandidates =
13927
- await this.getFullReplicaRepairCandidates(undefined, {
13928
- includeSubscribers: false,
13929
- });
13951
+ await this.getNativeFullReplicaDeliveryCandidates(
13952
+ replicas,
13953
+ context.selfHash,
13954
+ );
13930
13955
  this.throwIfReplicationOwnershipLifecycleInactive(
13931
13956
  ownershipLifecycleController,
13932
13957
  );