@omnibuf/node 0.0.3 → 0.0.4
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.
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
// Code generated by protoc-gen-omnibuf-es. DO NOT EDIT.
|
|
2
2
|
// source: peer.proto
|
|
3
|
-
|
|
3
|
+
/* eslint-disable @typescript-eslint/no-unused-vars */
|
|
4
|
+
import { Encoder, MaxNestingDepth, appendStringArrBody, appendUint32ArrBody, countSubMsgArrElems, decodeSchemaMeta, decodeUTF8, decodeVarintBigInt, decodeZigZag, defineMessage, encodeField0SchemaMeta, float32FromBits, parseArrayHeader, readBool, readFloat32, readFloat64, readFloat64At, readInt, readLenSlice, readString, readStringArr, readSubMsgArrDecoded, readSubMsgMerged, readUint, readUint32Arr, readUintAuto, roundFloat32Shortest, spliceFields, validateValue, writeField0SchemaMeta, } from '@omnibuf/core';
|
|
4
5
|
export const LocationSchema = defineMessage('omnibuf.bench.Location', {
|
|
5
6
|
region: { fieldNum: 1, type: 'string' },
|
|
6
7
|
datacenter: { fieldNum: 2, type: 'string' },
|
|
@@ -32,7 +33,7 @@ export function encodeLocation(enc, msg, options) {
|
|
|
32
33
|
enc.writeString(1, msg.region ?? '');
|
|
33
34
|
enc.writeString(2, msg.datacenter ?? '');
|
|
34
35
|
enc.writeString(3, msg.city ?? '');
|
|
35
|
-
enc.writeUint(4, msg.rack ?? 0);
|
|
36
|
+
enc.writeUint(4, Number(msg.rack ?? 0) >>> 0);
|
|
36
37
|
enc.writeFloat32(5, msg.latitude ?? 0);
|
|
37
38
|
enc.writeFloat32(6, msg.longitude ?? 0);
|
|
38
39
|
if (options?.writeUnknownFields && Array.isArray(msg.$unknown)) {
|
|
@@ -59,6 +60,7 @@ export function decodeLocation(buf, target, depth = 0, options, startPos = 0, en
|
|
|
59
60
|
const out = target ?? new LocationMsg();
|
|
60
61
|
const n = endPos;
|
|
61
62
|
let pos = startPos;
|
|
63
|
+
let seenMask = 0;
|
|
62
64
|
let unknownFields = Array.isArray(out.$unknown)
|
|
63
65
|
? out.$unknown
|
|
64
66
|
: null;
|
|
@@ -76,8 +78,8 @@ export function decodeLocation(buf, target, depth = 0, options, startPos = 0, en
|
|
|
76
78
|
pos += 2;
|
|
77
79
|
}
|
|
78
80
|
else {
|
|
79
|
-
const [t64, tn] = decodeVarintBigInt(buf, pos);
|
|
80
|
-
if (tn === 0 ||
|
|
81
|
+
const [t64, tn] = decodeVarintBigInt(buf, pos, n);
|
|
82
|
+
if (tn === 0 || t64 >> 4n > 536870911n)
|
|
81
83
|
throw new Error('omnibuf: invalid tag');
|
|
82
84
|
tag = Number(t64);
|
|
83
85
|
pos += tn;
|
|
@@ -85,18 +87,20 @@ export function decodeLocation(buf, target, depth = 0, options, startPos = 0, en
|
|
|
85
87
|
const fieldNum = tag <= 0x7fffffff ? tag >>> 4 : Math.floor(tag / 16);
|
|
86
88
|
const wt = tag & 0x0f;
|
|
87
89
|
if (fieldNum === 0) {
|
|
88
|
-
if (wt !==
|
|
90
|
+
if (wt !== 12)
|
|
89
91
|
throw new Error('omnibuf: invalid Field #0 wire type');
|
|
90
|
-
const [meta, nextPos] = readLenSlice(buf
|
|
92
|
+
const [meta, nextPos] = readLenSlice(buf, pos, 0, n);
|
|
91
93
|
decodeSchemaMeta(meta, depth + 1, maxDepth);
|
|
92
94
|
pos = nextPos;
|
|
93
95
|
continue;
|
|
94
96
|
}
|
|
97
|
+
const bit = fieldNum <= 30 ? 1 << fieldNum : 0;
|
|
98
|
+
const alreadySeen = (seenMask & bit) !== 0 || Boolean(options?.merge);
|
|
95
99
|
switch (fieldNum) {
|
|
96
100
|
case 1: {
|
|
97
|
-
if (wt
|
|
101
|
+
if (!(wt === 10)) {
|
|
98
102
|
const valStart = pos;
|
|
99
|
-
pos = validateValue(buf.subarray(0, n), pos, wt, depth, maxDepth);
|
|
103
|
+
pos = validateValue(n < buf.length ? buf.subarray(0, n) : buf, pos, wt, depth, maxDepth);
|
|
100
104
|
if (readUnknown) {
|
|
101
105
|
if (!unknownFields)
|
|
102
106
|
unknownFields = [];
|
|
@@ -108,6 +112,7 @@ export function decodeLocation(buf, target, depth = 0, options, startPos = 0, en
|
|
|
108
112
|
}
|
|
109
113
|
break;
|
|
110
114
|
}
|
|
115
|
+
seenMask |= bit;
|
|
111
116
|
if (pos >= n)
|
|
112
117
|
throw new Error('omnibuf: truncated string');
|
|
113
118
|
const sb = buf[pos];
|
|
@@ -120,16 +125,16 @@ export function decodeLocation(buf, target, depth = 0, options, startPos = 0, en
|
|
|
120
125
|
pos += sLen;
|
|
121
126
|
}
|
|
122
127
|
else {
|
|
123
|
-
const [s, nextPos] = readLenSlice(buf
|
|
128
|
+
const [s, nextPos] = readLenSlice(buf, pos, 0, n);
|
|
124
129
|
out.region = decodeUTF8(s);
|
|
125
130
|
pos = nextPos;
|
|
126
131
|
}
|
|
127
132
|
break;
|
|
128
133
|
}
|
|
129
134
|
case 2: {
|
|
130
|
-
if (wt
|
|
135
|
+
if (!(wt === 10)) {
|
|
131
136
|
const valStart = pos;
|
|
132
|
-
pos = validateValue(buf.subarray(0, n), pos, wt, depth, maxDepth);
|
|
137
|
+
pos = validateValue(n < buf.length ? buf.subarray(0, n) : buf, pos, wt, depth, maxDepth);
|
|
133
138
|
if (readUnknown) {
|
|
134
139
|
if (!unknownFields)
|
|
135
140
|
unknownFields = [];
|
|
@@ -141,6 +146,7 @@ export function decodeLocation(buf, target, depth = 0, options, startPos = 0, en
|
|
|
141
146
|
}
|
|
142
147
|
break;
|
|
143
148
|
}
|
|
149
|
+
seenMask |= bit;
|
|
144
150
|
if (pos >= n)
|
|
145
151
|
throw new Error('omnibuf: truncated string');
|
|
146
152
|
const sb = buf[pos];
|
|
@@ -153,16 +159,16 @@ export function decodeLocation(buf, target, depth = 0, options, startPos = 0, en
|
|
|
153
159
|
pos += sLen;
|
|
154
160
|
}
|
|
155
161
|
else {
|
|
156
|
-
const [s, nextPos] = readLenSlice(buf
|
|
162
|
+
const [s, nextPos] = readLenSlice(buf, pos, 0, n);
|
|
157
163
|
out.datacenter = decodeUTF8(s);
|
|
158
164
|
pos = nextPos;
|
|
159
165
|
}
|
|
160
166
|
break;
|
|
161
167
|
}
|
|
162
168
|
case 3: {
|
|
163
|
-
if (wt
|
|
169
|
+
if (!(wt === 10)) {
|
|
164
170
|
const valStart = pos;
|
|
165
|
-
pos = validateValue(buf.subarray(0, n), pos, wt, depth, maxDepth);
|
|
171
|
+
pos = validateValue(n < buf.length ? buf.subarray(0, n) : buf, pos, wt, depth, maxDepth);
|
|
166
172
|
if (readUnknown) {
|
|
167
173
|
if (!unknownFields)
|
|
168
174
|
unknownFields = [];
|
|
@@ -174,6 +180,7 @@ export function decodeLocation(buf, target, depth = 0, options, startPos = 0, en
|
|
|
174
180
|
}
|
|
175
181
|
break;
|
|
176
182
|
}
|
|
183
|
+
seenMask |= bit;
|
|
177
184
|
if (pos >= n)
|
|
178
185
|
throw new Error('omnibuf: truncated string');
|
|
179
186
|
const sb = buf[pos];
|
|
@@ -186,16 +193,16 @@ export function decodeLocation(buf, target, depth = 0, options, startPos = 0, en
|
|
|
186
193
|
pos += sLen;
|
|
187
194
|
}
|
|
188
195
|
else {
|
|
189
|
-
const [s, nextPos] = readLenSlice(buf
|
|
196
|
+
const [s, nextPos] = readLenSlice(buf, pos, 0, n);
|
|
190
197
|
out.city = decodeUTF8(s);
|
|
191
198
|
pos = nextPos;
|
|
192
199
|
}
|
|
193
200
|
break;
|
|
194
201
|
}
|
|
195
202
|
case 4: {
|
|
196
|
-
if (wt
|
|
203
|
+
if (!(wt === 0)) {
|
|
197
204
|
const valStart = pos;
|
|
198
|
-
pos = validateValue(buf.subarray(0, n), pos, wt, depth, maxDepth);
|
|
205
|
+
pos = validateValue(n < buf.length ? buf.subarray(0, n) : buf, pos, wt, depth, maxDepth);
|
|
199
206
|
if (readUnknown) {
|
|
200
207
|
if (!unknownFields)
|
|
201
208
|
unknownFields = [];
|
|
@@ -207,30 +214,33 @@ export function decodeLocation(buf, target, depth = 0, options, startPos = 0, en
|
|
|
207
214
|
}
|
|
208
215
|
break;
|
|
209
216
|
}
|
|
217
|
+
seenMask |= bit;
|
|
210
218
|
if (pos >= n)
|
|
211
219
|
throw new Error('omnibuf: truncated uint32');
|
|
212
220
|
const vb = buf[pos];
|
|
221
|
+
let u32Val = 0;
|
|
213
222
|
if ((vb & 1) !== 0) {
|
|
214
|
-
|
|
223
|
+
u32Val = vb >>> 1;
|
|
215
224
|
pos += 1;
|
|
216
225
|
}
|
|
217
226
|
else if ((vb & 2) !== 0) {
|
|
218
227
|
if (pos + 2 > n)
|
|
219
228
|
throw new Error('omnibuf: truncated uint32');
|
|
220
|
-
|
|
229
|
+
u32Val = (vb | (buf[pos + 1] << 8)) >>> 2;
|
|
221
230
|
pos += 2;
|
|
222
231
|
}
|
|
223
232
|
else if ((vb & 4) !== 0) {
|
|
224
233
|
if (pos + 4 > n)
|
|
225
234
|
throw new Error('omnibuf: truncated uint32');
|
|
226
|
-
|
|
227
|
-
|
|
235
|
+
u32Val =
|
|
236
|
+
((vb | (buf[pos + 1] << 8) | (buf[pos + 2] << 16) | (buf[pos + 3] << 24)) >>> 3) >>>
|
|
237
|
+
0;
|
|
228
238
|
pos += 4;
|
|
229
239
|
}
|
|
230
240
|
else {
|
|
231
|
-
if (pos + 9 > n)
|
|
241
|
+
if (vb !== 0 || pos + 9 > n)
|
|
232
242
|
throw new Error('omnibuf: truncated uint32');
|
|
233
|
-
|
|
243
|
+
u32Val =
|
|
234
244
|
(buf[pos + 1] |
|
|
235
245
|
(buf[pos + 2] << 8) |
|
|
236
246
|
(buf[pos + 3] << 16) |
|
|
@@ -238,12 +248,13 @@ export function decodeLocation(buf, target, depth = 0, options, startPos = 0, en
|
|
|
238
248
|
0;
|
|
239
249
|
pos += 9;
|
|
240
250
|
}
|
|
251
|
+
out.rack = u32Val;
|
|
241
252
|
break;
|
|
242
253
|
}
|
|
243
254
|
case 5: {
|
|
244
|
-
if (wt
|
|
255
|
+
if (!(wt === 8)) {
|
|
245
256
|
const valStart = pos;
|
|
246
|
-
pos = validateValue(buf.subarray(0, n), pos, wt, depth, maxDepth);
|
|
257
|
+
pos = validateValue(n < buf.length ? buf.subarray(0, n) : buf, pos, wt, depth, maxDepth);
|
|
247
258
|
if (readUnknown) {
|
|
248
259
|
if (!unknownFields)
|
|
249
260
|
unknownFields = [];
|
|
@@ -255,6 +266,7 @@ export function decodeLocation(buf, target, depth = 0, options, startPos = 0, en
|
|
|
255
266
|
}
|
|
256
267
|
break;
|
|
257
268
|
}
|
|
269
|
+
seenMask |= bit;
|
|
258
270
|
if (n - pos < 4)
|
|
259
271
|
throw new Error('omnibuf: truncated float32');
|
|
260
272
|
const bits = (buf[pos] | (buf[pos + 1] << 8) | (buf[pos + 2] << 16) | (buf[pos + 3] << 24)) >>> 0;
|
|
@@ -263,9 +275,9 @@ export function decodeLocation(buf, target, depth = 0, options, startPos = 0, en
|
|
|
263
275
|
break;
|
|
264
276
|
}
|
|
265
277
|
case 6: {
|
|
266
|
-
if (wt
|
|
278
|
+
if (!(wt === 8)) {
|
|
267
279
|
const valStart = pos;
|
|
268
|
-
pos = validateValue(buf.subarray(0, n), pos, wt, depth, maxDepth);
|
|
280
|
+
pos = validateValue(n < buf.length ? buf.subarray(0, n) : buf, pos, wt, depth, maxDepth);
|
|
269
281
|
if (readUnknown) {
|
|
270
282
|
if (!unknownFields)
|
|
271
283
|
unknownFields = [];
|
|
@@ -277,6 +289,7 @@ export function decodeLocation(buf, target, depth = 0, options, startPos = 0, en
|
|
|
277
289
|
}
|
|
278
290
|
break;
|
|
279
291
|
}
|
|
292
|
+
seenMask |= bit;
|
|
280
293
|
if (n - pos < 4)
|
|
281
294
|
throw new Error('omnibuf: truncated float32');
|
|
282
295
|
const bits = (buf[pos] | (buf[pos + 1] << 8) | (buf[pos + 2] << 16) | (buf[pos + 3] << 24)) >>> 0;
|
|
@@ -286,7 +299,7 @@ export function decodeLocation(buf, target, depth = 0, options, startPos = 0, en
|
|
|
286
299
|
}
|
|
287
300
|
default: {
|
|
288
301
|
const valStart = pos;
|
|
289
|
-
pos = validateValue(buf.subarray(0, n), pos, wt, depth, maxDepth);
|
|
302
|
+
pos = validateValue(n < buf.length ? buf.subarray(0, n) : buf, pos, wt, depth, maxDepth);
|
|
290
303
|
if (readUnknown) {
|
|
291
304
|
if (!unknownFields)
|
|
292
305
|
unknownFields = [];
|
|
@@ -318,6 +331,147 @@ LocationSchema.setGeneratedCodec({
|
|
|
318
331
|
encode: encodeLocation,
|
|
319
332
|
decode: decodeLocation,
|
|
320
333
|
});
|
|
334
|
+
export class OpaqueLocation {
|
|
335
|
+
_raw;
|
|
336
|
+
_dirtyMask = 0;
|
|
337
|
+
_region;
|
|
338
|
+
_datacenter;
|
|
339
|
+
_city;
|
|
340
|
+
_rack;
|
|
341
|
+
_latitude;
|
|
342
|
+
_longitude;
|
|
343
|
+
constructor(raw) {
|
|
344
|
+
this._raw = raw;
|
|
345
|
+
}
|
|
346
|
+
raw() {
|
|
347
|
+
return this._raw;
|
|
348
|
+
}
|
|
349
|
+
getRegion() {
|
|
350
|
+
if ((this._dirtyMask & (1 << 1)) !== 0) {
|
|
351
|
+
return this._region;
|
|
352
|
+
}
|
|
353
|
+
return readString(this._raw, 1)[0];
|
|
354
|
+
}
|
|
355
|
+
region() {
|
|
356
|
+
return this.getRegion();
|
|
357
|
+
}
|
|
358
|
+
setRegion(val) {
|
|
359
|
+
this._region = val;
|
|
360
|
+
this._dirtyMask |= 1 << 1;
|
|
361
|
+
}
|
|
362
|
+
getDatacenter() {
|
|
363
|
+
if ((this._dirtyMask & (1 << 2)) !== 0) {
|
|
364
|
+
return this._datacenter;
|
|
365
|
+
}
|
|
366
|
+
return readString(this._raw, 2)[0];
|
|
367
|
+
}
|
|
368
|
+
datacenter() {
|
|
369
|
+
return this.getDatacenter();
|
|
370
|
+
}
|
|
371
|
+
setDatacenter(val) {
|
|
372
|
+
this._datacenter = val;
|
|
373
|
+
this._dirtyMask |= 1 << 2;
|
|
374
|
+
}
|
|
375
|
+
getCity() {
|
|
376
|
+
if ((this._dirtyMask & (1 << 3)) !== 0) {
|
|
377
|
+
return this._city;
|
|
378
|
+
}
|
|
379
|
+
return readString(this._raw, 3)[0];
|
|
380
|
+
}
|
|
381
|
+
city() {
|
|
382
|
+
return this.getCity();
|
|
383
|
+
}
|
|
384
|
+
setCity(val) {
|
|
385
|
+
this._city = val;
|
|
386
|
+
this._dirtyMask |= 1 << 3;
|
|
387
|
+
}
|
|
388
|
+
getRack() {
|
|
389
|
+
if ((this._dirtyMask & (1 << 4)) !== 0) {
|
|
390
|
+
return this._rack;
|
|
391
|
+
}
|
|
392
|
+
return readUint(this._raw, 4)[0];
|
|
393
|
+
}
|
|
394
|
+
rack() {
|
|
395
|
+
return this.getRack();
|
|
396
|
+
}
|
|
397
|
+
setRack(val) {
|
|
398
|
+
this._rack = val;
|
|
399
|
+
this._dirtyMask |= 1 << 4;
|
|
400
|
+
}
|
|
401
|
+
getLatitude() {
|
|
402
|
+
if ((this._dirtyMask & (1 << 5)) !== 0) {
|
|
403
|
+
return this._latitude;
|
|
404
|
+
}
|
|
405
|
+
return roundFloat32Shortest(readFloat32(this._raw, 5)[0]);
|
|
406
|
+
}
|
|
407
|
+
latitude() {
|
|
408
|
+
return this.getLatitude();
|
|
409
|
+
}
|
|
410
|
+
setLatitude(val) {
|
|
411
|
+
this._latitude = val;
|
|
412
|
+
this._dirtyMask |= 1 << 5;
|
|
413
|
+
}
|
|
414
|
+
getLongitude() {
|
|
415
|
+
if ((this._dirtyMask & (1 << 6)) !== 0) {
|
|
416
|
+
return this._longitude;
|
|
417
|
+
}
|
|
418
|
+
return roundFloat32Shortest(readFloat32(this._raw, 6)[0]);
|
|
419
|
+
}
|
|
420
|
+
longitude() {
|
|
421
|
+
return this.getLongitude();
|
|
422
|
+
}
|
|
423
|
+
setLongitude(val) {
|
|
424
|
+
this._longitude = val;
|
|
425
|
+
this._dirtyMask |= 1 << 6;
|
|
426
|
+
}
|
|
427
|
+
marshal(options) {
|
|
428
|
+
if (this._dirtyMask !== 0) {
|
|
429
|
+
this._raw = spliceFields(this._raw, this._dirtyMask, 6, (enc, fnum) => {
|
|
430
|
+
switch (fnum) {
|
|
431
|
+
case 1: {
|
|
432
|
+
const msg = { region: this._region };
|
|
433
|
+
enc.writeString(1, msg.region ?? '');
|
|
434
|
+
break;
|
|
435
|
+
}
|
|
436
|
+
case 2: {
|
|
437
|
+
const msg = { datacenter: this._datacenter };
|
|
438
|
+
enc.writeString(2, msg.datacenter ?? '');
|
|
439
|
+
break;
|
|
440
|
+
}
|
|
441
|
+
case 3: {
|
|
442
|
+
const msg = { city: this._city };
|
|
443
|
+
enc.writeString(3, msg.city ?? '');
|
|
444
|
+
break;
|
|
445
|
+
}
|
|
446
|
+
case 4: {
|
|
447
|
+
const msg = { rack: this._rack };
|
|
448
|
+
enc.writeUint(4, Number(msg.rack ?? 0) >>> 0);
|
|
449
|
+
break;
|
|
450
|
+
}
|
|
451
|
+
case 5: {
|
|
452
|
+
const msg = { latitude: this._latitude };
|
|
453
|
+
enc.writeFloat32(5, msg.latitude ?? 0);
|
|
454
|
+
break;
|
|
455
|
+
}
|
|
456
|
+
case 6: {
|
|
457
|
+
const msg = { longitude: this._longitude };
|
|
458
|
+
enc.writeFloat32(6, msg.longitude ?? 0);
|
|
459
|
+
break;
|
|
460
|
+
}
|
|
461
|
+
}
|
|
462
|
+
});
|
|
463
|
+
this._dirtyMask = 0;
|
|
464
|
+
}
|
|
465
|
+
if (options?.selfDescribing && (this._raw.length === 0 || this._raw[0] !== 0x19)) {
|
|
466
|
+
const f0 = encodeField0SchemaMeta(LocationSchema.getSchemaMeta(0), Boolean(options.deterministic));
|
|
467
|
+
const out = new Uint8Array(f0.length + this._raw.length);
|
|
468
|
+
out.set(f0, 0);
|
|
469
|
+
out.set(this._raw, f0.length);
|
|
470
|
+
return out;
|
|
471
|
+
}
|
|
472
|
+
return this._raw;
|
|
473
|
+
}
|
|
474
|
+
}
|
|
321
475
|
export const NeighborSchema = defineMessage('omnibuf.bench.Neighbor', {
|
|
322
476
|
peerAsn: { fieldNum: 1, name: 'peer_asn', type: 'uint32' },
|
|
323
477
|
router: { fieldNum: 2, type: 'string' },
|
|
@@ -326,21 +480,21 @@ export const NeighborSchema = defineMessage('omnibuf.bench.Neighbor', {
|
|
|
326
480
|
});
|
|
327
481
|
class NeighborMsg {
|
|
328
482
|
peerAsn = 0;
|
|
329
|
-
router = '';
|
|
330
|
-
latencyUs = 0;
|
|
331
|
-
established = false;
|
|
332
483
|
get peer_asn() {
|
|
333
484
|
return this.peerAsn;
|
|
334
485
|
}
|
|
335
486
|
set peer_asn(v) {
|
|
336
487
|
this.peerAsn = v;
|
|
337
488
|
}
|
|
489
|
+
router = '';
|
|
490
|
+
latencyUs = 0;
|
|
338
491
|
get latency_us() {
|
|
339
492
|
return this.latencyUs;
|
|
340
493
|
}
|
|
341
494
|
set latency_us(v) {
|
|
342
495
|
this.latencyUs = v;
|
|
343
496
|
}
|
|
497
|
+
established = false;
|
|
344
498
|
}
|
|
345
499
|
Object.defineProperty(NeighborMsg.prototype, '$typeName', {
|
|
346
500
|
value: 'omnibuf.bench.Neighbor',
|
|
@@ -354,9 +508,9 @@ export function createNeighbor(init) {
|
|
|
354
508
|
return NeighborSchema.create(init);
|
|
355
509
|
}
|
|
356
510
|
export function encodeNeighbor(enc, msg, options) {
|
|
357
|
-
enc.writeUint(1, msg.peerAsn ?? msg.peer_asn ?? 0);
|
|
511
|
+
enc.writeUint(1, Number(msg.peerAsn ?? msg.peer_asn ?? 0) >>> 0);
|
|
358
512
|
enc.writeString(2, msg.router ?? '');
|
|
359
|
-
enc.writeUint(3, msg.latencyUs ?? msg.latency_us ?? 0);
|
|
513
|
+
enc.writeUint(3, Number(msg.latencyUs ?? msg.latency_us ?? 0) >>> 0);
|
|
360
514
|
enc.writeBool(4, Boolean(msg.established));
|
|
361
515
|
if (options?.writeUnknownFields && Array.isArray(msg.$unknown)) {
|
|
362
516
|
for (const uf of msg.$unknown) {
|
|
@@ -382,6 +536,7 @@ export function decodeNeighbor(buf, target, depth = 0, options, startPos = 0, en
|
|
|
382
536
|
const out = target ?? new NeighborMsg();
|
|
383
537
|
const n = endPos;
|
|
384
538
|
let pos = startPos;
|
|
539
|
+
let seenMask = 0;
|
|
385
540
|
let unknownFields = Array.isArray(out.$unknown)
|
|
386
541
|
? out.$unknown
|
|
387
542
|
: null;
|
|
@@ -399,8 +554,8 @@ export function decodeNeighbor(buf, target, depth = 0, options, startPos = 0, en
|
|
|
399
554
|
pos += 2;
|
|
400
555
|
}
|
|
401
556
|
else {
|
|
402
|
-
const [t64, tn] = decodeVarintBigInt(buf, pos);
|
|
403
|
-
if (tn === 0 ||
|
|
557
|
+
const [t64, tn] = decodeVarintBigInt(buf, pos, n);
|
|
558
|
+
if (tn === 0 || t64 >> 4n > 536870911n)
|
|
404
559
|
throw new Error('omnibuf: invalid tag');
|
|
405
560
|
tag = Number(t64);
|
|
406
561
|
pos += tn;
|
|
@@ -408,18 +563,20 @@ export function decodeNeighbor(buf, target, depth = 0, options, startPos = 0, en
|
|
|
408
563
|
const fieldNum = tag <= 0x7fffffff ? tag >>> 4 : Math.floor(tag / 16);
|
|
409
564
|
const wt = tag & 0x0f;
|
|
410
565
|
if (fieldNum === 0) {
|
|
411
|
-
if (wt !==
|
|
566
|
+
if (wt !== 12)
|
|
412
567
|
throw new Error('omnibuf: invalid Field #0 wire type');
|
|
413
|
-
const [meta, nextPos] = readLenSlice(buf
|
|
568
|
+
const [meta, nextPos] = readLenSlice(buf, pos, 0, n);
|
|
414
569
|
decodeSchemaMeta(meta, depth + 1, maxDepth);
|
|
415
570
|
pos = nextPos;
|
|
416
571
|
continue;
|
|
417
572
|
}
|
|
573
|
+
const bit = fieldNum <= 30 ? 1 << fieldNum : 0;
|
|
574
|
+
const alreadySeen = (seenMask & bit) !== 0 || Boolean(options?.merge);
|
|
418
575
|
switch (fieldNum) {
|
|
419
576
|
case 1: {
|
|
420
|
-
if (wt
|
|
577
|
+
if (!(wt === 0)) {
|
|
421
578
|
const valStart = pos;
|
|
422
|
-
pos = validateValue(buf.subarray(0, n), pos, wt, depth, maxDepth);
|
|
579
|
+
pos = validateValue(n < buf.length ? buf.subarray(0, n) : buf, pos, wt, depth, maxDepth);
|
|
423
580
|
if (readUnknown) {
|
|
424
581
|
if (!unknownFields)
|
|
425
582
|
unknownFields = [];
|
|
@@ -431,30 +588,33 @@ export function decodeNeighbor(buf, target, depth = 0, options, startPos = 0, en
|
|
|
431
588
|
}
|
|
432
589
|
break;
|
|
433
590
|
}
|
|
591
|
+
seenMask |= bit;
|
|
434
592
|
if (pos >= n)
|
|
435
593
|
throw new Error('omnibuf: truncated uint32');
|
|
436
594
|
const vb = buf[pos];
|
|
595
|
+
let u32Val = 0;
|
|
437
596
|
if ((vb & 1) !== 0) {
|
|
438
|
-
|
|
597
|
+
u32Val = vb >>> 1;
|
|
439
598
|
pos += 1;
|
|
440
599
|
}
|
|
441
600
|
else if ((vb & 2) !== 0) {
|
|
442
601
|
if (pos + 2 > n)
|
|
443
602
|
throw new Error('omnibuf: truncated uint32');
|
|
444
|
-
|
|
603
|
+
u32Val = (vb | (buf[pos + 1] << 8)) >>> 2;
|
|
445
604
|
pos += 2;
|
|
446
605
|
}
|
|
447
606
|
else if ((vb & 4) !== 0) {
|
|
448
607
|
if (pos + 4 > n)
|
|
449
608
|
throw new Error('omnibuf: truncated uint32');
|
|
450
|
-
|
|
451
|
-
|
|
609
|
+
u32Val =
|
|
610
|
+
((vb | (buf[pos + 1] << 8) | (buf[pos + 2] << 16) | (buf[pos + 3] << 24)) >>> 3) >>>
|
|
611
|
+
0;
|
|
452
612
|
pos += 4;
|
|
453
613
|
}
|
|
454
614
|
else {
|
|
455
|
-
if (pos + 9 > n)
|
|
615
|
+
if (vb !== 0 || pos + 9 > n)
|
|
456
616
|
throw new Error('omnibuf: truncated uint32');
|
|
457
|
-
|
|
617
|
+
u32Val =
|
|
458
618
|
(buf[pos + 1] |
|
|
459
619
|
(buf[pos + 2] << 8) |
|
|
460
620
|
(buf[pos + 3] << 16) |
|
|
@@ -462,12 +622,13 @@ export function decodeNeighbor(buf, target, depth = 0, options, startPos = 0, en
|
|
|
462
622
|
0;
|
|
463
623
|
pos += 9;
|
|
464
624
|
}
|
|
625
|
+
out.peerAsn = u32Val;
|
|
465
626
|
break;
|
|
466
627
|
}
|
|
467
628
|
case 2: {
|
|
468
|
-
if (wt
|
|
629
|
+
if (!(wt === 10)) {
|
|
469
630
|
const valStart = pos;
|
|
470
|
-
pos = validateValue(buf.subarray(0, n), pos, wt, depth, maxDepth);
|
|
631
|
+
pos = validateValue(n < buf.length ? buf.subarray(0, n) : buf, pos, wt, depth, maxDepth);
|
|
471
632
|
if (readUnknown) {
|
|
472
633
|
if (!unknownFields)
|
|
473
634
|
unknownFields = [];
|
|
@@ -479,6 +640,7 @@ export function decodeNeighbor(buf, target, depth = 0, options, startPos = 0, en
|
|
|
479
640
|
}
|
|
480
641
|
break;
|
|
481
642
|
}
|
|
643
|
+
seenMask |= bit;
|
|
482
644
|
if (pos >= n)
|
|
483
645
|
throw new Error('omnibuf: truncated string');
|
|
484
646
|
const sb = buf[pos];
|
|
@@ -491,16 +653,16 @@ export function decodeNeighbor(buf, target, depth = 0, options, startPos = 0, en
|
|
|
491
653
|
pos += sLen;
|
|
492
654
|
}
|
|
493
655
|
else {
|
|
494
|
-
const [s, nextPos] = readLenSlice(buf
|
|
656
|
+
const [s, nextPos] = readLenSlice(buf, pos, 0, n);
|
|
495
657
|
out.router = decodeUTF8(s);
|
|
496
658
|
pos = nextPos;
|
|
497
659
|
}
|
|
498
660
|
break;
|
|
499
661
|
}
|
|
500
662
|
case 3: {
|
|
501
|
-
if (wt
|
|
663
|
+
if (!(wt === 0)) {
|
|
502
664
|
const valStart = pos;
|
|
503
|
-
pos = validateValue(buf.subarray(0, n), pos, wt, depth, maxDepth);
|
|
665
|
+
pos = validateValue(n < buf.length ? buf.subarray(0, n) : buf, pos, wt, depth, maxDepth);
|
|
504
666
|
if (readUnknown) {
|
|
505
667
|
if (!unknownFields)
|
|
506
668
|
unknownFields = [];
|
|
@@ -512,30 +674,33 @@ export function decodeNeighbor(buf, target, depth = 0, options, startPos = 0, en
|
|
|
512
674
|
}
|
|
513
675
|
break;
|
|
514
676
|
}
|
|
677
|
+
seenMask |= bit;
|
|
515
678
|
if (pos >= n)
|
|
516
679
|
throw new Error('omnibuf: truncated uint32');
|
|
517
680
|
const vb = buf[pos];
|
|
681
|
+
let u32Val = 0;
|
|
518
682
|
if ((vb & 1) !== 0) {
|
|
519
|
-
|
|
683
|
+
u32Val = vb >>> 1;
|
|
520
684
|
pos += 1;
|
|
521
685
|
}
|
|
522
686
|
else if ((vb & 2) !== 0) {
|
|
523
687
|
if (pos + 2 > n)
|
|
524
688
|
throw new Error('omnibuf: truncated uint32');
|
|
525
|
-
|
|
689
|
+
u32Val = (vb | (buf[pos + 1] << 8)) >>> 2;
|
|
526
690
|
pos += 2;
|
|
527
691
|
}
|
|
528
692
|
else if ((vb & 4) !== 0) {
|
|
529
693
|
if (pos + 4 > n)
|
|
530
694
|
throw new Error('omnibuf: truncated uint32');
|
|
531
|
-
|
|
532
|
-
|
|
695
|
+
u32Val =
|
|
696
|
+
((vb | (buf[pos + 1] << 8) | (buf[pos + 2] << 16) | (buf[pos + 3] << 24)) >>> 3) >>>
|
|
697
|
+
0;
|
|
533
698
|
pos += 4;
|
|
534
699
|
}
|
|
535
700
|
else {
|
|
536
|
-
if (pos + 9 > n)
|
|
701
|
+
if (vb !== 0 || pos + 9 > n)
|
|
537
702
|
throw new Error('omnibuf: truncated uint32');
|
|
538
|
-
|
|
703
|
+
u32Val =
|
|
539
704
|
(buf[pos + 1] |
|
|
540
705
|
(buf[pos + 2] << 8) |
|
|
541
706
|
(buf[pos + 3] << 16) |
|
|
@@ -543,12 +708,13 @@ export function decodeNeighbor(buf, target, depth = 0, options, startPos = 0, en
|
|
|
543
708
|
0;
|
|
544
709
|
pos += 9;
|
|
545
710
|
}
|
|
711
|
+
out.latencyUs = u32Val;
|
|
546
712
|
break;
|
|
547
713
|
}
|
|
548
714
|
case 4: {
|
|
549
|
-
if (wt
|
|
715
|
+
if (!(wt === 2 || wt === 3)) {
|
|
550
716
|
const valStart = pos;
|
|
551
|
-
pos = validateValue(buf.subarray(0, n), pos, wt, depth, maxDepth);
|
|
717
|
+
pos = validateValue(n < buf.length ? buf.subarray(0, n) : buf, pos, wt, depth, maxDepth);
|
|
552
718
|
if (readUnknown) {
|
|
553
719
|
if (!unknownFields)
|
|
554
720
|
unknownFields = [];
|
|
@@ -560,12 +726,13 @@ export function decodeNeighbor(buf, target, depth = 0, options, startPos = 0, en
|
|
|
560
726
|
}
|
|
561
727
|
break;
|
|
562
728
|
}
|
|
563
|
-
|
|
729
|
+
seenMask |= bit;
|
|
730
|
+
out.established = wt === 3;
|
|
564
731
|
break;
|
|
565
732
|
}
|
|
566
733
|
default: {
|
|
567
734
|
const valStart = pos;
|
|
568
|
-
pos = validateValue(buf.subarray(0, n), pos, wt, depth, maxDepth);
|
|
735
|
+
pos = validateValue(n < buf.length ? buf.subarray(0, n) : buf, pos, wt, depth, maxDepth);
|
|
569
736
|
if (readUnknown) {
|
|
570
737
|
if (!unknownFields)
|
|
571
738
|
unknownFields = [];
|
|
@@ -597,6 +764,115 @@ NeighborSchema.setGeneratedCodec({
|
|
|
597
764
|
encode: encodeNeighbor,
|
|
598
765
|
decode: decodeNeighbor,
|
|
599
766
|
});
|
|
767
|
+
export class OpaqueNeighbor {
|
|
768
|
+
_raw;
|
|
769
|
+
_dirtyMask = 0;
|
|
770
|
+
_peerAsn;
|
|
771
|
+
_router;
|
|
772
|
+
_latencyUs;
|
|
773
|
+
_established;
|
|
774
|
+
constructor(raw) {
|
|
775
|
+
this._raw = raw;
|
|
776
|
+
}
|
|
777
|
+
raw() {
|
|
778
|
+
return this._raw;
|
|
779
|
+
}
|
|
780
|
+
getPeerAsn() {
|
|
781
|
+
if ((this._dirtyMask & (1 << 1)) !== 0) {
|
|
782
|
+
return this._peerAsn;
|
|
783
|
+
}
|
|
784
|
+
return readUint(this._raw, 1)[0];
|
|
785
|
+
}
|
|
786
|
+
peerAsn() {
|
|
787
|
+
return this.getPeerAsn();
|
|
788
|
+
}
|
|
789
|
+
peer_asn() {
|
|
790
|
+
return this.getPeerAsn();
|
|
791
|
+
}
|
|
792
|
+
setPeerAsn(val) {
|
|
793
|
+
this._peerAsn = val;
|
|
794
|
+
this._dirtyMask |= 1 << 1;
|
|
795
|
+
}
|
|
796
|
+
getRouter() {
|
|
797
|
+
if ((this._dirtyMask & (1 << 2)) !== 0) {
|
|
798
|
+
return this._router;
|
|
799
|
+
}
|
|
800
|
+
return readString(this._raw, 2)[0];
|
|
801
|
+
}
|
|
802
|
+
router() {
|
|
803
|
+
return this.getRouter();
|
|
804
|
+
}
|
|
805
|
+
setRouter(val) {
|
|
806
|
+
this._router = val;
|
|
807
|
+
this._dirtyMask |= 1 << 2;
|
|
808
|
+
}
|
|
809
|
+
getLatencyUs() {
|
|
810
|
+
if ((this._dirtyMask & (1 << 3)) !== 0) {
|
|
811
|
+
return this._latencyUs;
|
|
812
|
+
}
|
|
813
|
+
return readUint(this._raw, 3)[0];
|
|
814
|
+
}
|
|
815
|
+
latencyUs() {
|
|
816
|
+
return this.getLatencyUs();
|
|
817
|
+
}
|
|
818
|
+
latency_us() {
|
|
819
|
+
return this.getLatencyUs();
|
|
820
|
+
}
|
|
821
|
+
setLatencyUs(val) {
|
|
822
|
+
this._latencyUs = val;
|
|
823
|
+
this._dirtyMask |= 1 << 3;
|
|
824
|
+
}
|
|
825
|
+
getEstablished() {
|
|
826
|
+
if ((this._dirtyMask & (1 << 4)) !== 0) {
|
|
827
|
+
return this._established;
|
|
828
|
+
}
|
|
829
|
+
return readBool(this._raw, 4)[0];
|
|
830
|
+
}
|
|
831
|
+
established() {
|
|
832
|
+
return this.getEstablished();
|
|
833
|
+
}
|
|
834
|
+
setEstablished(val) {
|
|
835
|
+
this._established = val;
|
|
836
|
+
this._dirtyMask |= 1 << 4;
|
|
837
|
+
}
|
|
838
|
+
marshal(options) {
|
|
839
|
+
if (this._dirtyMask !== 0) {
|
|
840
|
+
this._raw = spliceFields(this._raw, this._dirtyMask, 4, (enc, fnum) => {
|
|
841
|
+
switch (fnum) {
|
|
842
|
+
case 1: {
|
|
843
|
+
const msg = { peerAsn: this._peerAsn };
|
|
844
|
+
enc.writeUint(1, Number(msg.peerAsn ?? msg.peer_asn ?? 0) >>> 0);
|
|
845
|
+
break;
|
|
846
|
+
}
|
|
847
|
+
case 2: {
|
|
848
|
+
const msg = { router: this._router };
|
|
849
|
+
enc.writeString(2, msg.router ?? '');
|
|
850
|
+
break;
|
|
851
|
+
}
|
|
852
|
+
case 3: {
|
|
853
|
+
const msg = { latencyUs: this._latencyUs };
|
|
854
|
+
enc.writeUint(3, Number(msg.latencyUs ?? msg.latency_us ?? 0) >>> 0);
|
|
855
|
+
break;
|
|
856
|
+
}
|
|
857
|
+
case 4: {
|
|
858
|
+
const msg = { established: this._established };
|
|
859
|
+
enc.writeBool(4, Boolean(msg.established));
|
|
860
|
+
break;
|
|
861
|
+
}
|
|
862
|
+
}
|
|
863
|
+
});
|
|
864
|
+
this._dirtyMask = 0;
|
|
865
|
+
}
|
|
866
|
+
if (options?.selfDescribing && (this._raw.length === 0 || this._raw[0] !== 0x19)) {
|
|
867
|
+
const f0 = encodeField0SchemaMeta(NeighborSchema.getSchemaMeta(0), Boolean(options.deterministic));
|
|
868
|
+
const out = new Uint8Array(f0.length + this._raw.length);
|
|
869
|
+
out.set(f0, 0);
|
|
870
|
+
out.set(this._raw, f0.length);
|
|
871
|
+
return out;
|
|
872
|
+
}
|
|
873
|
+
return this._raw;
|
|
874
|
+
}
|
|
875
|
+
}
|
|
600
876
|
export const PeerUpdateSchema = defineMessage('omnibuf.bench.PeerUpdate', {
|
|
601
877
|
asn: { fieldNum: 1, type: 'uint32' },
|
|
602
878
|
routerId: { fieldNum: 2, name: 'router_id', type: 'string' },
|
|
@@ -606,46 +882,46 @@ export const PeerUpdateSchema = defineMessage('omnibuf.bench.PeerUpdate', {
|
|
|
606
882
|
cpuLoad: { fieldNum: 6, name: 'cpu_load', type: 'float64' },
|
|
607
883
|
tags: { fieldNum: 7, type: 'string[]' },
|
|
608
884
|
prefixes: { fieldNum: 8, type: 'uint32[]' },
|
|
609
|
-
location: { fieldNum: 9, type: 'submsg',
|
|
885
|
+
location: { fieldNum: 9, type: 'submsg', subSchema: () => LocationSchema },
|
|
610
886
|
neighbors: { fieldNum: 10, type: 'submsg[]', subSchema: () => NeighborSchema },
|
|
611
887
|
sequence: { fieldNum: 11, type: 'uint64' },
|
|
612
888
|
});
|
|
613
889
|
class PeerUpdateMsg {
|
|
614
890
|
asn = 0;
|
|
615
891
|
routerId = '';
|
|
616
|
-
active = false;
|
|
617
|
-
uptimeSec = 0;
|
|
618
|
-
rssiDbm = 0;
|
|
619
|
-
cpuLoad = 0;
|
|
620
|
-
tags = [];
|
|
621
|
-
prefixes = [];
|
|
622
|
-
location = new LocationMsg();
|
|
623
|
-
neighbors = [];
|
|
624
|
-
sequence = 0;
|
|
625
892
|
get router_id() {
|
|
626
893
|
return this.routerId;
|
|
627
894
|
}
|
|
628
895
|
set router_id(v) {
|
|
629
896
|
this.routerId = v;
|
|
630
897
|
}
|
|
898
|
+
active = false;
|
|
899
|
+
uptimeSec = 0;
|
|
631
900
|
get uptime_sec() {
|
|
632
901
|
return this.uptimeSec;
|
|
633
902
|
}
|
|
634
903
|
set uptime_sec(v) {
|
|
635
904
|
this.uptimeSec = v;
|
|
636
905
|
}
|
|
906
|
+
rssiDbm = 0;
|
|
637
907
|
get rssi_dbm() {
|
|
638
908
|
return this.rssiDbm;
|
|
639
909
|
}
|
|
640
910
|
set rssi_dbm(v) {
|
|
641
911
|
this.rssiDbm = v;
|
|
642
912
|
}
|
|
913
|
+
cpuLoad = 0;
|
|
643
914
|
get cpu_load() {
|
|
644
915
|
return this.cpuLoad;
|
|
645
916
|
}
|
|
646
917
|
set cpu_load(v) {
|
|
647
918
|
this.cpuLoad = v;
|
|
648
919
|
}
|
|
920
|
+
tags = [];
|
|
921
|
+
prefixes = [];
|
|
922
|
+
location = null;
|
|
923
|
+
neighbors = [];
|
|
924
|
+
sequence = 0;
|
|
649
925
|
}
|
|
650
926
|
Object.defineProperty(PeerUpdateMsg.prototype, '$typeName', {
|
|
651
927
|
value: 'omnibuf.bench.PeerUpdate',
|
|
@@ -659,7 +935,7 @@ export function createPeerUpdate(init) {
|
|
|
659
935
|
return PeerUpdateSchema.create(init);
|
|
660
936
|
}
|
|
661
937
|
export function encodePeerUpdate(enc, msg, options) {
|
|
662
|
-
enc.writeUint(1, msg.asn ?? 0);
|
|
938
|
+
enc.writeUint(1, Number(msg.asn ?? 0) >>> 0);
|
|
663
939
|
enc.writeString(2, msg.routerId ?? msg.router_id ?? '');
|
|
664
940
|
enc.writeBool(3, Boolean(msg.active));
|
|
665
941
|
enc.writeUint(4, msg.uptimeSec ?? msg.uptime_sec ?? 0);
|
|
@@ -667,9 +943,14 @@ export function encodePeerUpdate(enc, msg, options) {
|
|
|
667
943
|
enc.writeFloat64(6, msg.cpuLoad ?? msg.cpu_load ?? 0);
|
|
668
944
|
enc.writeStringArr(7, msg.tags ?? []);
|
|
669
945
|
enc.writeUint32Arr(8, msg.prefixes ?? []);
|
|
670
|
-
|
|
671
|
-
|
|
672
|
-
|
|
946
|
+
{
|
|
947
|
+
const subVal = msg.location;
|
|
948
|
+
if (subVal !== null && subVal !== undefined) {
|
|
949
|
+
enc.beginSubMsg(9);
|
|
950
|
+
encodeLocation(enc, subVal, options);
|
|
951
|
+
enc.endSubMsg();
|
|
952
|
+
}
|
|
953
|
+
}
|
|
673
954
|
{
|
|
674
955
|
const arr = msg.neighbors ?? [];
|
|
675
956
|
enc.beginSubMsgArr(10);
|
|
@@ -696,15 +977,15 @@ export function marshalPeerUpdateOmniBuf(msg, options) {
|
|
|
696
977
|
encodePeerUpdate(enc, msg, options);
|
|
697
978
|
return enc.finish();
|
|
698
979
|
}
|
|
699
|
-
export function decodePeerUpdate(buf, target, depth = 0, options) {
|
|
980
|
+
export function decodePeerUpdate(buf, target, depth = 0, options, startPos = 0, endPos = buf.length) {
|
|
700
981
|
const maxDepth = options?.recursionLimit ?? MaxNestingDepth;
|
|
701
982
|
const readUnknown = options?.readUnknownFields ?? true;
|
|
702
983
|
if (depth > maxDepth) {
|
|
703
984
|
throw new Error(`omnibuf: nesting depth ${depth} exceeds MaxNestingDepth (${maxDepth})`);
|
|
704
985
|
}
|
|
705
986
|
const out = target ?? new PeerUpdateMsg();
|
|
706
|
-
const n =
|
|
707
|
-
let pos =
|
|
987
|
+
const n = endPos;
|
|
988
|
+
let pos = startPos;
|
|
708
989
|
let seenMask = 0;
|
|
709
990
|
let unknownFields = Array.isArray(out.$unknown)
|
|
710
991
|
? out.$unknown
|
|
@@ -723,8 +1004,8 @@ export function decodePeerUpdate(buf, target, depth = 0, options) {
|
|
|
723
1004
|
pos += 2;
|
|
724
1005
|
}
|
|
725
1006
|
else {
|
|
726
|
-
const [t64, tn] = decodeVarintBigInt(buf, pos);
|
|
727
|
-
if (tn === 0 || t64 >> 4n >
|
|
1007
|
+
const [t64, tn] = decodeVarintBigInt(buf, pos, n);
|
|
1008
|
+
if (tn === 0 || t64 >> 4n > 536870911n)
|
|
728
1009
|
throw new Error('omnibuf: invalid tag');
|
|
729
1010
|
tag = Number(t64);
|
|
730
1011
|
pos += tn;
|
|
@@ -732,9 +1013,9 @@ export function decodePeerUpdate(buf, target, depth = 0, options) {
|
|
|
732
1013
|
const fieldNum = tag <= 0x7fffffff ? tag >>> 4 : Math.floor(tag / 16);
|
|
733
1014
|
const wt = tag & 0x0f;
|
|
734
1015
|
if (fieldNum === 0) {
|
|
735
|
-
if (wt !==
|
|
1016
|
+
if (wt !== 12)
|
|
736
1017
|
throw new Error('omnibuf: invalid Field #0 wire type');
|
|
737
|
-
const [meta, nextPos] = readLenSlice(buf, pos, 0);
|
|
1018
|
+
const [meta, nextPos] = readLenSlice(buf, pos, 0, n);
|
|
738
1019
|
decodeSchemaMeta(meta, depth + 1, maxDepth);
|
|
739
1020
|
pos = nextPos;
|
|
740
1021
|
continue;
|
|
@@ -743,9 +1024,9 @@ export function decodePeerUpdate(buf, target, depth = 0, options) {
|
|
|
743
1024
|
const alreadySeen = (seenMask & bit) !== 0 || Boolean(options?.merge);
|
|
744
1025
|
switch (fieldNum) {
|
|
745
1026
|
case 1: {
|
|
746
|
-
if (wt
|
|
1027
|
+
if (!(wt === 0)) {
|
|
747
1028
|
const valStart = pos;
|
|
748
|
-
pos = validateValue(buf, pos, wt, depth, maxDepth);
|
|
1029
|
+
pos = validateValue(n < buf.length ? buf.subarray(0, n) : buf, pos, wt, depth, maxDepth);
|
|
749
1030
|
if (readUnknown) {
|
|
750
1031
|
if (!unknownFields)
|
|
751
1032
|
unknownFields = [];
|
|
@@ -761,27 +1042,29 @@ export function decodePeerUpdate(buf, target, depth = 0, options) {
|
|
|
761
1042
|
if (pos >= n)
|
|
762
1043
|
throw new Error('omnibuf: truncated uint32');
|
|
763
1044
|
const vb = buf[pos];
|
|
1045
|
+
let u32Val = 0;
|
|
764
1046
|
if ((vb & 1) !== 0) {
|
|
765
|
-
|
|
1047
|
+
u32Val = vb >>> 1;
|
|
766
1048
|
pos += 1;
|
|
767
1049
|
}
|
|
768
1050
|
else if ((vb & 2) !== 0) {
|
|
769
1051
|
if (pos + 2 > n)
|
|
770
1052
|
throw new Error('omnibuf: truncated uint32');
|
|
771
|
-
|
|
1053
|
+
u32Val = (vb | (buf[pos + 1] << 8)) >>> 2;
|
|
772
1054
|
pos += 2;
|
|
773
1055
|
}
|
|
774
1056
|
else if ((vb & 4) !== 0) {
|
|
775
1057
|
if (pos + 4 > n)
|
|
776
1058
|
throw new Error('omnibuf: truncated uint32');
|
|
777
|
-
|
|
778
|
-
|
|
1059
|
+
u32Val =
|
|
1060
|
+
((vb | (buf[pos + 1] << 8) | (buf[pos + 2] << 16) | (buf[pos + 3] << 24)) >>> 3) >>>
|
|
1061
|
+
0;
|
|
779
1062
|
pos += 4;
|
|
780
1063
|
}
|
|
781
1064
|
else {
|
|
782
|
-
if (pos + 9 > n)
|
|
1065
|
+
if (vb !== 0 || pos + 9 > n)
|
|
783
1066
|
throw new Error('omnibuf: truncated uint32');
|
|
784
|
-
|
|
1067
|
+
u32Val =
|
|
785
1068
|
(buf[pos + 1] |
|
|
786
1069
|
(buf[pos + 2] << 8) |
|
|
787
1070
|
(buf[pos + 3] << 16) |
|
|
@@ -789,12 +1072,13 @@ export function decodePeerUpdate(buf, target, depth = 0, options) {
|
|
|
789
1072
|
0;
|
|
790
1073
|
pos += 9;
|
|
791
1074
|
}
|
|
1075
|
+
out.asn = u32Val;
|
|
792
1076
|
break;
|
|
793
1077
|
}
|
|
794
1078
|
case 2: {
|
|
795
|
-
if (wt
|
|
1079
|
+
if (!(wt === 10)) {
|
|
796
1080
|
const valStart = pos;
|
|
797
|
-
pos = validateValue(buf, pos, wt, depth, maxDepth);
|
|
1081
|
+
pos = validateValue(n < buf.length ? buf.subarray(0, n) : buf, pos, wt, depth, maxDepth);
|
|
798
1082
|
if (readUnknown) {
|
|
799
1083
|
if (!unknownFields)
|
|
800
1084
|
unknownFields = [];
|
|
@@ -819,16 +1103,16 @@ export function decodePeerUpdate(buf, target, depth = 0, options) {
|
|
|
819
1103
|
pos += sLen;
|
|
820
1104
|
}
|
|
821
1105
|
else {
|
|
822
|
-
const [s, nextPos] = readLenSlice(buf, pos, 0);
|
|
1106
|
+
const [s, nextPos] = readLenSlice(buf, pos, 0, n);
|
|
823
1107
|
out.routerId = decodeUTF8(s);
|
|
824
1108
|
pos = nextPos;
|
|
825
1109
|
}
|
|
826
1110
|
break;
|
|
827
1111
|
}
|
|
828
1112
|
case 3: {
|
|
829
|
-
if (wt
|
|
1113
|
+
if (!(wt === 2 || wt === 3)) {
|
|
830
1114
|
const valStart = pos;
|
|
831
|
-
pos = validateValue(buf, pos, wt, depth, maxDepth);
|
|
1115
|
+
pos = validateValue(n < buf.length ? buf.subarray(0, n) : buf, pos, wt, depth, maxDepth);
|
|
832
1116
|
if (readUnknown) {
|
|
833
1117
|
if (!unknownFields)
|
|
834
1118
|
unknownFields = [];
|
|
@@ -841,13 +1125,13 @@ export function decodePeerUpdate(buf, target, depth = 0, options) {
|
|
|
841
1125
|
break;
|
|
842
1126
|
}
|
|
843
1127
|
seenMask |= bit;
|
|
844
|
-
out.active = wt ===
|
|
1128
|
+
out.active = wt === 3;
|
|
845
1129
|
break;
|
|
846
1130
|
}
|
|
847
1131
|
case 4: {
|
|
848
|
-
if (wt
|
|
1132
|
+
if (!(wt === 0)) {
|
|
849
1133
|
const valStart = pos;
|
|
850
|
-
pos = validateValue(buf, pos, wt, depth, maxDepth);
|
|
1134
|
+
pos = validateValue(n < buf.length ? buf.subarray(0, n) : buf, pos, wt, depth, maxDepth);
|
|
851
1135
|
if (readUnknown) {
|
|
852
1136
|
if (!unknownFields)
|
|
853
1137
|
unknownFields = [];
|
|
@@ -863,36 +1147,48 @@ export function decodePeerUpdate(buf, target, depth = 0, options) {
|
|
|
863
1147
|
if (pos >= n)
|
|
864
1148
|
throw new Error('omnibuf: truncated uint64');
|
|
865
1149
|
const vb = buf[pos];
|
|
1150
|
+
let u64Val;
|
|
866
1151
|
if ((vb & 1) !== 0) {
|
|
867
|
-
|
|
1152
|
+
u64Val = vb >>> 1;
|
|
868
1153
|
pos += 1;
|
|
869
1154
|
}
|
|
870
1155
|
else if ((vb & 2) !== 0) {
|
|
871
1156
|
if (pos + 2 > n)
|
|
872
1157
|
throw new Error('omnibuf: truncated uint64');
|
|
873
|
-
|
|
1158
|
+
u64Val = (vb | (buf[pos + 1] << 8)) >>> 2;
|
|
874
1159
|
pos += 2;
|
|
875
1160
|
}
|
|
876
1161
|
else if ((vb & 4) !== 0) {
|
|
877
1162
|
if (pos + 4 > n)
|
|
878
1163
|
throw new Error('omnibuf: truncated uint64');
|
|
879
|
-
|
|
880
|
-
|
|
1164
|
+
u64Val =
|
|
1165
|
+
((vb | (buf[pos + 1] << 8) | (buf[pos + 2] << 16) | (buf[pos + 3] << 24)) >>> 3) >>>
|
|
1166
|
+
0;
|
|
881
1167
|
pos += 4;
|
|
882
1168
|
}
|
|
883
1169
|
else {
|
|
884
|
-
|
|
885
|
-
if (vn === 0)
|
|
1170
|
+
if (vb !== 0 || pos + 9 > n)
|
|
886
1171
|
throw new Error('omnibuf: truncated uint64');
|
|
887
|
-
|
|
888
|
-
|
|
1172
|
+
const lo = (buf[pos + 1] |
|
|
1173
|
+
(buf[pos + 2] << 8) |
|
|
1174
|
+
(buf[pos + 3] << 16) |
|
|
1175
|
+
(buf[pos + 4] << 24)) >>>
|
|
1176
|
+
0;
|
|
1177
|
+
const hi = (buf[pos + 5] |
|
|
1178
|
+
(buf[pos + 6] << 8) |
|
|
1179
|
+
(buf[pos + 7] << 16) |
|
|
1180
|
+
(buf[pos + 8] << 24)) >>>
|
|
1181
|
+
0;
|
|
1182
|
+
u64Val = hi <= 0x1fffff ? hi * 0x100000000 + lo : (BigInt(hi) << 32n) | BigInt(lo);
|
|
1183
|
+
pos += 9;
|
|
889
1184
|
}
|
|
1185
|
+
out.uptimeSec = u64Val;
|
|
890
1186
|
break;
|
|
891
1187
|
}
|
|
892
1188
|
case 5: {
|
|
893
|
-
if (wt
|
|
1189
|
+
if (!(wt === 1)) {
|
|
894
1190
|
const valStart = pos;
|
|
895
|
-
pos = validateValue(buf, pos, wt, depth, maxDepth);
|
|
1191
|
+
pos = validateValue(n < buf.length ? buf.subarray(0, n) : buf, pos, wt, depth, maxDepth);
|
|
896
1192
|
if (readUnknown) {
|
|
897
1193
|
if (!unknownFields)
|
|
898
1194
|
unknownFields = [];
|
|
@@ -906,41 +1202,43 @@ export function decodePeerUpdate(buf, target, depth = 0, options) {
|
|
|
906
1202
|
}
|
|
907
1203
|
seenMask |= bit;
|
|
908
1204
|
if (pos >= n)
|
|
909
|
-
throw new Error('omnibuf: truncated int32');
|
|
1205
|
+
throw new Error('omnibuf: truncated int32/enum');
|
|
910
1206
|
const vb = buf[pos];
|
|
1207
|
+
let i32Val = 0;
|
|
911
1208
|
if ((vb & 1) !== 0) {
|
|
912
1209
|
const u = vb >>> 1;
|
|
913
|
-
|
|
1210
|
+
i32Val = (u >>> 1) ^ -(u & 1);
|
|
914
1211
|
pos += 1;
|
|
915
1212
|
}
|
|
916
1213
|
else if ((vb & 2) !== 0) {
|
|
917
1214
|
if (pos + 2 > n)
|
|
918
|
-
throw new Error('omnibuf: truncated int32');
|
|
1215
|
+
throw new Error('omnibuf: truncated int32/enum');
|
|
919
1216
|
const u = (vb | (buf[pos + 1] << 8)) >>> 2;
|
|
920
|
-
|
|
1217
|
+
i32Val = (u >>> 1) ^ -(u & 1);
|
|
921
1218
|
pos += 2;
|
|
922
1219
|
}
|
|
923
1220
|
else if ((vb & 4) !== 0) {
|
|
924
1221
|
if (pos + 4 > n)
|
|
925
|
-
throw new Error('omnibuf: truncated int32');
|
|
1222
|
+
throw new Error('omnibuf: truncated int32/enum');
|
|
926
1223
|
const u = ((vb | (buf[pos + 1] << 8) | (buf[pos + 2] << 16) | (buf[pos + 3] << 24)) >>> 3) >>>
|
|
927
1224
|
0;
|
|
928
|
-
|
|
1225
|
+
i32Val = (u >>> 1) ^ -(u & 1);
|
|
929
1226
|
pos += 4;
|
|
930
1227
|
}
|
|
931
1228
|
else {
|
|
932
|
-
const [v, vn] = decodeVarintBigInt(buf, pos);
|
|
1229
|
+
const [v, vn] = decodeVarintBigInt(buf, pos, n);
|
|
933
1230
|
if (vn === 0)
|
|
934
|
-
throw new Error('omnibuf: truncated int32');
|
|
935
|
-
|
|
1231
|
+
throw new Error('omnibuf: truncated int32/enum');
|
|
1232
|
+
i32Val = decodeZigZag(v) | 0;
|
|
936
1233
|
pos += vn;
|
|
937
1234
|
}
|
|
1235
|
+
out.rssiDbm = i32Val;
|
|
938
1236
|
break;
|
|
939
1237
|
}
|
|
940
1238
|
case 6: {
|
|
941
|
-
if (wt
|
|
1239
|
+
if (!(wt === 9)) {
|
|
942
1240
|
const valStart = pos;
|
|
943
|
-
pos = validateValue(buf, pos, wt, depth, maxDepth);
|
|
1241
|
+
pos = validateValue(n < buf.length ? buf.subarray(0, n) : buf, pos, wt, depth, maxDepth);
|
|
944
1242
|
if (readUnknown) {
|
|
945
1243
|
if (!unknownFields)
|
|
946
1244
|
unknownFields = [];
|
|
@@ -960,9 +1258,9 @@ export function decodePeerUpdate(buf, target, depth = 0, options) {
|
|
|
960
1258
|
break;
|
|
961
1259
|
}
|
|
962
1260
|
case 7: {
|
|
963
|
-
if (wt
|
|
1261
|
+
if (!(wt === 13)) {
|
|
964
1262
|
const valStart = pos;
|
|
965
|
-
pos = validateValue(buf, pos, wt, depth, maxDepth);
|
|
1263
|
+
pos = validateValue(n < buf.length ? buf.subarray(0, n) : buf, pos, wt, depth, maxDepth);
|
|
966
1264
|
if (readUnknown) {
|
|
967
1265
|
if (!unknownFields)
|
|
968
1266
|
unknownFields = [];
|
|
@@ -990,7 +1288,7 @@ export function decodePeerUpdate(buf, target, depth = 0, options) {
|
|
|
990
1288
|
pos += 1;
|
|
991
1289
|
}
|
|
992
1290
|
else {
|
|
993
|
-
const [body, nextPos] = readLenSlice(buf, pos,
|
|
1291
|
+
const [body, nextPos] = readLenSlice(buf, pos, 2, n);
|
|
994
1292
|
const prev = alreadySeen && Array.isArray(out.tags) ? out.tags : [];
|
|
995
1293
|
const [arr, ok] = appendStringArrBody(prev, body);
|
|
996
1294
|
if (!ok)
|
|
@@ -1000,12 +1298,11 @@ export function decodePeerUpdate(buf, target, depth = 0, options) {
|
|
|
1000
1298
|
break;
|
|
1001
1299
|
}
|
|
1002
1300
|
const bodyEnd = pos + bodyLen;
|
|
1003
|
-
if (bodyLen <
|
|
1301
|
+
if (bodyLen < 2 || bodyEnd > n)
|
|
1004
1302
|
throw new Error('omnibuf: invalid string array');
|
|
1005
|
-
|
|
1006
|
-
|
|
1007
|
-
|
|
1008
|
-
let p = pos + 1;
|
|
1303
|
+
if (buf[pos] === 10 && (buf[pos + 1] & 1) !== 0) {
|
|
1304
|
+
const count = buf[pos + 1] >>> 1;
|
|
1305
|
+
let p = pos + 2;
|
|
1009
1306
|
if (count > bodyEnd - p)
|
|
1010
1307
|
throw new Error('omnibuf: invalid string array');
|
|
1011
1308
|
let dst = out.tags;
|
|
@@ -1029,10 +1326,9 @@ export function decodePeerUpdate(buf, target, depth = 0, options) {
|
|
|
1029
1326
|
p += sLen;
|
|
1030
1327
|
}
|
|
1031
1328
|
else {
|
|
1032
|
-
const [sLen, sn] = decodeVarintBigInt(buf, p);
|
|
1033
|
-
if (sn === 0 || sLen > BigInt(bodyEnd - (p + sn)))
|
|
1329
|
+
const [sLen, sn] = decodeVarintBigInt(buf, p, bodyEnd);
|
|
1330
|
+
if (sn === 0 || sLen > BigInt(bodyEnd - (p + sn)))
|
|
1034
1331
|
throw new Error('omnibuf: invalid string array');
|
|
1035
|
-
}
|
|
1036
1332
|
p += sn;
|
|
1037
1333
|
const sLenNum = Number(sLen);
|
|
1038
1334
|
dst.push(decodeUTF8(buf, p, p + sLenNum));
|
|
@@ -1053,9 +1349,9 @@ export function decodePeerUpdate(buf, target, depth = 0, options) {
|
|
|
1053
1349
|
break;
|
|
1054
1350
|
}
|
|
1055
1351
|
case 8: {
|
|
1056
|
-
if (wt
|
|
1352
|
+
if (!(wt === 13)) {
|
|
1057
1353
|
const valStart = pos;
|
|
1058
|
-
pos = validateValue(buf, pos, wt, depth, maxDepth);
|
|
1354
|
+
pos = validateValue(n < buf.length ? buf.subarray(0, n) : buf, pos, wt, depth, maxDepth);
|
|
1059
1355
|
if (readUnknown) {
|
|
1060
1356
|
if (!unknownFields)
|
|
1061
1357
|
unknownFields = [];
|
|
@@ -1083,7 +1379,7 @@ export function decodePeerUpdate(buf, target, depth = 0, options) {
|
|
|
1083
1379
|
pos += 1;
|
|
1084
1380
|
}
|
|
1085
1381
|
else {
|
|
1086
|
-
const [body, nextPos] = readLenSlice(buf, pos,
|
|
1382
|
+
const [body, nextPos] = readLenSlice(buf, pos, 2, n);
|
|
1087
1383
|
const prev = alreadySeen && Array.isArray(out.prefixes) ? out.prefixes : [];
|
|
1088
1384
|
const [arr, ok] = appendUint32ArrBody(prev, body);
|
|
1089
1385
|
if (!ok)
|
|
@@ -1093,12 +1389,11 @@ export function decodePeerUpdate(buf, target, depth = 0, options) {
|
|
|
1093
1389
|
break;
|
|
1094
1390
|
}
|
|
1095
1391
|
const bodyEnd = pos + bodyLen;
|
|
1096
|
-
if (bodyLen <
|
|
1392
|
+
if (bodyLen < 2 || bodyEnd > n)
|
|
1097
1393
|
throw new Error('omnibuf: invalid uint32 array');
|
|
1098
|
-
|
|
1099
|
-
|
|
1100
|
-
|
|
1101
|
-
let p = pos + 1;
|
|
1394
|
+
if (buf[pos] === 0 && (buf[pos + 1] & 1) !== 0) {
|
|
1395
|
+
const count = buf[pos + 1] >>> 1;
|
|
1396
|
+
let p = pos + 2;
|
|
1102
1397
|
if (count > bodyEnd - p)
|
|
1103
1398
|
throw new Error('omnibuf: invalid uint32 array');
|
|
1104
1399
|
let dst = out.prefixes;
|
|
@@ -1126,16 +1421,14 @@ export function decodePeerUpdate(buf, target, depth = 0, options) {
|
|
|
1126
1421
|
else if ((vb & 4) !== 0) {
|
|
1127
1422
|
if (p + 4 > bodyEnd)
|
|
1128
1423
|
throw new Error('omnibuf: invalid uint32 array');
|
|
1129
|
-
|
|
1130
|
-
dst.push(u32 >>> 3);
|
|
1424
|
+
dst.push(((vb | (buf[p + 1] << 8) | (buf[p + 2] << 16) | (buf[p + 3] << 24)) >>> 3) >>> 0);
|
|
1131
1425
|
p += 4;
|
|
1132
1426
|
}
|
|
1133
1427
|
else {
|
|
1134
|
-
if (p + 9 > bodyEnd)
|
|
1428
|
+
if (vb !== 0 || p + 9 > bodyEnd)
|
|
1135
1429
|
throw new Error('omnibuf: invalid uint32 array');
|
|
1136
|
-
|
|
1137
|
-
0;
|
|
1138
|
-
dst.push(lo);
|
|
1430
|
+
dst.push((buf[p + 1] | (buf[p + 2] << 8) | (buf[p + 3] << 16) | (buf[p + 4] << 24)) >>>
|
|
1431
|
+
0);
|
|
1139
1432
|
p += 9;
|
|
1140
1433
|
}
|
|
1141
1434
|
}
|
|
@@ -1153,9 +1446,9 @@ export function decodePeerUpdate(buf, target, depth = 0, options) {
|
|
|
1153
1446
|
break;
|
|
1154
1447
|
}
|
|
1155
1448
|
case 9: {
|
|
1156
|
-
if (wt
|
|
1449
|
+
if (!(wt === 12)) {
|
|
1157
1450
|
const valStart = pos;
|
|
1158
|
-
pos = validateValue(buf, pos, wt, depth, maxDepth);
|
|
1451
|
+
pos = validateValue(n < buf.length ? buf.subarray(0, n) : buf, pos, wt, depth, maxDepth);
|
|
1159
1452
|
if (readUnknown) {
|
|
1160
1453
|
if (!unknownFields)
|
|
1161
1454
|
unknownFields = [];
|
|
@@ -1183,21 +1476,25 @@ export function decodePeerUpdate(buf, target, depth = 0, options) {
|
|
|
1183
1476
|
pos += 1;
|
|
1184
1477
|
}
|
|
1185
1478
|
else {
|
|
1186
|
-
const [subBytes, nextPos] = readLenSlice(buf, pos, 0);
|
|
1187
|
-
|
|
1479
|
+
const [subBytes, nextPos] = readLenSlice(buf, pos, 0, n);
|
|
1480
|
+
const existing = out.location;
|
|
1481
|
+
const decodedSub = decodeLocation(subBytes, existing ?? undefined, depth + 1, alreadySeen ? { ...options, merge: true } : options);
|
|
1482
|
+
out.location = decodedSub;
|
|
1188
1483
|
pos = nextPos;
|
|
1189
1484
|
break;
|
|
1190
1485
|
}
|
|
1191
1486
|
if (pos + subLen > n)
|
|
1192
1487
|
throw new Error('omnibuf: truncated submsg');
|
|
1193
|
-
|
|
1488
|
+
const existing = out.location;
|
|
1489
|
+
const decodedSub = decodeLocation(buf, existing ?? undefined, depth + 1, alreadySeen ? { ...options, merge: true } : options, pos, pos + subLen);
|
|
1490
|
+
out.location = decodedSub;
|
|
1194
1491
|
pos += subLen;
|
|
1195
1492
|
break;
|
|
1196
1493
|
}
|
|
1197
1494
|
case 10: {
|
|
1198
|
-
if (wt
|
|
1495
|
+
if (!(wt === 13)) {
|
|
1199
1496
|
const valStart = pos;
|
|
1200
|
-
pos = validateValue(buf, pos, wt, depth, maxDepth);
|
|
1497
|
+
pos = validateValue(n < buf.length ? buf.subarray(0, n) : buf, pos, wt, depth, maxDepth);
|
|
1201
1498
|
if (readUnknown) {
|
|
1202
1499
|
if (!unknownFields)
|
|
1203
1500
|
unknownFields = [];
|
|
@@ -1211,12 +1508,12 @@ export function decodePeerUpdate(buf, target, depth = 0, options) {
|
|
|
1211
1508
|
}
|
|
1212
1509
|
seenMask |= bit;
|
|
1213
1510
|
if (pos >= n)
|
|
1214
|
-
throw new Error('omnibuf:
|
|
1511
|
+
throw new Error('omnibuf: corrupt submsg array');
|
|
1215
1512
|
let arrLen = 0;
|
|
1216
1513
|
const lb = buf[pos];
|
|
1217
1514
|
if ((lb & 2) !== 0) {
|
|
1218
1515
|
if (pos + 2 > n)
|
|
1219
|
-
throw new Error('omnibuf:
|
|
1516
|
+
throw new Error('omnibuf: corrupt submsg array');
|
|
1220
1517
|
arrLen = (lb | (buf[pos + 1] << 8)) >>> 2;
|
|
1221
1518
|
pos += 2;
|
|
1222
1519
|
}
|
|
@@ -1225,12 +1522,12 @@ export function decodePeerUpdate(buf, target, depth = 0, options) {
|
|
|
1225
1522
|
pos += 1;
|
|
1226
1523
|
}
|
|
1227
1524
|
else {
|
|
1228
|
-
const [arrPayload, nextPos] = readLenSlice(buf, pos,
|
|
1525
|
+
const [arrPayload, nextPos] = readLenSlice(buf, pos, 2, n);
|
|
1229
1526
|
const [elemCount, ok] = countSubMsgArrElems(arrPayload);
|
|
1230
1527
|
if (!ok)
|
|
1231
1528
|
throw new Error('omnibuf: corrupt submsg array');
|
|
1232
1529
|
const elems = alreadySeen && Array.isArray(out.neighbors) ? out.neighbors : [];
|
|
1233
|
-
let p =
|
|
1530
|
+
let [, , p] = parseArrayHeader(arrPayload);
|
|
1234
1531
|
for (let i = 0; i < elemCount; i++) {
|
|
1235
1532
|
const [el, en] = decodeVarintBigInt(arrPayload, p);
|
|
1236
1533
|
p += en;
|
|
@@ -1243,50 +1540,74 @@ export function decodePeerUpdate(buf, target, depth = 0, options) {
|
|
|
1243
1540
|
break;
|
|
1244
1541
|
}
|
|
1245
1542
|
const arrEnd = pos + arrLen;
|
|
1246
|
-
if (arrEnd > n)
|
|
1247
|
-
throw new Error('omnibuf:
|
|
1248
|
-
|
|
1249
|
-
|
|
1250
|
-
|
|
1251
|
-
|
|
1252
|
-
|
|
1253
|
-
|
|
1254
|
-
elems
|
|
1255
|
-
|
|
1256
|
-
|
|
1257
|
-
while (p < arrEnd) {
|
|
1258
|
-
let elNum = 0;
|
|
1259
|
-
const eb0 = buf[p];
|
|
1260
|
-
if ((eb0 & 2) !== 0) {
|
|
1261
|
-
if (p + 2 > arrEnd)
|
|
1262
|
-
throw new Error('omnibuf: corrupt submsg array');
|
|
1263
|
-
elNum = (eb0 | (buf[p + 1] << 8)) >>> 2;
|
|
1264
|
-
p += 2;
|
|
1543
|
+
if (arrLen < 2 || arrEnd > n)
|
|
1544
|
+
throw new Error('omnibuf: corrupt submsg array');
|
|
1545
|
+
if (buf[pos] === 12 && (buf[pos + 1] & 1) !== 0) {
|
|
1546
|
+
const elemCount = buf[pos + 1] >>> 1;
|
|
1547
|
+
let p = pos + 2;
|
|
1548
|
+
if (elemCount > arrEnd - p)
|
|
1549
|
+
throw new Error('omnibuf: corrupt submsg array');
|
|
1550
|
+
let elems = out.neighbors;
|
|
1551
|
+
if (!Array.isArray(elems)) {
|
|
1552
|
+
elems = [];
|
|
1553
|
+
out.neighbors = elems;
|
|
1265
1554
|
}
|
|
1266
|
-
else if (
|
|
1267
|
-
|
|
1268
|
-
p += 1;
|
|
1555
|
+
else if (!alreadySeen) {
|
|
1556
|
+
elems.length = 0;
|
|
1269
1557
|
}
|
|
1270
|
-
|
|
1271
|
-
|
|
1272
|
-
if (en === 0 || el > BigInt(arrEnd - (p + en))) {
|
|
1558
|
+
for (let i = 0; i < elemCount; i++) {
|
|
1559
|
+
if (p >= arrEnd)
|
|
1273
1560
|
throw new Error('omnibuf: corrupt submsg array');
|
|
1561
|
+
let elNum = 0;
|
|
1562
|
+
const eb0 = buf[p];
|
|
1563
|
+
if ((eb0 & 2) !== 0) {
|
|
1564
|
+
if (p + 2 > arrEnd)
|
|
1565
|
+
throw new Error('omnibuf: corrupt submsg array');
|
|
1566
|
+
elNum = (eb0 | (buf[p + 1] << 8)) >>> 2;
|
|
1567
|
+
p += 2;
|
|
1274
1568
|
}
|
|
1275
|
-
|
|
1276
|
-
|
|
1569
|
+
else if ((eb0 & 1) !== 0) {
|
|
1570
|
+
elNum = eb0 >>> 1;
|
|
1571
|
+
p += 1;
|
|
1572
|
+
}
|
|
1573
|
+
else {
|
|
1574
|
+
const [el, en] = decodeVarintBigInt(buf, p, arrEnd);
|
|
1575
|
+
if (en === 0 || el > BigInt(arrEnd - (p + en)))
|
|
1576
|
+
throw new Error('omnibuf: corrupt submsg array');
|
|
1577
|
+
p += en;
|
|
1578
|
+
elNum = Number(el);
|
|
1579
|
+
}
|
|
1580
|
+
if (p + elNum > arrEnd)
|
|
1581
|
+
throw new Error('omnibuf: corrupt submsg array');
|
|
1582
|
+
elems.push(decodeNeighbor(buf, undefined, depth + 1, options, p, p + elNum));
|
|
1583
|
+
p += elNum;
|
|
1277
1584
|
}
|
|
1278
|
-
if (p
|
|
1585
|
+
if (p !== arrEnd)
|
|
1279
1586
|
throw new Error('omnibuf: corrupt submsg array');
|
|
1280
|
-
|
|
1587
|
+
pos = arrEnd;
|
|
1588
|
+
break;
|
|
1589
|
+
}
|
|
1590
|
+
const arrPayload = buf.subarray(pos, arrEnd);
|
|
1591
|
+
const [elemCount, ok] = countSubMsgArrElems(arrPayload);
|
|
1592
|
+
if (!ok)
|
|
1593
|
+
throw new Error('omnibuf: corrupt submsg array');
|
|
1594
|
+
const elems = alreadySeen && Array.isArray(out.neighbors) ? out.neighbors : [];
|
|
1595
|
+
let [, , p] = parseArrayHeader(arrPayload);
|
|
1596
|
+
for (let i = 0; i < elemCount; i++) {
|
|
1597
|
+
const [el, en] = decodeVarintBigInt(arrPayload, p);
|
|
1598
|
+
p += en;
|
|
1599
|
+
const elNum = Number(el);
|
|
1600
|
+
elems.push(decodeNeighbor(arrPayload, undefined, depth + 1, options, p, p + elNum));
|
|
1281
1601
|
p += elNum;
|
|
1282
1602
|
}
|
|
1603
|
+
out.neighbors = elems;
|
|
1283
1604
|
pos = arrEnd;
|
|
1284
1605
|
break;
|
|
1285
1606
|
}
|
|
1286
1607
|
case 11: {
|
|
1287
|
-
if (wt
|
|
1608
|
+
if (!(wt === 0)) {
|
|
1288
1609
|
const valStart = pos;
|
|
1289
|
-
pos = validateValue(buf, pos, wt, depth, maxDepth);
|
|
1610
|
+
pos = validateValue(n < buf.length ? buf.subarray(0, n) : buf, pos, wt, depth, maxDepth);
|
|
1290
1611
|
if (readUnknown) {
|
|
1291
1612
|
if (!unknownFields)
|
|
1292
1613
|
unknownFields = [];
|
|
@@ -1302,25 +1623,27 @@ export function decodePeerUpdate(buf, target, depth = 0, options) {
|
|
|
1302
1623
|
if (pos >= n)
|
|
1303
1624
|
throw new Error('omnibuf: truncated uint64');
|
|
1304
1625
|
const vb = buf[pos];
|
|
1626
|
+
let u64Val;
|
|
1305
1627
|
if ((vb & 1) !== 0) {
|
|
1306
|
-
|
|
1628
|
+
u64Val = vb >>> 1;
|
|
1307
1629
|
pos += 1;
|
|
1308
1630
|
}
|
|
1309
1631
|
else if ((vb & 2) !== 0) {
|
|
1310
1632
|
if (pos + 2 > n)
|
|
1311
1633
|
throw new Error('omnibuf: truncated uint64');
|
|
1312
|
-
|
|
1634
|
+
u64Val = (vb | (buf[pos + 1] << 8)) >>> 2;
|
|
1313
1635
|
pos += 2;
|
|
1314
1636
|
}
|
|
1315
1637
|
else if ((vb & 4) !== 0) {
|
|
1316
1638
|
if (pos + 4 > n)
|
|
1317
1639
|
throw new Error('omnibuf: truncated uint64');
|
|
1318
|
-
|
|
1319
|
-
|
|
1640
|
+
u64Val =
|
|
1641
|
+
((vb | (buf[pos + 1] << 8) | (buf[pos + 2] << 16) | (buf[pos + 3] << 24)) >>> 3) >>>
|
|
1642
|
+
0;
|
|
1320
1643
|
pos += 4;
|
|
1321
1644
|
}
|
|
1322
1645
|
else {
|
|
1323
|
-
if (pos + 9 > n)
|
|
1646
|
+
if (vb !== 0 || pos + 9 > n)
|
|
1324
1647
|
throw new Error('omnibuf: truncated uint64');
|
|
1325
1648
|
const lo = (buf[pos + 1] |
|
|
1326
1649
|
(buf[pos + 2] << 8) |
|
|
@@ -1332,14 +1655,15 @@ export function decodePeerUpdate(buf, target, depth = 0, options) {
|
|
|
1332
1655
|
(buf[pos + 7] << 16) |
|
|
1333
1656
|
(buf[pos + 8] << 24)) >>>
|
|
1334
1657
|
0;
|
|
1335
|
-
|
|
1658
|
+
u64Val = hi <= 0x1fffff ? hi * 0x100000000 + lo : (BigInt(hi) << 32n) | BigInt(lo);
|
|
1336
1659
|
pos += 9;
|
|
1337
1660
|
}
|
|
1661
|
+
out.sequence = u64Val;
|
|
1338
1662
|
break;
|
|
1339
1663
|
}
|
|
1340
1664
|
default: {
|
|
1341
1665
|
const valStart = pos;
|
|
1342
|
-
pos = validateValue(buf, pos, wt, depth, maxDepth);
|
|
1666
|
+
pos = validateValue(n < buf.length ? buf.subarray(0, n) : buf, pos, wt, depth, maxDepth);
|
|
1343
1667
|
if (readUnknown) {
|
|
1344
1668
|
if (!unknownFields)
|
|
1345
1669
|
unknownFields = [];
|
|
@@ -1391,157 +1715,168 @@ export class OpaquePeerUpdate {
|
|
|
1391
1715
|
raw() {
|
|
1392
1716
|
return this._raw;
|
|
1393
1717
|
}
|
|
1394
|
-
|
|
1395
|
-
if ((this._dirtyMask & (1 << 1)) !== 0)
|
|
1718
|
+
getAsn() {
|
|
1719
|
+
if ((this._dirtyMask & (1 << 1)) !== 0) {
|
|
1396
1720
|
return this._asn;
|
|
1721
|
+
}
|
|
1397
1722
|
return readUint(this._raw, 1)[0];
|
|
1398
1723
|
}
|
|
1399
|
-
|
|
1400
|
-
return this.
|
|
1724
|
+
asn() {
|
|
1725
|
+
return this.getAsn();
|
|
1401
1726
|
}
|
|
1402
1727
|
setAsn(val) {
|
|
1403
1728
|
this._asn = val;
|
|
1404
1729
|
this._dirtyMask |= 1 << 1;
|
|
1405
1730
|
}
|
|
1406
|
-
|
|
1407
|
-
if ((this._dirtyMask & (1 << 2)) !== 0)
|
|
1731
|
+
getRouterId() {
|
|
1732
|
+
if ((this._dirtyMask & (1 << 2)) !== 0) {
|
|
1408
1733
|
return this._routerId;
|
|
1734
|
+
}
|
|
1409
1735
|
return readString(this._raw, 2)[0];
|
|
1410
1736
|
}
|
|
1411
|
-
|
|
1412
|
-
return this.
|
|
1737
|
+
routerId() {
|
|
1738
|
+
return this.getRouterId();
|
|
1413
1739
|
}
|
|
1414
1740
|
router_id() {
|
|
1415
|
-
return this.
|
|
1741
|
+
return this.getRouterId();
|
|
1416
1742
|
}
|
|
1417
1743
|
setRouterId(val) {
|
|
1418
1744
|
this._routerId = val;
|
|
1419
1745
|
this._dirtyMask |= 1 << 2;
|
|
1420
1746
|
}
|
|
1421
|
-
|
|
1422
|
-
if ((this._dirtyMask & (1 << 3)) !== 0)
|
|
1747
|
+
getActive() {
|
|
1748
|
+
if ((this._dirtyMask & (1 << 3)) !== 0) {
|
|
1423
1749
|
return this._active;
|
|
1750
|
+
}
|
|
1424
1751
|
return readBool(this._raw, 3)[0];
|
|
1425
1752
|
}
|
|
1426
|
-
|
|
1427
|
-
return this.
|
|
1753
|
+
active() {
|
|
1754
|
+
return this.getActive();
|
|
1428
1755
|
}
|
|
1429
1756
|
setActive(val) {
|
|
1430
1757
|
this._active = val;
|
|
1431
1758
|
this._dirtyMask |= 1 << 3;
|
|
1432
1759
|
}
|
|
1433
|
-
|
|
1434
|
-
if ((this._dirtyMask & (1 << 4)) !== 0)
|
|
1760
|
+
getUptimeSec() {
|
|
1761
|
+
if ((this._dirtyMask & (1 << 4)) !== 0) {
|
|
1435
1762
|
return this._uptimeSec;
|
|
1763
|
+
}
|
|
1436
1764
|
return readUintAuto(this._raw, 4)[0];
|
|
1437
1765
|
}
|
|
1438
|
-
|
|
1439
|
-
return this.
|
|
1766
|
+
uptimeSec() {
|
|
1767
|
+
return this.getUptimeSec();
|
|
1440
1768
|
}
|
|
1441
1769
|
uptime_sec() {
|
|
1442
|
-
return this.
|
|
1770
|
+
return this.getUptimeSec();
|
|
1443
1771
|
}
|
|
1444
1772
|
setUptimeSec(val) {
|
|
1445
1773
|
this._uptimeSec = val;
|
|
1446
1774
|
this._dirtyMask |= 1 << 4;
|
|
1447
1775
|
}
|
|
1448
|
-
|
|
1449
|
-
if ((this._dirtyMask & (1 << 5)) !== 0)
|
|
1776
|
+
getRssiDbm() {
|
|
1777
|
+
if ((this._dirtyMask & (1 << 5)) !== 0) {
|
|
1450
1778
|
return this._rssiDbm;
|
|
1779
|
+
}
|
|
1451
1780
|
return readInt(this._raw, 5)[0];
|
|
1452
1781
|
}
|
|
1453
|
-
|
|
1454
|
-
return this.
|
|
1782
|
+
rssiDbm() {
|
|
1783
|
+
return this.getRssiDbm();
|
|
1455
1784
|
}
|
|
1456
1785
|
rssi_dbm() {
|
|
1457
|
-
return this.
|
|
1786
|
+
return this.getRssiDbm();
|
|
1458
1787
|
}
|
|
1459
1788
|
setRssiDbm(val) {
|
|
1460
1789
|
this._rssiDbm = val;
|
|
1461
1790
|
this._dirtyMask |= 1 << 5;
|
|
1462
1791
|
}
|
|
1463
|
-
|
|
1464
|
-
if ((this._dirtyMask & (1 << 6)) !== 0)
|
|
1792
|
+
getCpuLoad() {
|
|
1793
|
+
if ((this._dirtyMask & (1 << 6)) !== 0) {
|
|
1465
1794
|
return this._cpuLoad;
|
|
1795
|
+
}
|
|
1466
1796
|
return readFloat64(this._raw, 6)[0];
|
|
1467
1797
|
}
|
|
1468
|
-
|
|
1469
|
-
return this.
|
|
1798
|
+
cpuLoad() {
|
|
1799
|
+
return this.getCpuLoad();
|
|
1470
1800
|
}
|
|
1471
1801
|
cpu_load() {
|
|
1472
|
-
return this.
|
|
1802
|
+
return this.getCpuLoad();
|
|
1473
1803
|
}
|
|
1474
1804
|
setCpuLoad(val) {
|
|
1475
1805
|
this._cpuLoad = val;
|
|
1476
1806
|
this._dirtyMask |= 1 << 6;
|
|
1477
1807
|
}
|
|
1478
|
-
|
|
1479
|
-
if ((this._dirtyMask & (1 << 7)) !== 0)
|
|
1808
|
+
getTags() {
|
|
1809
|
+
if ((this._dirtyMask & (1 << 7)) !== 0) {
|
|
1480
1810
|
return this._tags;
|
|
1811
|
+
}
|
|
1481
1812
|
if (this._tags === undefined) {
|
|
1482
1813
|
this._tags = readStringArr(this._raw, 7)[0];
|
|
1483
1814
|
}
|
|
1484
1815
|
return this._tags;
|
|
1485
1816
|
}
|
|
1486
|
-
|
|
1487
|
-
return this.
|
|
1817
|
+
tags() {
|
|
1818
|
+
return this.getTags();
|
|
1488
1819
|
}
|
|
1489
1820
|
setTags(val) {
|
|
1490
1821
|
this._tags = val;
|
|
1491
1822
|
this._dirtyMask |= 1 << 7;
|
|
1492
1823
|
}
|
|
1493
|
-
|
|
1494
|
-
if ((this._dirtyMask & (1 << 8)) !== 0)
|
|
1824
|
+
getPrefixes() {
|
|
1825
|
+
if ((this._dirtyMask & (1 << 8)) !== 0) {
|
|
1495
1826
|
return this._prefixes;
|
|
1827
|
+
}
|
|
1496
1828
|
if (this._prefixes === undefined) {
|
|
1497
1829
|
this._prefixes = readUint32Arr(this._raw, 8)[0];
|
|
1498
1830
|
}
|
|
1499
1831
|
return this._prefixes;
|
|
1500
1832
|
}
|
|
1501
|
-
|
|
1502
|
-
return this.
|
|
1833
|
+
prefixes() {
|
|
1834
|
+
return this.getPrefixes();
|
|
1503
1835
|
}
|
|
1504
1836
|
setPrefixes(val) {
|
|
1505
1837
|
this._prefixes = val;
|
|
1506
1838
|
this._dirtyMask |= 1 << 8;
|
|
1507
1839
|
}
|
|
1508
|
-
|
|
1509
|
-
if ((this._dirtyMask & (1 << 9)) !== 0)
|
|
1840
|
+
getLocation() {
|
|
1841
|
+
if ((this._dirtyMask & (1 << 9)) !== 0) {
|
|
1510
1842
|
return this._location;
|
|
1843
|
+
}
|
|
1511
1844
|
if (this._location === undefined) {
|
|
1512
|
-
this._location = readSubMsgMerged(this._raw, 9, (sub, target, merge) => decodeLocation(sub, target, 0, { merge }))[0];
|
|
1845
|
+
this._location = readSubMsgMerged(this._raw, 9, (sub, target, merge, s, e) => decodeLocation(sub, target, 0, merge ? { merge: true } : undefined, s, e))[0];
|
|
1513
1846
|
}
|
|
1514
1847
|
return this._location;
|
|
1515
1848
|
}
|
|
1516
|
-
|
|
1517
|
-
return this.
|
|
1849
|
+
location() {
|
|
1850
|
+
return this.getLocation();
|
|
1518
1851
|
}
|
|
1519
1852
|
setLocation(val) {
|
|
1520
1853
|
this._location = val;
|
|
1521
1854
|
this._dirtyMask |= 1 << 9;
|
|
1522
1855
|
}
|
|
1523
|
-
|
|
1524
|
-
if ((this._dirtyMask & (1 << 10)) !== 0)
|
|
1856
|
+
getNeighbors() {
|
|
1857
|
+
if ((this._dirtyMask & (1 << 10)) !== 0) {
|
|
1525
1858
|
return this._neighbors;
|
|
1859
|
+
}
|
|
1526
1860
|
if (this._neighbors === undefined) {
|
|
1527
1861
|
this._neighbors = readSubMsgArrDecoded(this._raw, 10, (sub) => decodeNeighbor(sub))[0];
|
|
1528
1862
|
}
|
|
1529
1863
|
return this._neighbors;
|
|
1530
1864
|
}
|
|
1531
|
-
|
|
1532
|
-
return this.
|
|
1865
|
+
neighbors() {
|
|
1866
|
+
return this.getNeighbors();
|
|
1533
1867
|
}
|
|
1534
1868
|
setNeighbors(val) {
|
|
1535
1869
|
this._neighbors = val;
|
|
1536
1870
|
this._dirtyMask |= 1 << 10;
|
|
1537
1871
|
}
|
|
1538
|
-
|
|
1539
|
-
if ((this._dirtyMask & (1 << 11)) !== 0)
|
|
1872
|
+
getSequence() {
|
|
1873
|
+
if ((this._dirtyMask & (1 << 11)) !== 0) {
|
|
1540
1874
|
return this._sequence;
|
|
1875
|
+
}
|
|
1541
1876
|
return readUintAuto(this._raw, 11)[0];
|
|
1542
1877
|
}
|
|
1543
|
-
|
|
1544
|
-
return this.
|
|
1878
|
+
sequence() {
|
|
1879
|
+
return this.getSequence();
|
|
1545
1880
|
}
|
|
1546
1881
|
setSequence(val) {
|
|
1547
1882
|
this._sequence = val;
|
|
@@ -1551,56 +1886,82 @@ export class OpaquePeerUpdate {
|
|
|
1551
1886
|
if (this._dirtyMask !== 0) {
|
|
1552
1887
|
this._raw = spliceFields(this._raw, this._dirtyMask, 11, (enc, fnum) => {
|
|
1553
1888
|
switch (fnum) {
|
|
1554
|
-
case 1:
|
|
1555
|
-
|
|
1889
|
+
case 1: {
|
|
1890
|
+
const msg = { asn: this._asn };
|
|
1891
|
+
enc.writeUint(1, Number(msg.asn ?? 0) >>> 0);
|
|
1556
1892
|
break;
|
|
1557
|
-
|
|
1558
|
-
|
|
1893
|
+
}
|
|
1894
|
+
case 2: {
|
|
1895
|
+
const msg = { routerId: this._routerId };
|
|
1896
|
+
enc.writeString(2, msg.routerId ?? msg.router_id ?? '');
|
|
1559
1897
|
break;
|
|
1560
|
-
|
|
1561
|
-
|
|
1898
|
+
}
|
|
1899
|
+
case 3: {
|
|
1900
|
+
const msg = { active: this._active };
|
|
1901
|
+
enc.writeBool(3, Boolean(msg.active));
|
|
1562
1902
|
break;
|
|
1563
|
-
|
|
1564
|
-
|
|
1903
|
+
}
|
|
1904
|
+
case 4: {
|
|
1905
|
+
const msg = { uptimeSec: this._uptimeSec };
|
|
1906
|
+
enc.writeUint(4, msg.uptimeSec ?? msg.uptime_sec ?? 0);
|
|
1565
1907
|
break;
|
|
1566
|
-
|
|
1567
|
-
|
|
1908
|
+
}
|
|
1909
|
+
case 5: {
|
|
1910
|
+
const msg = { rssiDbm: this._rssiDbm };
|
|
1911
|
+
enc.writeInt(5, msg.rssiDbm ?? msg.rssi_dbm ?? 0);
|
|
1568
1912
|
break;
|
|
1569
|
-
|
|
1570
|
-
|
|
1913
|
+
}
|
|
1914
|
+
case 6: {
|
|
1915
|
+
const msg = { cpuLoad: this._cpuLoad };
|
|
1916
|
+
enc.writeFloat64(6, msg.cpuLoad ?? msg.cpu_load ?? 0);
|
|
1571
1917
|
break;
|
|
1572
|
-
|
|
1573
|
-
|
|
1918
|
+
}
|
|
1919
|
+
case 7: {
|
|
1920
|
+
const msg = { tags: this._tags };
|
|
1921
|
+
enc.writeStringArr(7, msg.tags ?? []);
|
|
1574
1922
|
break;
|
|
1575
|
-
|
|
1576
|
-
|
|
1923
|
+
}
|
|
1924
|
+
case 8: {
|
|
1925
|
+
const msg = { prefixes: this._prefixes };
|
|
1926
|
+
enc.writeUint32Arr(8, msg.prefixes ?? []);
|
|
1577
1927
|
break;
|
|
1578
|
-
|
|
1579
|
-
|
|
1580
|
-
|
|
1581
|
-
|
|
1582
|
-
|
|
1928
|
+
}
|
|
1929
|
+
case 9: {
|
|
1930
|
+
const msg = { location: this._location };
|
|
1931
|
+
{
|
|
1932
|
+
const subVal = msg.location;
|
|
1933
|
+
if (subVal !== null && subVal !== undefined) {
|
|
1934
|
+
enc.beginSubMsg(9);
|
|
1935
|
+
encodeLocation(enc, subVal, options);
|
|
1936
|
+
enc.endSubMsg();
|
|
1937
|
+
}
|
|
1583
1938
|
}
|
|
1584
1939
|
break;
|
|
1940
|
+
}
|
|
1585
1941
|
case 10: {
|
|
1586
|
-
const
|
|
1587
|
-
|
|
1588
|
-
|
|
1589
|
-
enc.
|
|
1590
|
-
|
|
1591
|
-
|
|
1942
|
+
const msg = { neighbors: this._neighbors };
|
|
1943
|
+
{
|
|
1944
|
+
const arr = msg.neighbors ?? [];
|
|
1945
|
+
enc.beginSubMsgArr(10);
|
|
1946
|
+
for (let i = 0; i < arr.length; i++) {
|
|
1947
|
+
enc.beginSubMsgElem();
|
|
1948
|
+
encodeNeighbor(enc, arr[i], options);
|
|
1949
|
+
enc.endSubMsgElem();
|
|
1950
|
+
}
|
|
1951
|
+
enc.endSubMsgArr();
|
|
1592
1952
|
}
|
|
1593
|
-
enc.endSubMsgArr();
|
|
1594
1953
|
break;
|
|
1595
1954
|
}
|
|
1596
|
-
case 11:
|
|
1597
|
-
|
|
1955
|
+
case 11: {
|
|
1956
|
+
const msg = { sequence: this._sequence };
|
|
1957
|
+
enc.writeUint(11, msg.sequence ?? 0);
|
|
1598
1958
|
break;
|
|
1959
|
+
}
|
|
1599
1960
|
}
|
|
1600
1961
|
});
|
|
1601
1962
|
this._dirtyMask = 0;
|
|
1602
1963
|
}
|
|
1603
|
-
if (options?.selfDescribing && (this._raw.length === 0 || this._raw[0] !==
|
|
1964
|
+
if (options?.selfDescribing && (this._raw.length === 0 || this._raw[0] !== 0x19)) {
|
|
1604
1965
|
const f0 = encodeField0SchemaMeta(PeerUpdateSchema.getSchemaMeta(0), Boolean(options.deterministic));
|
|
1605
1966
|
const out = new Uint8Array(f0.length + this._raw.length);
|
|
1606
1967
|
out.set(f0, 0);
|
|
@@ -1610,5 +1971,4 @@ export class OpaquePeerUpdate {
|
|
|
1610
1971
|
return this._raw;
|
|
1611
1972
|
}
|
|
1612
1973
|
}
|
|
1613
|
-
export { roundFloat32Shortest, readFloat32 };
|
|
1614
1974
|
//# sourceMappingURL=peer_omnibuf.pb.js.map
|