@peerbit/shared-log 11.5.8 → 11.6.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.
- package/dist/benchmark/index.js +118 -63
- package/dist/benchmark/index.js.map +1 -1
- package/dist/benchmark/memory/child.js +112 -57
- package/dist/benchmark/memory/child.js.map +1 -1
- package/dist/benchmark/replication-prune.js.map +1 -1
- package/dist/benchmark/replication.js +1 -3
- package/dist/benchmark/replication.js.map +1 -1
- package/dist/src/blocks.js +61 -22
- package/dist/src/blocks.js.map +1 -1
- package/dist/src/debounce.d.ts +8 -8
- package/dist/src/exchange-heads.d.ts.map +1 -1
- package/dist/src/exchange-heads.js +164 -81
- package/dist/src/exchange-heads.js.map +1 -1
- package/dist/src/index.d.ts +1 -2
- package/dist/src/index.d.ts.map +1 -1
- package/dist/src/index.js +2421 -2380
- package/dist/src/index.js.map +1 -1
- package/dist/src/message.js +50 -10
- package/dist/src/message.js.map +1 -1
- package/dist/src/ranges.d.ts +13 -15
- package/dist/src/ranges.d.ts.map +1 -1
- package/dist/src/ranges.js +736 -589
- package/dist/src/ranges.js.map +1 -1
- package/dist/src/replication.js +216 -109
- package/dist/src/replication.js.map +1 -1
- package/dist/src/role.js +164 -89
- package/dist/src/role.js.map +1 -1
- package/dist/src/sync/rateless-iblt.d.ts +2 -3
- package/dist/src/sync/rateless-iblt.d.ts.map +1 -1
- package/dist/src/sync/rateless-iblt.js +224 -129
- package/dist/src/sync/rateless-iblt.js.map +1 -1
- package/dist/src/sync/simple.d.ts +1 -1
- package/dist/src/sync/simple.d.ts.map +1 -1
- package/dist/src/sync/simple.js +119 -52
- package/dist/src/sync/simple.js.map +1 -1
- package/package.json +19 -19
- package/src/exchange-heads.ts +3 -2
- package/src/index.ts +17 -15
- package/src/ranges.ts +10 -10
- package/src/sync/rateless-iblt.ts +3 -5
- package/src/sync/simple.ts +1 -1
package/dist/src/ranges.js
CHANGED
|
@@ -1,11 +1,36 @@
|
|
|
1
|
-
var
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
1
|
+
var __esDecorate = (this && this.__esDecorate) || function (ctor, descriptorIn, decorators, contextIn, initializers, extraInitializers) {
|
|
2
|
+
function accept(f) { if (f !== void 0 && typeof f !== "function") throw new TypeError("Function expected"); return f; }
|
|
3
|
+
var kind = contextIn.kind, key = kind === "getter" ? "get" : kind === "setter" ? "set" : "value";
|
|
4
|
+
var target = !descriptorIn && ctor ? contextIn["static"] ? ctor : ctor.prototype : null;
|
|
5
|
+
var descriptor = descriptorIn || (target ? Object.getOwnPropertyDescriptor(target, contextIn.name) : {});
|
|
6
|
+
var _, done = false;
|
|
7
|
+
for (var i = decorators.length - 1; i >= 0; i--) {
|
|
8
|
+
var context = {};
|
|
9
|
+
for (var p in contextIn) context[p] = p === "access" ? {} : contextIn[p];
|
|
10
|
+
for (var p in contextIn.access) context.access[p] = contextIn.access[p];
|
|
11
|
+
context.addInitializer = function (f) { if (done) throw new TypeError("Cannot add initializers after decoration has completed"); extraInitializers.push(accept(f || null)); };
|
|
12
|
+
var result = (0, decorators[i])(kind === "accessor" ? { get: descriptor.get, set: descriptor.set } : descriptor[key], context);
|
|
13
|
+
if (kind === "accessor") {
|
|
14
|
+
if (result === void 0) continue;
|
|
15
|
+
if (result === null || typeof result !== "object") throw new TypeError("Object expected");
|
|
16
|
+
if (_ = accept(result.get)) descriptor.get = _;
|
|
17
|
+
if (_ = accept(result.set)) descriptor.set = _;
|
|
18
|
+
if (_ = accept(result.init)) initializers.unshift(_);
|
|
19
|
+
}
|
|
20
|
+
else if (_ = accept(result)) {
|
|
21
|
+
if (kind === "field") initializers.unshift(_);
|
|
22
|
+
else descriptor[key] = _;
|
|
23
|
+
}
|
|
24
|
+
}
|
|
25
|
+
if (target) Object.defineProperty(target, contextIn.name, descriptor);
|
|
26
|
+
done = true;
|
|
6
27
|
};
|
|
7
|
-
var
|
|
8
|
-
|
|
28
|
+
var __runInitializers = (this && this.__runInitializers) || function (thisArg, initializers, value) {
|
|
29
|
+
var useValue = arguments.length > 2;
|
|
30
|
+
for (var i = 0; i < initializers.length; i++) {
|
|
31
|
+
value = useValue ? initializers[i].call(thisArg, value) : initializers[i].call(thisArg);
|
|
32
|
+
}
|
|
33
|
+
return useValue ? value : void 0;
|
|
9
34
|
};
|
|
10
35
|
import { deserialize, field, serialize, variant, vec } from "@dao-xyz/borsh";
|
|
11
36
|
import { PublicSignKey, equals, randomBytes, sha256Base64Sync, toBase64, } from "@peerbit/crypto";
|
|
@@ -51,309 +76,397 @@ export const shouldAssigneToRangeBoundary = (leaders, minReplicas) => {
|
|
|
51
76
|
export const isEntryReplicated = (x) => {
|
|
52
77
|
return x instanceof EntryReplicatedU32 || x instanceof EntryReplicatedU64;
|
|
53
78
|
};
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
+
let EntryReplicatedU32 = (() => {
|
|
80
|
+
let _hash_decorators;
|
|
81
|
+
let _hash_initializers = [];
|
|
82
|
+
let _hash_extraInitializers = [];
|
|
83
|
+
let _hashNumber_decorators;
|
|
84
|
+
let _hashNumber_initializers = [];
|
|
85
|
+
let _hashNumber_extraInitializers = [];
|
|
86
|
+
let _gid_decorators;
|
|
87
|
+
let _gid_initializers = [];
|
|
88
|
+
let _gid_extraInitializers = [];
|
|
89
|
+
let _coordinates_decorators;
|
|
90
|
+
let _coordinates_initializers = [];
|
|
91
|
+
let _coordinates_extraInitializers = [];
|
|
92
|
+
let _wallTime_decorators;
|
|
93
|
+
let _wallTime_initializers = [];
|
|
94
|
+
let _wallTime_extraInitializers = [];
|
|
95
|
+
let _assignedToRangeBoundary_decorators;
|
|
96
|
+
let _assignedToRangeBoundary_initializers = [];
|
|
97
|
+
let _assignedToRangeBoundary_extraInitializers = [];
|
|
98
|
+
let __meta_decorators;
|
|
99
|
+
let __meta_initializers = [];
|
|
100
|
+
let __meta_extraInitializers = [];
|
|
101
|
+
return class EntryReplicatedU32 {
|
|
102
|
+
static {
|
|
103
|
+
const _metadata = typeof Symbol === "function" && Symbol.metadata ? Object.create(null) : void 0;
|
|
104
|
+
_hash_decorators = [id({ type: "string" })];
|
|
105
|
+
_hashNumber_decorators = [field({ type: "u32" })];
|
|
106
|
+
_gid_decorators = [field({ type: "string" })];
|
|
107
|
+
_coordinates_decorators = [field({ type: vec("u32") })];
|
|
108
|
+
_wallTime_decorators = [field({ type: "u64" })];
|
|
109
|
+
_assignedToRangeBoundary_decorators = [field({ type: "bool" })];
|
|
110
|
+
__meta_decorators = [field({ type: Uint8Array })];
|
|
111
|
+
__esDecorate(null, null, _hash_decorators, { kind: "field", name: "hash", static: false, private: false, access: { has: obj => "hash" in obj, get: obj => obj.hash, set: (obj, value) => { obj.hash = value; } }, metadata: _metadata }, _hash_initializers, _hash_extraInitializers);
|
|
112
|
+
__esDecorate(null, null, _hashNumber_decorators, { kind: "field", name: "hashNumber", static: false, private: false, access: { has: obj => "hashNumber" in obj, get: obj => obj.hashNumber, set: (obj, value) => { obj.hashNumber = value; } }, metadata: _metadata }, _hashNumber_initializers, _hashNumber_extraInitializers);
|
|
113
|
+
__esDecorate(null, null, _gid_decorators, { kind: "field", name: "gid", static: false, private: false, access: { has: obj => "gid" in obj, get: obj => obj.gid, set: (obj, value) => { obj.gid = value; } }, metadata: _metadata }, _gid_initializers, _gid_extraInitializers);
|
|
114
|
+
__esDecorate(null, null, _coordinates_decorators, { kind: "field", name: "coordinates", static: false, private: false, access: { has: obj => "coordinates" in obj, get: obj => obj.coordinates, set: (obj, value) => { obj.coordinates = value; } }, metadata: _metadata }, _coordinates_initializers, _coordinates_extraInitializers);
|
|
115
|
+
__esDecorate(null, null, _wallTime_decorators, { kind: "field", name: "wallTime", static: false, private: false, access: { has: obj => "wallTime" in obj, get: obj => obj.wallTime, set: (obj, value) => { obj.wallTime = value; } }, metadata: _metadata }, _wallTime_initializers, _wallTime_extraInitializers);
|
|
116
|
+
__esDecorate(null, null, _assignedToRangeBoundary_decorators, { kind: "field", name: "assignedToRangeBoundary", static: false, private: false, access: { has: obj => "assignedToRangeBoundary" in obj, get: obj => obj.assignedToRangeBoundary, set: (obj, value) => { obj.assignedToRangeBoundary = value; } }, metadata: _metadata }, _assignedToRangeBoundary_initializers, _assignedToRangeBoundary_extraInitializers);
|
|
117
|
+
__esDecorate(null, null, __meta_decorators, { kind: "field", name: "_meta", static: false, private: false, access: { has: obj => "_meta" in obj, get: obj => obj._meta, set: (obj, value) => { obj._meta = value; } }, metadata: _metadata }, __meta_initializers, __meta_extraInitializers);
|
|
118
|
+
if (_metadata) Object.defineProperty(this, Symbol.metadata, { enumerable: true, configurable: true, writable: true, value: _metadata });
|
|
119
|
+
}
|
|
120
|
+
hash = __runInitializers(this, _hash_initializers, void 0);
|
|
121
|
+
hashNumber = (__runInitializers(this, _hash_extraInitializers), __runInitializers(this, _hashNumber_initializers, void 0));
|
|
122
|
+
gid = (__runInitializers(this, _hashNumber_extraInitializers), __runInitializers(this, _gid_initializers, void 0));
|
|
123
|
+
coordinates = (__runInitializers(this, _gid_extraInitializers), __runInitializers(this, _coordinates_initializers, void 0));
|
|
124
|
+
wallTime = (__runInitializers(this, _coordinates_extraInitializers), __runInitializers(this, _wallTime_initializers, void 0));
|
|
125
|
+
assignedToRangeBoundary = (__runInitializers(this, _wallTime_extraInitializers), __runInitializers(this, _assignedToRangeBoundary_initializers, void 0));
|
|
126
|
+
_meta = (__runInitializers(this, _assignedToRangeBoundary_extraInitializers), __runInitializers(this, __meta_initializers, void 0));
|
|
127
|
+
_metaResolved = __runInitializers(this, __meta_extraInitializers);
|
|
128
|
+
constructor(properties) {
|
|
129
|
+
this.coordinates = properties.coordinates;
|
|
130
|
+
this.hash = properties.hash;
|
|
131
|
+
this.gid = properties.meta.gid;
|
|
132
|
+
this.wallTime = properties.meta.clock.timestamp.wallTime;
|
|
133
|
+
this.hashNumber = properties.hashNumber;
|
|
134
|
+
const shallow = properties.meta instanceof Meta
|
|
135
|
+
? new ShallowMeta(properties.meta)
|
|
136
|
+
: properties.meta;
|
|
137
|
+
this._meta = serialize(shallow);
|
|
79
138
|
this._metaResolved = deserialize(this._meta, ShallowMeta);
|
|
139
|
+
this._metaResolved = properties.meta;
|
|
140
|
+
this.assignedToRangeBoundary = properties.assignedToRangeBoundary;
|
|
80
141
|
}
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
:
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
142
|
+
get meta() {
|
|
143
|
+
if (!this._metaResolved) {
|
|
144
|
+
this._metaResolved = deserialize(this._meta, ShallowMeta);
|
|
145
|
+
}
|
|
146
|
+
return this._metaResolved;
|
|
147
|
+
}
|
|
148
|
+
};
|
|
149
|
+
})();
|
|
150
|
+
export { EntryReplicatedU32 };
|
|
151
|
+
let EntryReplicatedU64 = (() => {
|
|
152
|
+
let _hash_decorators;
|
|
153
|
+
let _hash_initializers = [];
|
|
154
|
+
let _hash_extraInitializers = [];
|
|
155
|
+
let _hashNumber_decorators;
|
|
156
|
+
let _hashNumber_initializers = [];
|
|
157
|
+
let _hashNumber_extraInitializers = [];
|
|
158
|
+
let _gid_decorators;
|
|
159
|
+
let _gid_initializers = [];
|
|
160
|
+
let _gid_extraInitializers = [];
|
|
161
|
+
let _coordinates_decorators;
|
|
162
|
+
let _coordinates_initializers = [];
|
|
163
|
+
let _coordinates_extraInitializers = [];
|
|
164
|
+
let _wallTime_decorators;
|
|
165
|
+
let _wallTime_initializers = [];
|
|
166
|
+
let _wallTime_extraInitializers = [];
|
|
167
|
+
let _assignedToRangeBoundary_decorators;
|
|
168
|
+
let _assignedToRangeBoundary_initializers = [];
|
|
169
|
+
let _assignedToRangeBoundary_extraInitializers = [];
|
|
170
|
+
let __meta_decorators;
|
|
171
|
+
let __meta_initializers = [];
|
|
172
|
+
let __meta_extraInitializers = [];
|
|
173
|
+
return class EntryReplicatedU64 {
|
|
174
|
+
static {
|
|
175
|
+
const _metadata = typeof Symbol === "function" && Symbol.metadata ? Object.create(null) : void 0;
|
|
176
|
+
_hash_decorators = [id({ type: "string" })];
|
|
177
|
+
_hashNumber_decorators = [field({ type: "u64" })];
|
|
178
|
+
_gid_decorators = [field({ type: "string" })];
|
|
179
|
+
_coordinates_decorators = [field({ type: vec("u64") })];
|
|
180
|
+
_wallTime_decorators = [field({ type: "u64" })];
|
|
181
|
+
_assignedToRangeBoundary_decorators = [field({ type: "bool" })];
|
|
182
|
+
__meta_decorators = [field({ type: Uint8Array })];
|
|
183
|
+
__esDecorate(null, null, _hash_decorators, { kind: "field", name: "hash", static: false, private: false, access: { has: obj => "hash" in obj, get: obj => obj.hash, set: (obj, value) => { obj.hash = value; } }, metadata: _metadata }, _hash_initializers, _hash_extraInitializers);
|
|
184
|
+
__esDecorate(null, null, _hashNumber_decorators, { kind: "field", name: "hashNumber", static: false, private: false, access: { has: obj => "hashNumber" in obj, get: obj => obj.hashNumber, set: (obj, value) => { obj.hashNumber = value; } }, metadata: _metadata }, _hashNumber_initializers, _hashNumber_extraInitializers);
|
|
185
|
+
__esDecorate(null, null, _gid_decorators, { kind: "field", name: "gid", static: false, private: false, access: { has: obj => "gid" in obj, get: obj => obj.gid, set: (obj, value) => { obj.gid = value; } }, metadata: _metadata }, _gid_initializers, _gid_extraInitializers);
|
|
186
|
+
__esDecorate(null, null, _coordinates_decorators, { kind: "field", name: "coordinates", static: false, private: false, access: { has: obj => "coordinates" in obj, get: obj => obj.coordinates, set: (obj, value) => { obj.coordinates = value; } }, metadata: _metadata }, _coordinates_initializers, _coordinates_extraInitializers);
|
|
187
|
+
__esDecorate(null, null, _wallTime_decorators, { kind: "field", name: "wallTime", static: false, private: false, access: { has: obj => "wallTime" in obj, get: obj => obj.wallTime, set: (obj, value) => { obj.wallTime = value; } }, metadata: _metadata }, _wallTime_initializers, _wallTime_extraInitializers);
|
|
188
|
+
__esDecorate(null, null, _assignedToRangeBoundary_decorators, { kind: "field", name: "assignedToRangeBoundary", static: false, private: false, access: { has: obj => "assignedToRangeBoundary" in obj, get: obj => obj.assignedToRangeBoundary, set: (obj, value) => { obj.assignedToRangeBoundary = value; } }, metadata: _metadata }, _assignedToRangeBoundary_initializers, _assignedToRangeBoundary_extraInitializers);
|
|
189
|
+
__esDecorate(null, null, __meta_decorators, { kind: "field", name: "_meta", static: false, private: false, access: { has: obj => "_meta" in obj, get: obj => obj._meta, set: (obj, value) => { obj._meta = value; } }, metadata: _metadata }, __meta_initializers, __meta_extraInitializers);
|
|
190
|
+
if (_metadata) Object.defineProperty(this, Symbol.metadata, { enumerable: true, configurable: true, writable: true, value: _metadata });
|
|
191
|
+
}
|
|
192
|
+
hash = __runInitializers(this, _hash_initializers, void 0);
|
|
193
|
+
hashNumber = (__runInitializers(this, _hash_extraInitializers), __runInitializers(this, _hashNumber_initializers, void 0));
|
|
194
|
+
gid = (__runInitializers(this, _hashNumber_extraInitializers), __runInitializers(this, _gid_initializers, void 0));
|
|
195
|
+
coordinates = (__runInitializers(this, _gid_extraInitializers), __runInitializers(this, _coordinates_initializers, void 0));
|
|
196
|
+
wallTime = (__runInitializers(this, _coordinates_extraInitializers), __runInitializers(this, _wallTime_initializers, void 0));
|
|
197
|
+
assignedToRangeBoundary = (__runInitializers(this, _wallTime_extraInitializers), __runInitializers(this, _assignedToRangeBoundary_initializers, void 0));
|
|
198
|
+
_meta = (__runInitializers(this, _assignedToRangeBoundary_extraInitializers), __runInitializers(this, __meta_initializers, void 0));
|
|
199
|
+
_metaResolved = __runInitializers(this, __meta_extraInitializers);
|
|
200
|
+
constructor(properties) {
|
|
201
|
+
this.coordinates = properties.coordinates;
|
|
202
|
+
this.hash = properties.hash;
|
|
203
|
+
this.hashNumber = properties.hashNumber;
|
|
204
|
+
this.gid = properties.meta.gid;
|
|
205
|
+
this.wallTime = properties.meta.clock.timestamp.wallTime;
|
|
206
|
+
const shallow = properties.meta instanceof Meta
|
|
207
|
+
? new ShallowMeta(properties.meta)
|
|
208
|
+
: properties.meta;
|
|
209
|
+
this._meta = serialize(shallow);
|
|
137
210
|
this._metaResolved = deserialize(this._meta, ShallowMeta);
|
|
211
|
+
this._metaResolved = properties.meta;
|
|
212
|
+
this.assignedToRangeBoundary = properties.assignedToRangeBoundary;
|
|
138
213
|
}
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
__metadata("design:type", BigInt)
|
|
149
|
-
], EntryReplicatedU64.prototype, "hashNumber", void 0);
|
|
150
|
-
__decorate([
|
|
151
|
-
field({ type: "string" }),
|
|
152
|
-
__metadata("design:type", String)
|
|
153
|
-
], EntryReplicatedU64.prototype, "gid", void 0);
|
|
154
|
-
__decorate([
|
|
155
|
-
field({ type: vec("u64") }),
|
|
156
|
-
__metadata("design:type", Array)
|
|
157
|
-
], EntryReplicatedU64.prototype, "coordinates", void 0);
|
|
158
|
-
__decorate([
|
|
159
|
-
field({ type: "u64" }),
|
|
160
|
-
__metadata("design:type", BigInt)
|
|
161
|
-
], EntryReplicatedU64.prototype, "wallTime", void 0);
|
|
162
|
-
__decorate([
|
|
163
|
-
field({ type: "bool" }),
|
|
164
|
-
__metadata("design:type", Boolean)
|
|
165
|
-
], EntryReplicatedU64.prototype, "assignedToRangeBoundary", void 0);
|
|
166
|
-
__decorate([
|
|
167
|
-
field({ type: Uint8Array }),
|
|
168
|
-
__metadata("design:type", Uint8Array)
|
|
169
|
-
], EntryReplicatedU64.prototype, "_meta", void 0);
|
|
214
|
+
get meta() {
|
|
215
|
+
if (!this._metaResolved) {
|
|
216
|
+
this._metaResolved = deserialize(this._meta, ShallowMeta);
|
|
217
|
+
}
|
|
218
|
+
return this._metaResolved;
|
|
219
|
+
}
|
|
220
|
+
};
|
|
221
|
+
})();
|
|
222
|
+
export { EntryReplicatedU64 };
|
|
170
223
|
export const isReplicationRangeMessage = (x) => {
|
|
171
224
|
return x instanceof ReplicationRangeMessage;
|
|
172
225
|
};
|
|
173
226
|
export class ReplicationRangeMessage {
|
|
174
227
|
}
|
|
175
|
-
let ReplicationRangeMessageU32 =
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
};
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
228
|
+
let ReplicationRangeMessageU32 = (() => {
|
|
229
|
+
let _classDecorators = [variant(0)];
|
|
230
|
+
let _classDescriptor;
|
|
231
|
+
let _classExtraInitializers = [];
|
|
232
|
+
let _classThis;
|
|
233
|
+
let _classSuper = ReplicationRangeMessage;
|
|
234
|
+
let _id_decorators;
|
|
235
|
+
let _id_initializers = [];
|
|
236
|
+
let _id_extraInitializers = [];
|
|
237
|
+
let _timestamp_decorators;
|
|
238
|
+
let _timestamp_initializers = [];
|
|
239
|
+
let _timestamp_extraInitializers = [];
|
|
240
|
+
let __offset_decorators;
|
|
241
|
+
let __offset_initializers = [];
|
|
242
|
+
let __offset_extraInitializers = [];
|
|
243
|
+
let __factor_decorators;
|
|
244
|
+
let __factor_initializers = [];
|
|
245
|
+
let __factor_extraInitializers = [];
|
|
246
|
+
let _mode_decorators;
|
|
247
|
+
let _mode_initializers = [];
|
|
248
|
+
let _mode_extraInitializers = [];
|
|
249
|
+
var ReplicationRangeMessageU32 = class extends _classSuper {
|
|
250
|
+
static { _classThis = this; }
|
|
251
|
+
static {
|
|
252
|
+
const _metadata = typeof Symbol === "function" && Symbol.metadata ? Object.create(_classSuper[Symbol.metadata] ?? null) : void 0;
|
|
253
|
+
_id_decorators = [field({ type: Uint8Array })];
|
|
254
|
+
_timestamp_decorators = [field({ type: "u64" })];
|
|
255
|
+
__offset_decorators = [field({ type: "u32" })];
|
|
256
|
+
__factor_decorators = [field({ type: "u32" })];
|
|
257
|
+
_mode_decorators = [field({ type: "u8" })];
|
|
258
|
+
__esDecorate(null, null, _id_decorators, { kind: "field", name: "id", static: false, private: false, access: { has: obj => "id" in obj, get: obj => obj.id, set: (obj, value) => { obj.id = value; } }, metadata: _metadata }, _id_initializers, _id_extraInitializers);
|
|
259
|
+
__esDecorate(null, null, _timestamp_decorators, { kind: "field", name: "timestamp", static: false, private: false, access: { has: obj => "timestamp" in obj, get: obj => obj.timestamp, set: (obj, value) => { obj.timestamp = value; } }, metadata: _metadata }, _timestamp_initializers, _timestamp_extraInitializers);
|
|
260
|
+
__esDecorate(null, null, __offset_decorators, { kind: "field", name: "_offset", static: false, private: false, access: { has: obj => "_offset" in obj, get: obj => obj._offset, set: (obj, value) => { obj._offset = value; } }, metadata: _metadata }, __offset_initializers, __offset_extraInitializers);
|
|
261
|
+
__esDecorate(null, null, __factor_decorators, { kind: "field", name: "_factor", static: false, private: false, access: { has: obj => "_factor" in obj, get: obj => obj._factor, set: (obj, value) => { obj._factor = value; } }, metadata: _metadata }, __factor_initializers, __factor_extraInitializers);
|
|
262
|
+
__esDecorate(null, null, _mode_decorators, { kind: "field", name: "mode", static: false, private: false, access: { has: obj => "mode" in obj, get: obj => obj.mode, set: (obj, value) => { obj.mode = value; } }, metadata: _metadata }, _mode_initializers, _mode_extraInitializers);
|
|
263
|
+
__esDecorate(null, _classDescriptor = { value: _classThis }, _classDecorators, { kind: "class", name: _classThis.name, metadata: _metadata }, null, _classExtraInitializers);
|
|
264
|
+
ReplicationRangeMessageU32 = _classThis = _classDescriptor.value;
|
|
265
|
+
if (_metadata) Object.defineProperty(_classThis, Symbol.metadata, { enumerable: true, configurable: true, writable: true, value: _metadata });
|
|
266
|
+
__runInitializers(_classThis, _classExtraInitializers);
|
|
267
|
+
}
|
|
268
|
+
id = __runInitializers(this, _id_initializers, void 0);
|
|
269
|
+
timestamp = (__runInitializers(this, _id_extraInitializers), __runInitializers(this, _timestamp_initializers, void 0));
|
|
270
|
+
_offset = (__runInitializers(this, _timestamp_extraInitializers), __runInitializers(this, __offset_initializers, void 0));
|
|
271
|
+
_factor = (__runInitializers(this, __offset_extraInitializers), __runInitializers(this, __factor_initializers, void 0));
|
|
272
|
+
mode = (__runInitializers(this, __factor_extraInitializers), __runInitializers(this, _mode_initializers, void 0));
|
|
273
|
+
constructor(properties) {
|
|
274
|
+
super();
|
|
275
|
+
__runInitializers(this, _mode_extraInitializers);
|
|
276
|
+
const { id, offset, factor, timestamp, mode } = properties;
|
|
277
|
+
this.id = id;
|
|
278
|
+
this._offset = offset;
|
|
279
|
+
this._factor = factor;
|
|
280
|
+
this.timestamp = timestamp;
|
|
281
|
+
this.mode = mode;
|
|
282
|
+
}
|
|
283
|
+
get factor() {
|
|
284
|
+
return this._factor;
|
|
285
|
+
}
|
|
286
|
+
get offset() {
|
|
287
|
+
return this._offset;
|
|
288
|
+
}
|
|
289
|
+
toReplicationRangeIndexable(key) {
|
|
290
|
+
return new ReplicationRangeIndexableU32({
|
|
291
|
+
id: this.id,
|
|
292
|
+
publicKeyHash: key.hashcode(),
|
|
293
|
+
offset: this.offset,
|
|
294
|
+
width: this.factor,
|
|
295
|
+
timestamp: this.timestamp,
|
|
296
|
+
mode: this.mode,
|
|
297
|
+
});
|
|
298
|
+
}
|
|
299
|
+
};
|
|
300
|
+
return ReplicationRangeMessageU32 = _classThis;
|
|
301
|
+
})();
|
|
231
302
|
export { ReplicationRangeMessageU32 };
|
|
232
|
-
let ReplicationRangeMessageU64 =
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
};
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
|
|
303
|
+
let ReplicationRangeMessageU64 = (() => {
|
|
304
|
+
let _classDecorators = [variant(1)];
|
|
305
|
+
let _classDescriptor;
|
|
306
|
+
let _classExtraInitializers = [];
|
|
307
|
+
let _classThis;
|
|
308
|
+
let _classSuper = ReplicationRangeMessage;
|
|
309
|
+
let _id_decorators;
|
|
310
|
+
let _id_initializers = [];
|
|
311
|
+
let _id_extraInitializers = [];
|
|
312
|
+
let _timestamp_decorators;
|
|
313
|
+
let _timestamp_initializers = [];
|
|
314
|
+
let _timestamp_extraInitializers = [];
|
|
315
|
+
let __offset_decorators;
|
|
316
|
+
let __offset_initializers = [];
|
|
317
|
+
let __offset_extraInitializers = [];
|
|
318
|
+
let __factor_decorators;
|
|
319
|
+
let __factor_initializers = [];
|
|
320
|
+
let __factor_extraInitializers = [];
|
|
321
|
+
let _mode_decorators;
|
|
322
|
+
let _mode_initializers = [];
|
|
323
|
+
let _mode_extraInitializers = [];
|
|
324
|
+
var ReplicationRangeMessageU64 = class extends _classSuper {
|
|
325
|
+
static { _classThis = this; }
|
|
326
|
+
static {
|
|
327
|
+
const _metadata = typeof Symbol === "function" && Symbol.metadata ? Object.create(_classSuper[Symbol.metadata] ?? null) : void 0;
|
|
328
|
+
_id_decorators = [field({ type: Uint8Array })];
|
|
329
|
+
_timestamp_decorators = [field({ type: "u64" })];
|
|
330
|
+
__offset_decorators = [field({ type: "u64" })];
|
|
331
|
+
__factor_decorators = [field({ type: "u64" })];
|
|
332
|
+
_mode_decorators = [field({ type: "u8" })];
|
|
333
|
+
__esDecorate(null, null, _id_decorators, { kind: "field", name: "id", static: false, private: false, access: { has: obj => "id" in obj, get: obj => obj.id, set: (obj, value) => { obj.id = value; } }, metadata: _metadata }, _id_initializers, _id_extraInitializers);
|
|
334
|
+
__esDecorate(null, null, _timestamp_decorators, { kind: "field", name: "timestamp", static: false, private: false, access: { has: obj => "timestamp" in obj, get: obj => obj.timestamp, set: (obj, value) => { obj.timestamp = value; } }, metadata: _metadata }, _timestamp_initializers, _timestamp_extraInitializers);
|
|
335
|
+
__esDecorate(null, null, __offset_decorators, { kind: "field", name: "_offset", static: false, private: false, access: { has: obj => "_offset" in obj, get: obj => obj._offset, set: (obj, value) => { obj._offset = value; } }, metadata: _metadata }, __offset_initializers, __offset_extraInitializers);
|
|
336
|
+
__esDecorate(null, null, __factor_decorators, { kind: "field", name: "_factor", static: false, private: false, access: { has: obj => "_factor" in obj, get: obj => obj._factor, set: (obj, value) => { obj._factor = value; } }, metadata: _metadata }, __factor_initializers, __factor_extraInitializers);
|
|
337
|
+
__esDecorate(null, null, _mode_decorators, { kind: "field", name: "mode", static: false, private: false, access: { has: obj => "mode" in obj, get: obj => obj.mode, set: (obj, value) => { obj.mode = value; } }, metadata: _metadata }, _mode_initializers, _mode_extraInitializers);
|
|
338
|
+
__esDecorate(null, _classDescriptor = { value: _classThis }, _classDecorators, { kind: "class", name: _classThis.name, metadata: _metadata }, null, _classExtraInitializers);
|
|
339
|
+
ReplicationRangeMessageU64 = _classThis = _classDescriptor.value;
|
|
340
|
+
if (_metadata) Object.defineProperty(_classThis, Symbol.metadata, { enumerable: true, configurable: true, writable: true, value: _metadata });
|
|
341
|
+
__runInitializers(_classThis, _classExtraInitializers);
|
|
342
|
+
}
|
|
343
|
+
id = __runInitializers(this, _id_initializers, void 0);
|
|
344
|
+
timestamp = (__runInitializers(this, _id_extraInitializers), __runInitializers(this, _timestamp_initializers, void 0));
|
|
345
|
+
_offset = (__runInitializers(this, _timestamp_extraInitializers), __runInitializers(this, __offset_initializers, void 0));
|
|
346
|
+
_factor = (__runInitializers(this, __offset_extraInitializers), __runInitializers(this, __factor_initializers, void 0));
|
|
347
|
+
mode = (__runInitializers(this, __factor_extraInitializers), __runInitializers(this, _mode_initializers, void 0));
|
|
348
|
+
constructor(properties) {
|
|
349
|
+
super();
|
|
350
|
+
__runInitializers(this, _mode_extraInitializers);
|
|
351
|
+
const { id, offset, factor, timestamp, mode } = properties;
|
|
352
|
+
this.id = id;
|
|
353
|
+
this._offset = offset;
|
|
354
|
+
this._factor = factor;
|
|
355
|
+
this.timestamp = timestamp;
|
|
356
|
+
this.mode = mode;
|
|
357
|
+
}
|
|
358
|
+
get factor() {
|
|
359
|
+
return this._factor;
|
|
360
|
+
}
|
|
361
|
+
get offset() {
|
|
362
|
+
return this._offset;
|
|
363
|
+
}
|
|
364
|
+
toReplicationRangeIndexable(key) {
|
|
365
|
+
return new ReplicationRangeIndexableU64({
|
|
366
|
+
id: this.id,
|
|
367
|
+
publicKeyHash: key.hashcode(),
|
|
368
|
+
offset: this.offset,
|
|
369
|
+
width: this.factor,
|
|
370
|
+
timestamp: this.timestamp,
|
|
371
|
+
mode: this.mode,
|
|
372
|
+
});
|
|
373
|
+
}
|
|
374
|
+
};
|
|
375
|
+
return ReplicationRangeMessageU64 = _classThis;
|
|
376
|
+
})();
|
|
288
377
|
export { ReplicationRangeMessageU64 };
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
|
|
312
|
-
|
|
313
|
-
|
|
314
|
-
|
|
315
|
-
|
|
316
|
-
|
|
317
|
-
|
|
318
|
-
|
|
319
|
-
|
|
320
|
-
|
|
321
|
-
|
|
322
|
-
|
|
323
|
-
|
|
324
|
-
|
|
325
|
-
|
|
326
|
-
|
|
327
|
-
|
|
328
|
-
|
|
329
|
-
|
|
330
|
-
|
|
331
|
-
|
|
332
|
-
|
|
333
|
-
|
|
334
|
-
|
|
335
|
-
|
|
336
|
-
|
|
337
|
-
|
|
338
|
-
|
|
339
|
-
|
|
340
|
-
|
|
341
|
-
|
|
342
|
-
|
|
343
|
-
|
|
344
|
-
|
|
345
|
-
|
|
346
|
-
|
|
347
|
-
|
|
348
|
-
|
|
349
|
-
|
|
350
|
-
|
|
351
|
-
|
|
352
|
-
|
|
353
|
-
|
|
354
|
-
|
|
355
|
-
|
|
356
|
-
|
|
378
|
+
let HashableSegmentU32 = (() => {
|
|
379
|
+
let _start1_decorators;
|
|
380
|
+
let _start1_initializers = [];
|
|
381
|
+
let _start1_extraInitializers = [];
|
|
382
|
+
let _end1_decorators;
|
|
383
|
+
let _end1_initializers = [];
|
|
384
|
+
let _end1_extraInitializers = [];
|
|
385
|
+
let _start2_decorators;
|
|
386
|
+
let _start2_initializers = [];
|
|
387
|
+
let _start2_extraInitializers = [];
|
|
388
|
+
let _end2_decorators;
|
|
389
|
+
let _end2_initializers = [];
|
|
390
|
+
let _end2_extraInitializers = [];
|
|
391
|
+
let _mode_decorators;
|
|
392
|
+
let _mode_initializers = [];
|
|
393
|
+
let _mode_extraInitializers = [];
|
|
394
|
+
return class HashableSegmentU32 {
|
|
395
|
+
static {
|
|
396
|
+
const _metadata = typeof Symbol === "function" && Symbol.metadata ? Object.create(null) : void 0;
|
|
397
|
+
_start1_decorators = [field({ type: "u32" })];
|
|
398
|
+
_end1_decorators = [field({ type: "u32" })];
|
|
399
|
+
_start2_decorators = [field({ type: "u32" })];
|
|
400
|
+
_end2_decorators = [field({ type: "u32" })];
|
|
401
|
+
_mode_decorators = [field({ type: "u8" })];
|
|
402
|
+
__esDecorate(null, null, _start1_decorators, { kind: "field", name: "start1", static: false, private: false, access: { has: obj => "start1" in obj, get: obj => obj.start1, set: (obj, value) => { obj.start1 = value; } }, metadata: _metadata }, _start1_initializers, _start1_extraInitializers);
|
|
403
|
+
__esDecorate(null, null, _end1_decorators, { kind: "field", name: "end1", static: false, private: false, access: { has: obj => "end1" in obj, get: obj => obj.end1, set: (obj, value) => { obj.end1 = value; } }, metadata: _metadata }, _end1_initializers, _end1_extraInitializers);
|
|
404
|
+
__esDecorate(null, null, _start2_decorators, { kind: "field", name: "start2", static: false, private: false, access: { has: obj => "start2" in obj, get: obj => obj.start2, set: (obj, value) => { obj.start2 = value; } }, metadata: _metadata }, _start2_initializers, _start2_extraInitializers);
|
|
405
|
+
__esDecorate(null, null, _end2_decorators, { kind: "field", name: "end2", static: false, private: false, access: { has: obj => "end2" in obj, get: obj => obj.end2, set: (obj, value) => { obj.end2 = value; } }, metadata: _metadata }, _end2_initializers, _end2_extraInitializers);
|
|
406
|
+
__esDecorate(null, null, _mode_decorators, { kind: "field", name: "mode", static: false, private: false, access: { has: obj => "mode" in obj, get: obj => obj.mode, set: (obj, value) => { obj.mode = value; } }, metadata: _metadata }, _mode_initializers, _mode_extraInitializers);
|
|
407
|
+
if (_metadata) Object.defineProperty(this, Symbol.metadata, { enumerable: true, configurable: true, writable: true, value: _metadata });
|
|
408
|
+
}
|
|
409
|
+
start1 = __runInitializers(this, _start1_initializers, void 0);
|
|
410
|
+
end1 = (__runInitializers(this, _start1_extraInitializers), __runInitializers(this, _end1_initializers, void 0));
|
|
411
|
+
start2 = (__runInitializers(this, _end1_extraInitializers), __runInitializers(this, _start2_initializers, void 0));
|
|
412
|
+
end2 = (__runInitializers(this, _start2_extraInitializers), __runInitializers(this, _end2_initializers, void 0));
|
|
413
|
+
mode = (__runInitializers(this, _end2_extraInitializers), __runInitializers(this, _mode_initializers, void 0));
|
|
414
|
+
constructor(properties) {
|
|
415
|
+
__runInitializers(this, _mode_extraInitializers);
|
|
416
|
+
this.start1 = properties.start1;
|
|
417
|
+
this.end1 = properties.end1;
|
|
418
|
+
this.start2 = properties.start2;
|
|
419
|
+
this.end2 = properties.end2;
|
|
420
|
+
this.mode = properties.mode;
|
|
421
|
+
}
|
|
422
|
+
};
|
|
423
|
+
})();
|
|
424
|
+
let HashableSegmentU64 = (() => {
|
|
425
|
+
let _start1_decorators;
|
|
426
|
+
let _start1_initializers = [];
|
|
427
|
+
let _start1_extraInitializers = [];
|
|
428
|
+
let _end1_decorators;
|
|
429
|
+
let _end1_initializers = [];
|
|
430
|
+
let _end1_extraInitializers = [];
|
|
431
|
+
let _start2_decorators;
|
|
432
|
+
let _start2_initializers = [];
|
|
433
|
+
let _start2_extraInitializers = [];
|
|
434
|
+
let _end2_decorators;
|
|
435
|
+
let _end2_initializers = [];
|
|
436
|
+
let _end2_extraInitializers = [];
|
|
437
|
+
let _mode_decorators;
|
|
438
|
+
let _mode_initializers = [];
|
|
439
|
+
let _mode_extraInitializers = [];
|
|
440
|
+
return class HashableSegmentU64 {
|
|
441
|
+
static {
|
|
442
|
+
const _metadata = typeof Symbol === "function" && Symbol.metadata ? Object.create(null) : void 0;
|
|
443
|
+
_start1_decorators = [field({ type: "u64" })];
|
|
444
|
+
_end1_decorators = [field({ type: "u64" })];
|
|
445
|
+
_start2_decorators = [field({ type: "u64" })];
|
|
446
|
+
_end2_decorators = [field({ type: "u64" })];
|
|
447
|
+
_mode_decorators = [field({ type: "u8" })];
|
|
448
|
+
__esDecorate(null, null, _start1_decorators, { kind: "field", name: "start1", static: false, private: false, access: { has: obj => "start1" in obj, get: obj => obj.start1, set: (obj, value) => { obj.start1 = value; } }, metadata: _metadata }, _start1_initializers, _start1_extraInitializers);
|
|
449
|
+
__esDecorate(null, null, _end1_decorators, { kind: "field", name: "end1", static: false, private: false, access: { has: obj => "end1" in obj, get: obj => obj.end1, set: (obj, value) => { obj.end1 = value; } }, metadata: _metadata }, _end1_initializers, _end1_extraInitializers);
|
|
450
|
+
__esDecorate(null, null, _start2_decorators, { kind: "field", name: "start2", static: false, private: false, access: { has: obj => "start2" in obj, get: obj => obj.start2, set: (obj, value) => { obj.start2 = value; } }, metadata: _metadata }, _start2_initializers, _start2_extraInitializers);
|
|
451
|
+
__esDecorate(null, null, _end2_decorators, { kind: "field", name: "end2", static: false, private: false, access: { has: obj => "end2" in obj, get: obj => obj.end2, set: (obj, value) => { obj.end2 = value; } }, metadata: _metadata }, _end2_initializers, _end2_extraInitializers);
|
|
452
|
+
__esDecorate(null, null, _mode_decorators, { kind: "field", name: "mode", static: false, private: false, access: { has: obj => "mode" in obj, get: obj => obj.mode, set: (obj, value) => { obj.mode = value; } }, metadata: _metadata }, _mode_initializers, _mode_extraInitializers);
|
|
453
|
+
if (_metadata) Object.defineProperty(this, Symbol.metadata, { enumerable: true, configurable: true, writable: true, value: _metadata });
|
|
454
|
+
}
|
|
455
|
+
start1 = __runInitializers(this, _start1_initializers, void 0);
|
|
456
|
+
end1 = (__runInitializers(this, _start1_extraInitializers), __runInitializers(this, _end1_initializers, void 0));
|
|
457
|
+
start2 = (__runInitializers(this, _end1_extraInitializers), __runInitializers(this, _start2_initializers, void 0));
|
|
458
|
+
end2 = (__runInitializers(this, _start2_extraInitializers), __runInitializers(this, _end2_initializers, void 0));
|
|
459
|
+
mode = (__runInitializers(this, _end2_extraInitializers), __runInitializers(this, _mode_initializers, void 0));
|
|
460
|
+
constructor(properties) {
|
|
461
|
+
__runInitializers(this, _mode_extraInitializers);
|
|
462
|
+
this.start1 = properties.start1;
|
|
463
|
+
this.end1 = properties.end1;
|
|
464
|
+
this.start2 = properties.start2;
|
|
465
|
+
this.end2 = properties.end2;
|
|
466
|
+
this.mode = properties.mode;
|
|
467
|
+
}
|
|
468
|
+
};
|
|
469
|
+
})();
|
|
357
470
|
/**
|
|
358
471
|
* Convert a GeneralRange<N> into one or two `[bigint, bigint]` segments.
|
|
359
472
|
* - If it’s not wrapped, there’s one segment: [start1, end1).
|
|
@@ -533,304 +646,338 @@ export function symmetricDifferenceRanges(rangeA, rangeB) {
|
|
|
533
646
|
rangesFromB,
|
|
534
647
|
};
|
|
535
648
|
}
|
|
536
|
-
|
|
537
|
-
|
|
538
|
-
|
|
539
|
-
|
|
540
|
-
|
|
541
|
-
|
|
542
|
-
|
|
543
|
-
|
|
544
|
-
|
|
545
|
-
|
|
546
|
-
|
|
547
|
-
|
|
548
|
-
|
|
549
|
-
|
|
550
|
-
|
|
551
|
-
|
|
552
|
-
|
|
553
|
-
|
|
554
|
-
|
|
555
|
-
|
|
556
|
-
|
|
557
|
-
|
|
558
|
-
|
|
559
|
-
|
|
560
|
-
|
|
561
|
-
|
|
562
|
-
|
|
563
|
-
|
|
564
|
-
|
|
565
|
-
|
|
566
|
-
|
|
567
|
-
|
|
568
|
-
|
|
569
|
-
|
|
570
|
-
|
|
571
|
-
|
|
649
|
+
let ReplicationRangeIndexableU32 = (() => {
|
|
650
|
+
let _id_decorators;
|
|
651
|
+
let _id_initializers = [];
|
|
652
|
+
let _id_extraInitializers = [];
|
|
653
|
+
let _hash_decorators;
|
|
654
|
+
let _hash_initializers = [];
|
|
655
|
+
let _hash_extraInitializers = [];
|
|
656
|
+
let _timestamp_decorators;
|
|
657
|
+
let _timestamp_initializers = [];
|
|
658
|
+
let _timestamp_extraInitializers = [];
|
|
659
|
+
let _start1_decorators;
|
|
660
|
+
let _start1_initializers = [];
|
|
661
|
+
let _start1_extraInitializers = [];
|
|
662
|
+
let _end1_decorators;
|
|
663
|
+
let _end1_initializers = [];
|
|
664
|
+
let _end1_extraInitializers = [];
|
|
665
|
+
let _start2_decorators;
|
|
666
|
+
let _start2_initializers = [];
|
|
667
|
+
let _start2_extraInitializers = [];
|
|
668
|
+
let _end2_decorators;
|
|
669
|
+
let _end2_initializers = [];
|
|
670
|
+
let _end2_extraInitializers = [];
|
|
671
|
+
let _width_decorators;
|
|
672
|
+
let _width_initializers = [];
|
|
673
|
+
let _width_extraInitializers = [];
|
|
674
|
+
let _mode_decorators;
|
|
675
|
+
let _mode_initializers = [];
|
|
676
|
+
let _mode_extraInitializers = [];
|
|
677
|
+
return class ReplicationRangeIndexableU32 {
|
|
678
|
+
static {
|
|
679
|
+
const _metadata = typeof Symbol === "function" && Symbol.metadata ? Object.create(null) : void 0;
|
|
680
|
+
_id_decorators = [id({ type: Uint8Array })];
|
|
681
|
+
_hash_decorators = [field({ type: "string" })];
|
|
682
|
+
_timestamp_decorators = [field({ type: "u64" })];
|
|
683
|
+
_start1_decorators = [field({ type: "u32" })];
|
|
684
|
+
_end1_decorators = [field({ type: "u32" })];
|
|
685
|
+
_start2_decorators = [field({ type: "u32" })];
|
|
686
|
+
_end2_decorators = [field({ type: "u32" })];
|
|
687
|
+
_width_decorators = [field({ type: "u32" })];
|
|
688
|
+
_mode_decorators = [field({ type: "u8" })];
|
|
689
|
+
__esDecorate(null, null, _id_decorators, { kind: "field", name: "id", static: false, private: false, access: { has: obj => "id" in obj, get: obj => obj.id, set: (obj, value) => { obj.id = value; } }, metadata: _metadata }, _id_initializers, _id_extraInitializers);
|
|
690
|
+
__esDecorate(null, null, _hash_decorators, { kind: "field", name: "hash", static: false, private: false, access: { has: obj => "hash" in obj, get: obj => obj.hash, set: (obj, value) => { obj.hash = value; } }, metadata: _metadata }, _hash_initializers, _hash_extraInitializers);
|
|
691
|
+
__esDecorate(null, null, _timestamp_decorators, { kind: "field", name: "timestamp", static: false, private: false, access: { has: obj => "timestamp" in obj, get: obj => obj.timestamp, set: (obj, value) => { obj.timestamp = value; } }, metadata: _metadata }, _timestamp_initializers, _timestamp_extraInitializers);
|
|
692
|
+
__esDecorate(null, null, _start1_decorators, { kind: "field", name: "start1", static: false, private: false, access: { has: obj => "start1" in obj, get: obj => obj.start1, set: (obj, value) => { obj.start1 = value; } }, metadata: _metadata }, _start1_initializers, _start1_extraInitializers);
|
|
693
|
+
__esDecorate(null, null, _end1_decorators, { kind: "field", name: "end1", static: false, private: false, access: { has: obj => "end1" in obj, get: obj => obj.end1, set: (obj, value) => { obj.end1 = value; } }, metadata: _metadata }, _end1_initializers, _end1_extraInitializers);
|
|
694
|
+
__esDecorate(null, null, _start2_decorators, { kind: "field", name: "start2", static: false, private: false, access: { has: obj => "start2" in obj, get: obj => obj.start2, set: (obj, value) => { obj.start2 = value; } }, metadata: _metadata }, _start2_initializers, _start2_extraInitializers);
|
|
695
|
+
__esDecorate(null, null, _end2_decorators, { kind: "field", name: "end2", static: false, private: false, access: { has: obj => "end2" in obj, get: obj => obj.end2, set: (obj, value) => { obj.end2 = value; } }, metadata: _metadata }, _end2_initializers, _end2_extraInitializers);
|
|
696
|
+
__esDecorate(null, null, _width_decorators, { kind: "field", name: "width", static: false, private: false, access: { has: obj => "width" in obj, get: obj => obj.width, set: (obj, value) => { obj.width = value; } }, metadata: _metadata }, _width_initializers, _width_extraInitializers);
|
|
697
|
+
__esDecorate(null, null, _mode_decorators, { kind: "field", name: "mode", static: false, private: false, access: { has: obj => "mode" in obj, get: obj => obj.mode, set: (obj, value) => { obj.mode = value; } }, metadata: _metadata }, _mode_initializers, _mode_extraInitializers);
|
|
698
|
+
if (_metadata) Object.defineProperty(this, Symbol.metadata, { enumerable: true, configurable: true, writable: true, value: _metadata });
|
|
572
699
|
}
|
|
573
|
-
|
|
574
|
-
|
|
575
|
-
|
|
576
|
-
|
|
577
|
-
|
|
578
|
-
|
|
579
|
-
|
|
580
|
-
|
|
581
|
-
|
|
582
|
-
|
|
583
|
-
(
|
|
584
|
-
|
|
585
|
-
|
|
586
|
-
|
|
587
|
-
|
|
588
|
-
this.
|
|
589
|
-
this.
|
|
590
|
-
|
|
700
|
+
id = __runInitializers(this, _id_initializers, void 0);
|
|
701
|
+
hash = (__runInitializers(this, _id_extraInitializers), __runInitializers(this, _hash_initializers, void 0));
|
|
702
|
+
timestamp = (__runInitializers(this, _hash_extraInitializers), __runInitializers(this, _timestamp_initializers, void 0));
|
|
703
|
+
start1 = (__runInitializers(this, _timestamp_extraInitializers), __runInitializers(this, _start1_initializers, void 0));
|
|
704
|
+
end1 = (__runInitializers(this, _start1_extraInitializers), __runInitializers(this, _end1_initializers, void 0));
|
|
705
|
+
start2 = (__runInitializers(this, _end1_extraInitializers), __runInitializers(this, _start2_initializers, void 0));
|
|
706
|
+
end2 = (__runInitializers(this, _start2_extraInitializers), __runInitializers(this, _end2_initializers, void 0));
|
|
707
|
+
width = (__runInitializers(this, _end2_extraInitializers), __runInitializers(this, _width_initializers, void 0));
|
|
708
|
+
mode = (__runInitializers(this, _width_extraInitializers), __runInitializers(this, _mode_initializers, void 0));
|
|
709
|
+
constructor(properties) {
|
|
710
|
+
__runInitializers(this, _mode_extraInitializers);
|
|
711
|
+
this.id = properties.id ?? randomBytes(32);
|
|
712
|
+
this.hash =
|
|
713
|
+
properties.publicKeyHash ||
|
|
714
|
+
properties.publicKey.hashcode();
|
|
715
|
+
this.transform({ width: properties.width, offset: properties.offset });
|
|
716
|
+
this.mode = properties.mode ?? ReplicationIntent.NonStrict;
|
|
717
|
+
this.timestamp = properties.timestamp || BigInt(0);
|
|
591
718
|
}
|
|
592
|
-
|
|
593
|
-
|
|
719
|
+
transform(properties) {
|
|
720
|
+
const ranges = getSegmentsFromOffsetAndRange(properties.offset, properties.width, 0, MAX_U32);
|
|
721
|
+
this.start1 = Math.round(ranges[0][0]);
|
|
722
|
+
this.end1 = Math.round(ranges[0][1]);
|
|
723
|
+
this.start2 = Math.round(ranges[1][0]);
|
|
724
|
+
this.end2 = Math.round(ranges[1][1]);
|
|
725
|
+
this.width =
|
|
726
|
+
this.end1 -
|
|
727
|
+
this.start1 +
|
|
728
|
+
(this.end2 < this.end1 ? this.end2 - this.start2 : 0);
|
|
729
|
+
if (this.start1 > MAX_U32 ||
|
|
730
|
+
this.end1 > MAX_U32 ||
|
|
731
|
+
this.start2 > MAX_U32 ||
|
|
732
|
+
this.end2 > MAX_U32 ||
|
|
733
|
+
this.width > MAX_U32 ||
|
|
734
|
+
this.width < 0) {
|
|
735
|
+
throw new Error("Segment coordinate out of bounds");
|
|
736
|
+
}
|
|
594
737
|
}
|
|
595
|
-
|
|
596
|
-
|
|
597
|
-
toReplicationRange() {
|
|
598
|
-
return new ReplicationRangeMessageU32({
|
|
599
|
-
id: this.id,
|
|
600
|
-
offset: this.start1,
|
|
601
|
-
factor: this.width,
|
|
602
|
-
timestamp: this.timestamp,
|
|
603
|
-
mode: this.mode,
|
|
604
|
-
});
|
|
605
|
-
}
|
|
606
|
-
get wrapped() {
|
|
607
|
-
return this.end2 < this.end1;
|
|
608
|
-
}
|
|
609
|
-
get widthNormalized() {
|
|
610
|
-
return this.width / MAX_U32;
|
|
611
|
-
}
|
|
612
|
-
equals(other) {
|
|
613
|
-
if (equals(this.id, other.id) &&
|
|
614
|
-
this.hash === other.hash &&
|
|
615
|
-
this.timestamp === other.timestamp &&
|
|
616
|
-
this.mode === other.mode &&
|
|
617
|
-
this.start1 === other.start1 &&
|
|
618
|
-
this.end1 === other.end1 &&
|
|
619
|
-
this.start2 === other.start2 &&
|
|
620
|
-
this.end2 === other.end2 &&
|
|
621
|
-
this.width === other.width) {
|
|
622
|
-
return true;
|
|
623
|
-
}
|
|
624
|
-
return false;
|
|
625
|
-
}
|
|
626
|
-
equalRange(other) {
|
|
627
|
-
return (this.hash === other.hash &&
|
|
628
|
-
this.start1 === other.start1 &&
|
|
629
|
-
this.end1 === other.end1 &&
|
|
630
|
-
this.start2 === other.start2 &&
|
|
631
|
-
this.end2 === other.end2);
|
|
632
|
-
}
|
|
633
|
-
toString() {
|
|
634
|
-
let roundToTwoDecimals = (num) => Math.round(num * 100) / 100;
|
|
635
|
-
if (Math.abs(this.start1 - this.start2) < 0.0001) {
|
|
636
|
-
return `([${roundToTwoDecimals(this.start1 / MAX_U32)}, ${roundToTwoDecimals(this.end1 / MAX_U32)}])`;
|
|
738
|
+
get idString() {
|
|
739
|
+
return toBase64(this.id);
|
|
637
740
|
}
|
|
638
|
-
|
|
639
|
-
|
|
640
|
-
|
|
641
|
-
return `(hash ${this.hash} range: ${this.toString()})`;
|
|
642
|
-
}
|
|
643
|
-
toUniqueSegmentId() {
|
|
644
|
-
// return a unique id as a function of the segments location and the replication intent
|
|
645
|
-
const hashable = new HashableSegmentU32(this);
|
|
646
|
-
return sha256Base64Sync(serialize(hashable));
|
|
647
|
-
}
|
|
648
|
-
}
|
|
649
|
-
__decorate([
|
|
650
|
-
id({ type: Uint8Array }),
|
|
651
|
-
__metadata("design:type", Uint8Array)
|
|
652
|
-
], ReplicationRangeIndexableU32.prototype, "id", void 0);
|
|
653
|
-
__decorate([
|
|
654
|
-
field({ type: "string" }),
|
|
655
|
-
__metadata("design:type", String)
|
|
656
|
-
], ReplicationRangeIndexableU32.prototype, "hash", void 0);
|
|
657
|
-
__decorate([
|
|
658
|
-
field({ type: "u64" }),
|
|
659
|
-
__metadata("design:type", BigInt)
|
|
660
|
-
], ReplicationRangeIndexableU32.prototype, "timestamp", void 0);
|
|
661
|
-
__decorate([
|
|
662
|
-
field({ type: "u32" }),
|
|
663
|
-
__metadata("design:type", Number)
|
|
664
|
-
], ReplicationRangeIndexableU32.prototype, "start1", void 0);
|
|
665
|
-
__decorate([
|
|
666
|
-
field({ type: "u32" }),
|
|
667
|
-
__metadata("design:type", Number)
|
|
668
|
-
], ReplicationRangeIndexableU32.prototype, "end1", void 0);
|
|
669
|
-
__decorate([
|
|
670
|
-
field({ type: "u32" }),
|
|
671
|
-
__metadata("design:type", Number)
|
|
672
|
-
], ReplicationRangeIndexableU32.prototype, "start2", void 0);
|
|
673
|
-
__decorate([
|
|
674
|
-
field({ type: "u32" }),
|
|
675
|
-
__metadata("design:type", Number)
|
|
676
|
-
], ReplicationRangeIndexableU32.prototype, "end2", void 0);
|
|
677
|
-
__decorate([
|
|
678
|
-
field({ type: "u32" }),
|
|
679
|
-
__metadata("design:type", Number)
|
|
680
|
-
], ReplicationRangeIndexableU32.prototype, "width", void 0);
|
|
681
|
-
__decorate([
|
|
682
|
-
field({ type: "u8" }),
|
|
683
|
-
__metadata("design:type", Number)
|
|
684
|
-
], ReplicationRangeIndexableU32.prototype, "mode", void 0);
|
|
685
|
-
export class ReplicationRangeIndexableU64 {
|
|
686
|
-
id;
|
|
687
|
-
hash; // publickey hash
|
|
688
|
-
timestamp;
|
|
689
|
-
start1;
|
|
690
|
-
end1;
|
|
691
|
-
start2;
|
|
692
|
-
end2;
|
|
693
|
-
width;
|
|
694
|
-
mode;
|
|
695
|
-
constructor(properties) {
|
|
696
|
-
this.id = properties.id ?? randomBytes(32);
|
|
697
|
-
this.hash =
|
|
698
|
-
properties.publicKeyHash ||
|
|
699
|
-
properties.publicKey.hashcode();
|
|
700
|
-
this.transform({ width: properties.width, offset: properties.offset });
|
|
701
|
-
this.mode = properties.mode ?? ReplicationIntent.NonStrict;
|
|
702
|
-
this.timestamp = properties.timestamp || BigInt(0);
|
|
703
|
-
}
|
|
704
|
-
transform(properties) {
|
|
705
|
-
const ranges = getSegmentsFromOffsetAndRange(BigInt(properties.offset), BigInt(properties.width), 0n, MAX_U64);
|
|
706
|
-
this.start1 = ranges[0][0];
|
|
707
|
-
this.end1 = ranges[0][1];
|
|
708
|
-
this.start2 = ranges[1][0];
|
|
709
|
-
this.end2 = ranges[1][1];
|
|
710
|
-
this.width =
|
|
711
|
-
this.end1 -
|
|
712
|
-
this.start1 +
|
|
713
|
-
(this.end2 < this.end1 ? this.end2 - this.start2 : 0n);
|
|
714
|
-
if (this.start1 > MAX_U64 ||
|
|
715
|
-
this.end1 > MAX_U64 ||
|
|
716
|
-
this.start2 > MAX_U64 ||
|
|
717
|
-
this.end2 > MAX_U64 ||
|
|
718
|
-
this.width > MAX_U64 ||
|
|
719
|
-
this.width < 0n) {
|
|
720
|
-
throw new Error("Segment coordinate out of bounds");
|
|
741
|
+
get rangeHash() {
|
|
742
|
+
const ser = serialize(this);
|
|
743
|
+
return sha256Base64Sync(ser);
|
|
721
744
|
}
|
|
722
|
-
|
|
723
|
-
|
|
724
|
-
|
|
725
|
-
}
|
|
726
|
-
contains(point) {
|
|
727
|
-
return ((point >= this.start1 && point < this.end1) ||
|
|
728
|
-
(point >= this.start2 && point < this.end2));
|
|
729
|
-
}
|
|
730
|
-
get rangeHash() {
|
|
731
|
-
const ser = serialize(this);
|
|
732
|
-
return sha256Base64Sync(ser);
|
|
733
|
-
}
|
|
734
|
-
overlaps(other, checkOther = true) {
|
|
735
|
-
if (this.contains(other.start1) ||
|
|
736
|
-
this.contains(other.start2) ||
|
|
737
|
-
this.contains(other.end1 - 1n) ||
|
|
738
|
-
this.contains(other.end2 - 1n)) {
|
|
739
|
-
return true;
|
|
745
|
+
contains(point) {
|
|
746
|
+
return ((point >= this.start1 && point < this.end1) ||
|
|
747
|
+
(point >= this.start2 && point < this.end2));
|
|
740
748
|
}
|
|
741
|
-
|
|
742
|
-
|
|
749
|
+
overlaps(other, checkOther = true) {
|
|
750
|
+
if (this.contains(other.start1) ||
|
|
751
|
+
this.contains(other.start2) ||
|
|
752
|
+
this.contains(other.end1 - 1) ||
|
|
753
|
+
this.contains(other.end2 - 1)) {
|
|
754
|
+
return true;
|
|
755
|
+
}
|
|
756
|
+
if (checkOther) {
|
|
757
|
+
return other.overlaps(this, false);
|
|
758
|
+
}
|
|
759
|
+
return false;
|
|
743
760
|
}
|
|
744
|
-
|
|
745
|
-
|
|
746
|
-
|
|
747
|
-
|
|
748
|
-
|
|
749
|
-
|
|
750
|
-
|
|
751
|
-
|
|
752
|
-
mode: this.mode,
|
|
753
|
-
});
|
|
754
|
-
}
|
|
755
|
-
get wrapped() {
|
|
756
|
-
return this.end2 < this.end1;
|
|
757
|
-
}
|
|
758
|
-
get widthNormalized() {
|
|
759
|
-
return Number(this.width) / Number(MAX_U64);
|
|
760
|
-
}
|
|
761
|
-
equals(other) {
|
|
762
|
-
if (equals(this.id, other.id) &&
|
|
763
|
-
this.hash === other.hash &&
|
|
764
|
-
this.timestamp === other.timestamp &&
|
|
765
|
-
this.mode === other.mode &&
|
|
766
|
-
this.start1 === other.start1 &&
|
|
767
|
-
this.end1 === other.end1 &&
|
|
768
|
-
this.start2 === other.start2 &&
|
|
769
|
-
this.end2 === other.end2 &&
|
|
770
|
-
this.width === other.width) {
|
|
771
|
-
return true;
|
|
772
|
-
}
|
|
773
|
-
return false;
|
|
774
|
-
}
|
|
775
|
-
equalRange(other) {
|
|
776
|
-
return (this.hash === other.hash &&
|
|
777
|
-
this.start1 === other.start1 &&
|
|
778
|
-
this.end1 === other.end1 &&
|
|
779
|
-
this.start2 === other.start2 &&
|
|
780
|
-
this.end2 === other.end2);
|
|
781
|
-
}
|
|
782
|
-
toString() {
|
|
783
|
-
let roundToTwoDecimals = (num) => Math.round(num * 100) / 100;
|
|
784
|
-
if (Math.abs(Number(this.start1 - this.start2)) < 0.0001) {
|
|
785
|
-
return `([${roundToTwoDecimals(Number(this.start1) / Number(MAX_U64))}, ${roundToTwoDecimals(Number(this.start1) / Number(MAX_U64))}])`;
|
|
761
|
+
toReplicationRange() {
|
|
762
|
+
return new ReplicationRangeMessageU32({
|
|
763
|
+
id: this.id,
|
|
764
|
+
offset: this.start1,
|
|
765
|
+
factor: this.width,
|
|
766
|
+
timestamp: this.timestamp,
|
|
767
|
+
mode: this.mode,
|
|
768
|
+
});
|
|
786
769
|
}
|
|
787
|
-
|
|
788
|
-
|
|
789
|
-
|
|
790
|
-
|
|
791
|
-
|
|
792
|
-
|
|
793
|
-
|
|
794
|
-
|
|
795
|
-
|
|
796
|
-
|
|
797
|
-
|
|
798
|
-
|
|
799
|
-
|
|
800
|
-
|
|
801
|
-
|
|
802
|
-
|
|
803
|
-
|
|
804
|
-
|
|
805
|
-
|
|
806
|
-
|
|
807
|
-
|
|
808
|
-
|
|
809
|
-
|
|
810
|
-
|
|
811
|
-
|
|
812
|
-
|
|
813
|
-
|
|
814
|
-
|
|
815
|
-
|
|
816
|
-
|
|
817
|
-
|
|
818
|
-
|
|
819
|
-
|
|
820
|
-
|
|
821
|
-
|
|
822
|
-
|
|
823
|
-
|
|
824
|
-
|
|
825
|
-
|
|
826
|
-
|
|
827
|
-
|
|
828
|
-
|
|
829
|
-
|
|
830
|
-
|
|
831
|
-
|
|
832
|
-
|
|
833
|
-
|
|
770
|
+
get wrapped() {
|
|
771
|
+
return this.end2 < this.end1;
|
|
772
|
+
}
|
|
773
|
+
get widthNormalized() {
|
|
774
|
+
return this.width / MAX_U32;
|
|
775
|
+
}
|
|
776
|
+
equals(other) {
|
|
777
|
+
if (equals(this.id, other.id) &&
|
|
778
|
+
this.hash === other.hash &&
|
|
779
|
+
this.timestamp === other.timestamp &&
|
|
780
|
+
this.mode === other.mode &&
|
|
781
|
+
this.start1 === other.start1 &&
|
|
782
|
+
this.end1 === other.end1 &&
|
|
783
|
+
this.start2 === other.start2 &&
|
|
784
|
+
this.end2 === other.end2 &&
|
|
785
|
+
this.width === other.width) {
|
|
786
|
+
return true;
|
|
787
|
+
}
|
|
788
|
+
return false;
|
|
789
|
+
}
|
|
790
|
+
equalRange(other) {
|
|
791
|
+
return (this.hash === other.hash &&
|
|
792
|
+
this.start1 === other.start1 &&
|
|
793
|
+
this.end1 === other.end1 &&
|
|
794
|
+
this.start2 === other.start2 &&
|
|
795
|
+
this.end2 === other.end2);
|
|
796
|
+
}
|
|
797
|
+
toString() {
|
|
798
|
+
let roundToTwoDecimals = (num) => Math.round(num * 100) / 100;
|
|
799
|
+
if (Math.abs(this.start1 - this.start2) < 0.0001) {
|
|
800
|
+
return `([${roundToTwoDecimals(this.start1 / MAX_U32)}, ${roundToTwoDecimals(this.end1 / MAX_U32)}])`;
|
|
801
|
+
}
|
|
802
|
+
return `([${roundToTwoDecimals(this.start1 / MAX_U32)}, ${roundToTwoDecimals(this.end1 / MAX_U32)}] [${roundToTwoDecimals(this.start2 / MAX_U32)}, ${roundToTwoDecimals(this.end2 / MAX_U32)}])`;
|
|
803
|
+
}
|
|
804
|
+
toStringDetailed() {
|
|
805
|
+
return `(hash ${this.hash} range: ${this.toString()})`;
|
|
806
|
+
}
|
|
807
|
+
toUniqueSegmentId() {
|
|
808
|
+
// return a unique id as a function of the segments location and the replication intent
|
|
809
|
+
const hashable = new HashableSegmentU32(this);
|
|
810
|
+
return sha256Base64Sync(serialize(hashable));
|
|
811
|
+
}
|
|
812
|
+
};
|
|
813
|
+
})();
|
|
814
|
+
export { ReplicationRangeIndexableU32 };
|
|
815
|
+
let ReplicationRangeIndexableU64 = (() => {
|
|
816
|
+
let _id_decorators;
|
|
817
|
+
let _id_initializers = [];
|
|
818
|
+
let _id_extraInitializers = [];
|
|
819
|
+
let _hash_decorators;
|
|
820
|
+
let _hash_initializers = [];
|
|
821
|
+
let _hash_extraInitializers = [];
|
|
822
|
+
let _timestamp_decorators;
|
|
823
|
+
let _timestamp_initializers = [];
|
|
824
|
+
let _timestamp_extraInitializers = [];
|
|
825
|
+
let _start1_decorators;
|
|
826
|
+
let _start1_initializers = [];
|
|
827
|
+
let _start1_extraInitializers = [];
|
|
828
|
+
let _end1_decorators;
|
|
829
|
+
let _end1_initializers = [];
|
|
830
|
+
let _end1_extraInitializers = [];
|
|
831
|
+
let _start2_decorators;
|
|
832
|
+
let _start2_initializers = [];
|
|
833
|
+
let _start2_extraInitializers = [];
|
|
834
|
+
let _end2_decorators;
|
|
835
|
+
let _end2_initializers = [];
|
|
836
|
+
let _end2_extraInitializers = [];
|
|
837
|
+
let _width_decorators;
|
|
838
|
+
let _width_initializers = [];
|
|
839
|
+
let _width_extraInitializers = [];
|
|
840
|
+
let _mode_decorators;
|
|
841
|
+
let _mode_initializers = [];
|
|
842
|
+
let _mode_extraInitializers = [];
|
|
843
|
+
return class ReplicationRangeIndexableU64 {
|
|
844
|
+
static {
|
|
845
|
+
const _metadata = typeof Symbol === "function" && Symbol.metadata ? Object.create(null) : void 0;
|
|
846
|
+
_id_decorators = [id({ type: Uint8Array })];
|
|
847
|
+
_hash_decorators = [field({ type: "string" })];
|
|
848
|
+
_timestamp_decorators = [field({ type: "u64" })];
|
|
849
|
+
_start1_decorators = [field({ type: "u64" })];
|
|
850
|
+
_end1_decorators = [field({ type: "u64" })];
|
|
851
|
+
_start2_decorators = [field({ type: "u64" })];
|
|
852
|
+
_end2_decorators = [field({ type: "u64" })];
|
|
853
|
+
_width_decorators = [field({ type: "u64" })];
|
|
854
|
+
_mode_decorators = [field({ type: "u8" })];
|
|
855
|
+
__esDecorate(null, null, _id_decorators, { kind: "field", name: "id", static: false, private: false, access: { has: obj => "id" in obj, get: obj => obj.id, set: (obj, value) => { obj.id = value; } }, metadata: _metadata }, _id_initializers, _id_extraInitializers);
|
|
856
|
+
__esDecorate(null, null, _hash_decorators, { kind: "field", name: "hash", static: false, private: false, access: { has: obj => "hash" in obj, get: obj => obj.hash, set: (obj, value) => { obj.hash = value; } }, metadata: _metadata }, _hash_initializers, _hash_extraInitializers);
|
|
857
|
+
__esDecorate(null, null, _timestamp_decorators, { kind: "field", name: "timestamp", static: false, private: false, access: { has: obj => "timestamp" in obj, get: obj => obj.timestamp, set: (obj, value) => { obj.timestamp = value; } }, metadata: _metadata }, _timestamp_initializers, _timestamp_extraInitializers);
|
|
858
|
+
__esDecorate(null, null, _start1_decorators, { kind: "field", name: "start1", static: false, private: false, access: { has: obj => "start1" in obj, get: obj => obj.start1, set: (obj, value) => { obj.start1 = value; } }, metadata: _metadata }, _start1_initializers, _start1_extraInitializers);
|
|
859
|
+
__esDecorate(null, null, _end1_decorators, { kind: "field", name: "end1", static: false, private: false, access: { has: obj => "end1" in obj, get: obj => obj.end1, set: (obj, value) => { obj.end1 = value; } }, metadata: _metadata }, _end1_initializers, _end1_extraInitializers);
|
|
860
|
+
__esDecorate(null, null, _start2_decorators, { kind: "field", name: "start2", static: false, private: false, access: { has: obj => "start2" in obj, get: obj => obj.start2, set: (obj, value) => { obj.start2 = value; } }, metadata: _metadata }, _start2_initializers, _start2_extraInitializers);
|
|
861
|
+
__esDecorate(null, null, _end2_decorators, { kind: "field", name: "end2", static: false, private: false, access: { has: obj => "end2" in obj, get: obj => obj.end2, set: (obj, value) => { obj.end2 = value; } }, metadata: _metadata }, _end2_initializers, _end2_extraInitializers);
|
|
862
|
+
__esDecorate(null, null, _width_decorators, { kind: "field", name: "width", static: false, private: false, access: { has: obj => "width" in obj, get: obj => obj.width, set: (obj, value) => { obj.width = value; } }, metadata: _metadata }, _width_initializers, _width_extraInitializers);
|
|
863
|
+
__esDecorate(null, null, _mode_decorators, { kind: "field", name: "mode", static: false, private: false, access: { has: obj => "mode" in obj, get: obj => obj.mode, set: (obj, value) => { obj.mode = value; } }, metadata: _metadata }, _mode_initializers, _mode_extraInitializers);
|
|
864
|
+
if (_metadata) Object.defineProperty(this, Symbol.metadata, { enumerable: true, configurable: true, writable: true, value: _metadata });
|
|
865
|
+
}
|
|
866
|
+
id = __runInitializers(this, _id_initializers, void 0);
|
|
867
|
+
hash = (__runInitializers(this, _id_extraInitializers), __runInitializers(this, _hash_initializers, void 0)); // publickey hash
|
|
868
|
+
timestamp = (__runInitializers(this, _hash_extraInitializers), __runInitializers(this, _timestamp_initializers, void 0));
|
|
869
|
+
start1 = (__runInitializers(this, _timestamp_extraInitializers), __runInitializers(this, _start1_initializers, void 0));
|
|
870
|
+
end1 = (__runInitializers(this, _start1_extraInitializers), __runInitializers(this, _end1_initializers, void 0));
|
|
871
|
+
start2 = (__runInitializers(this, _end1_extraInitializers), __runInitializers(this, _start2_initializers, void 0));
|
|
872
|
+
end2 = (__runInitializers(this, _start2_extraInitializers), __runInitializers(this, _end2_initializers, void 0));
|
|
873
|
+
width = (__runInitializers(this, _end2_extraInitializers), __runInitializers(this, _width_initializers, void 0));
|
|
874
|
+
mode = (__runInitializers(this, _width_extraInitializers), __runInitializers(this, _mode_initializers, void 0));
|
|
875
|
+
constructor(properties) {
|
|
876
|
+
__runInitializers(this, _mode_extraInitializers);
|
|
877
|
+
this.id = properties.id ?? randomBytes(32);
|
|
878
|
+
this.hash =
|
|
879
|
+
properties.publicKeyHash ||
|
|
880
|
+
properties.publicKey.hashcode();
|
|
881
|
+
this.transform({ width: properties.width, offset: properties.offset });
|
|
882
|
+
this.mode = properties.mode ?? ReplicationIntent.NonStrict;
|
|
883
|
+
this.timestamp = properties.timestamp || BigInt(0);
|
|
884
|
+
}
|
|
885
|
+
transform(properties) {
|
|
886
|
+
const ranges = getSegmentsFromOffsetAndRange(BigInt(properties.offset), BigInt(properties.width), 0n, MAX_U64);
|
|
887
|
+
this.start1 = ranges[0][0];
|
|
888
|
+
this.end1 = ranges[0][1];
|
|
889
|
+
this.start2 = ranges[1][0];
|
|
890
|
+
this.end2 = ranges[1][1];
|
|
891
|
+
this.width =
|
|
892
|
+
this.end1 -
|
|
893
|
+
this.start1 +
|
|
894
|
+
(this.end2 < this.end1 ? this.end2 - this.start2 : 0n);
|
|
895
|
+
if (this.start1 > MAX_U64 ||
|
|
896
|
+
this.end1 > MAX_U64 ||
|
|
897
|
+
this.start2 > MAX_U64 ||
|
|
898
|
+
this.end2 > MAX_U64 ||
|
|
899
|
+
this.width > MAX_U64 ||
|
|
900
|
+
this.width < 0n) {
|
|
901
|
+
throw new Error("Segment coordinate out of bounds");
|
|
902
|
+
}
|
|
903
|
+
}
|
|
904
|
+
get idString() {
|
|
905
|
+
return toBase64(this.id);
|
|
906
|
+
}
|
|
907
|
+
contains(point) {
|
|
908
|
+
return ((point >= this.start1 && point < this.end1) ||
|
|
909
|
+
(point >= this.start2 && point < this.end2));
|
|
910
|
+
}
|
|
911
|
+
get rangeHash() {
|
|
912
|
+
const ser = serialize(this);
|
|
913
|
+
return sha256Base64Sync(ser);
|
|
914
|
+
}
|
|
915
|
+
overlaps(other, checkOther = true) {
|
|
916
|
+
if (this.contains(other.start1) ||
|
|
917
|
+
this.contains(other.start2) ||
|
|
918
|
+
this.contains(other.end1 - 1n) ||
|
|
919
|
+
this.contains(other.end2 - 1n)) {
|
|
920
|
+
return true;
|
|
921
|
+
}
|
|
922
|
+
if (checkOther) {
|
|
923
|
+
return other.overlaps(this, false);
|
|
924
|
+
}
|
|
925
|
+
return false;
|
|
926
|
+
}
|
|
927
|
+
toReplicationRange() {
|
|
928
|
+
return new ReplicationRangeMessageU64({
|
|
929
|
+
id: this.id,
|
|
930
|
+
offset: this.start1,
|
|
931
|
+
factor: this.width,
|
|
932
|
+
timestamp: this.timestamp,
|
|
933
|
+
mode: this.mode,
|
|
934
|
+
});
|
|
935
|
+
}
|
|
936
|
+
get wrapped() {
|
|
937
|
+
return this.end2 < this.end1;
|
|
938
|
+
}
|
|
939
|
+
get widthNormalized() {
|
|
940
|
+
return Number(this.width) / Number(MAX_U64);
|
|
941
|
+
}
|
|
942
|
+
equals(other) {
|
|
943
|
+
if (equals(this.id, other.id) &&
|
|
944
|
+
this.hash === other.hash &&
|
|
945
|
+
this.timestamp === other.timestamp &&
|
|
946
|
+
this.mode === other.mode &&
|
|
947
|
+
this.start1 === other.start1 &&
|
|
948
|
+
this.end1 === other.end1 &&
|
|
949
|
+
this.start2 === other.start2 &&
|
|
950
|
+
this.end2 === other.end2 &&
|
|
951
|
+
this.width === other.width) {
|
|
952
|
+
return true;
|
|
953
|
+
}
|
|
954
|
+
return false;
|
|
955
|
+
}
|
|
956
|
+
equalRange(other) {
|
|
957
|
+
return (this.hash === other.hash &&
|
|
958
|
+
this.start1 === other.start1 &&
|
|
959
|
+
this.end1 === other.end1 &&
|
|
960
|
+
this.start2 === other.start2 &&
|
|
961
|
+
this.end2 === other.end2);
|
|
962
|
+
}
|
|
963
|
+
toString() {
|
|
964
|
+
let roundToTwoDecimals = (num) => Math.round(num * 100) / 100;
|
|
965
|
+
if (Math.abs(Number(this.start1 - this.start2)) < 0.0001) {
|
|
966
|
+
return `([${roundToTwoDecimals(Number(this.start1) / Number(MAX_U64))}, ${roundToTwoDecimals(Number(this.start1) / Number(MAX_U64))}])`;
|
|
967
|
+
}
|
|
968
|
+
return `([${roundToTwoDecimals(Number(this.start1) / Number(MAX_U64))}, ${roundToTwoDecimals(Number(this.start1) / Number(MAX_U64))}] [${roundToTwoDecimals(Number(this.start2) / Number(MAX_U64))}, ${roundToTwoDecimals(Number(this.end2) / Number(MAX_U64))}])`;
|
|
969
|
+
}
|
|
970
|
+
toStringDetailed() {
|
|
971
|
+
return `(hash ${this.hash} range: ${this.toString()})`;
|
|
972
|
+
}
|
|
973
|
+
toUniqueSegmentId() {
|
|
974
|
+
// return a unique id as a function of the segments location and the replication intent
|
|
975
|
+
const hashable = new HashableSegmentU64(this);
|
|
976
|
+
return sha256Base64Sync(serialize(hashable));
|
|
977
|
+
}
|
|
978
|
+
};
|
|
979
|
+
})();
|
|
980
|
+
export { ReplicationRangeIndexableU64 };
|
|
834
981
|
export const mergeRanges = (segments, numbers) => {
|
|
835
982
|
if (segments.length === 0) {
|
|
836
983
|
throw new Error("No segments to merge");
|