hypercore 10.0.0-alpha.25 → 10.0.0-alpha.28
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/index.js +145 -85
- package/lib/bitfield.js +6 -3
- package/lib/caps.js +34 -0
- package/lib/core.js +26 -10
- package/lib/merkle-tree.js +114 -81
- package/lib/messages.js +246 -177
- package/lib/replicator.js +1334 -639
- package/package.json +5 -3
- package/lib/extensions.js +0 -76
- package/lib/protocol.js +0 -606
- package/lib/random-iterator.js +0 -46
package/lib/messages.js
CHANGED
|
@@ -1,6 +1,9 @@
|
|
|
1
1
|
const c = require('compact-encoding')
|
|
2
|
+
const b4a = require('b4a')
|
|
2
3
|
|
|
3
|
-
const
|
|
4
|
+
const EMPTY = b4a.alloc(0)
|
|
5
|
+
|
|
6
|
+
const node = {
|
|
4
7
|
preencode (state, n) {
|
|
5
8
|
c.uint.preencode(state, n.index)
|
|
6
9
|
c.uint.preencode(state, n.size)
|
|
@@ -22,6 +25,124 @@ const node = exports.node = {
|
|
|
22
25
|
|
|
23
26
|
const nodeArray = c.array(node)
|
|
24
27
|
|
|
28
|
+
const wire = exports.wire = {}
|
|
29
|
+
|
|
30
|
+
wire.handshake = {
|
|
31
|
+
preencode (state, m) {
|
|
32
|
+
c.uint.preencode(state, 0) // flags for the future
|
|
33
|
+
c.fixed32.preencode(state, m.capability)
|
|
34
|
+
},
|
|
35
|
+
encode (state, m) {
|
|
36
|
+
c.uint.encode(state, 0) // flags for the future
|
|
37
|
+
c.fixed32.encode(state, m.capability)
|
|
38
|
+
},
|
|
39
|
+
decode (state) {
|
|
40
|
+
c.uint.decode(state) // flags for the future
|
|
41
|
+
return {
|
|
42
|
+
capability: c.fixed32.decode(state)
|
|
43
|
+
}
|
|
44
|
+
}
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
const requestBlock = {
|
|
48
|
+
preencode (state, b) {
|
|
49
|
+
c.uint.preencode(state, b.index)
|
|
50
|
+
c.uint.preencode(state, b.nodes)
|
|
51
|
+
},
|
|
52
|
+
encode (state, b) {
|
|
53
|
+
c.uint.encode(state, b.index)
|
|
54
|
+
c.uint.encode(state, b.nodes)
|
|
55
|
+
},
|
|
56
|
+
decode (state) {
|
|
57
|
+
return {
|
|
58
|
+
index: c.uint.decode(state),
|
|
59
|
+
nodes: c.uint.decode(state)
|
|
60
|
+
}
|
|
61
|
+
}
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
const requestSeek = {
|
|
65
|
+
preencode (state, s) {
|
|
66
|
+
c.uint.preencode(state, s.bytes)
|
|
67
|
+
},
|
|
68
|
+
encode (state, s) {
|
|
69
|
+
c.uint.encode(state, s.bytes)
|
|
70
|
+
},
|
|
71
|
+
decode (state) {
|
|
72
|
+
return {
|
|
73
|
+
bytes: c.uint.decode(state)
|
|
74
|
+
}
|
|
75
|
+
}
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
const requestUpgrade = {
|
|
79
|
+
preencode (state, u) {
|
|
80
|
+
c.uint.preencode(state, u.start)
|
|
81
|
+
c.uint.preencode(state, u.length)
|
|
82
|
+
},
|
|
83
|
+
encode (state, u) {
|
|
84
|
+
c.uint.encode(state, u.start)
|
|
85
|
+
c.uint.encode(state, u.length)
|
|
86
|
+
},
|
|
87
|
+
decode (state) {
|
|
88
|
+
return {
|
|
89
|
+
start: c.uint.decode(state),
|
|
90
|
+
length: c.uint.decode(state)
|
|
91
|
+
}
|
|
92
|
+
}
|
|
93
|
+
}
|
|
94
|
+
|
|
95
|
+
wire.request = {
|
|
96
|
+
preencode (state, m) {
|
|
97
|
+
state.end++ // flags
|
|
98
|
+
c.uint.preencode(state, m.id)
|
|
99
|
+
c.uint.preencode(state, m.fork)
|
|
100
|
+
|
|
101
|
+
if (m.block) requestBlock.preencode(state, m.block)
|
|
102
|
+
if (m.hash) requestBlock.preencode(state, m.hash)
|
|
103
|
+
if (m.seek) requestSeek.preencode(state, m.seek)
|
|
104
|
+
if (m.upgrade) requestUpgrade.preencode(state, m.upgrade)
|
|
105
|
+
},
|
|
106
|
+
encode (state, m) {
|
|
107
|
+
const flags = (m.block ? 1 : 0) | (m.hash ? 2 : 0) | (m.seek ? 4 : 0) | (m.upgrade ? 8 : 0)
|
|
108
|
+
|
|
109
|
+
c.uint.encode(state, flags)
|
|
110
|
+
c.uint.encode(state, m.id)
|
|
111
|
+
c.uint.encode(state, m.fork)
|
|
112
|
+
|
|
113
|
+
if (m.block) requestBlock.encode(state, m.block)
|
|
114
|
+
if (m.hash) requestBlock.encode(state, m.hash)
|
|
115
|
+
if (m.seek) requestSeek.encode(state, m.seek)
|
|
116
|
+
if (m.upgrade) requestUpgrade.encode(state, m.upgrade)
|
|
117
|
+
},
|
|
118
|
+
decode (state) {
|
|
119
|
+
const flags = c.uint.decode(state)
|
|
120
|
+
|
|
121
|
+
return {
|
|
122
|
+
id: c.uint.decode(state),
|
|
123
|
+
fork: c.uint.decode(state),
|
|
124
|
+
block: flags & 1 ? requestBlock.decode(state) : null,
|
|
125
|
+
hash: flags & 2 ? requestBlock.decode(state) : null,
|
|
126
|
+
seek: flags & 4 ? requestSeek.decode(state) : null,
|
|
127
|
+
upgrade: flags & 8 ? requestUpgrade.decode(state) : null
|
|
128
|
+
}
|
|
129
|
+
}
|
|
130
|
+
}
|
|
131
|
+
|
|
132
|
+
wire.cancel = {
|
|
133
|
+
preencode (state, m) {
|
|
134
|
+
c.uint.preencode(state, m.request)
|
|
135
|
+
},
|
|
136
|
+
encode (state, m) {
|
|
137
|
+
c.uint.encode(state, m.request)
|
|
138
|
+
},
|
|
139
|
+
decode (state, m) {
|
|
140
|
+
return {
|
|
141
|
+
request: c.uint.decode(state)
|
|
142
|
+
}
|
|
143
|
+
}
|
|
144
|
+
}
|
|
145
|
+
|
|
25
146
|
const dataUpgrade = {
|
|
26
147
|
preencode (state, u) {
|
|
27
148
|
c.uint.preencode(state, u.start)
|
|
@@ -79,268 +200,214 @@ const dataBlock = {
|
|
|
79
200
|
decode (state) {
|
|
80
201
|
return {
|
|
81
202
|
index: c.uint.decode(state),
|
|
82
|
-
value: c.buffer.decode(state),
|
|
203
|
+
value: c.buffer.decode(state) || EMPTY,
|
|
83
204
|
nodes: nodeArray.decode(state)
|
|
84
205
|
}
|
|
85
206
|
}
|
|
86
207
|
}
|
|
87
208
|
|
|
88
|
-
|
|
89
|
-
preencode (state, d) {
|
|
90
|
-
c.uint.preencode(state, d.fork)
|
|
91
|
-
state.end++ // flags
|
|
92
|
-
if (d.block) dataBlock.preencode(state, d.block)
|
|
93
|
-
if (d.seek) dataSeek.preencode(state, d.seek)
|
|
94
|
-
if (d.upgrade) dataUpgrade.preencode(state, d.upgrade)
|
|
95
|
-
},
|
|
96
|
-
encode (state, d) {
|
|
97
|
-
c.uint.encode(state, d.fork)
|
|
98
|
-
|
|
99
|
-
const s = state.start++
|
|
100
|
-
let flags = 0
|
|
101
|
-
|
|
102
|
-
if (d.block) {
|
|
103
|
-
flags |= 1
|
|
104
|
-
dataBlock.encode(state, d.block)
|
|
105
|
-
}
|
|
106
|
-
if (d.seek) {
|
|
107
|
-
flags |= 2
|
|
108
|
-
dataSeek.encode(state, d.seek)
|
|
109
|
-
}
|
|
110
|
-
if (d.upgrade) {
|
|
111
|
-
flags |= 4
|
|
112
|
-
dataUpgrade.encode(state, d.upgrade)
|
|
113
|
-
}
|
|
114
|
-
|
|
115
|
-
state.buffer[s] = flags
|
|
116
|
-
},
|
|
117
|
-
decode (state) {
|
|
118
|
-
const fork = c.uint.decode(state)
|
|
119
|
-
const flags = c.uint.decode(state)
|
|
120
|
-
return {
|
|
121
|
-
fork,
|
|
122
|
-
block: (flags & 1) === 0 ? null : dataBlock.decode(state),
|
|
123
|
-
seek: (flags & 2) === 0 ? null : dataSeek.decode(state),
|
|
124
|
-
upgrade: (flags & 4) === 0 ? null : dataUpgrade.decode(state)
|
|
125
|
-
}
|
|
126
|
-
}
|
|
127
|
-
}
|
|
128
|
-
|
|
129
|
-
const requestBlock = {
|
|
209
|
+
const dataHash = {
|
|
130
210
|
preencode (state, b) {
|
|
131
211
|
c.uint.preencode(state, b.index)
|
|
132
|
-
|
|
133
|
-
c.uint.preencode(state, b.nodes)
|
|
212
|
+
nodeArray.preencode(state, b.nodes)
|
|
134
213
|
},
|
|
135
214
|
encode (state, b) {
|
|
136
215
|
c.uint.encode(state, b.index)
|
|
137
|
-
|
|
138
|
-
c.uint.encode(state, b.nodes)
|
|
216
|
+
nodeArray.encode(state, b.nodes)
|
|
139
217
|
},
|
|
140
218
|
decode (state) {
|
|
141
219
|
return {
|
|
142
220
|
index: c.uint.decode(state),
|
|
143
|
-
|
|
144
|
-
nodes: c.uint.decode(state)
|
|
221
|
+
nodes: nodeArray.decode(state)
|
|
145
222
|
}
|
|
146
223
|
}
|
|
147
224
|
}
|
|
148
225
|
|
|
149
|
-
|
|
150
|
-
preencode (state,
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
c.uint.encode(state, s.bytes)
|
|
155
|
-
},
|
|
156
|
-
decode (state) {
|
|
157
|
-
return {
|
|
158
|
-
bytes: c.uint.decode(state)
|
|
159
|
-
}
|
|
160
|
-
}
|
|
161
|
-
}
|
|
226
|
+
wire.data = {
|
|
227
|
+
preencode (state, m) {
|
|
228
|
+
state.end++ // flags
|
|
229
|
+
c.uint.preencode(state, m.request)
|
|
230
|
+
c.uint.preencode(state, m.fork)
|
|
162
231
|
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
232
|
+
if (m.block) dataBlock.preencode(state, m.block)
|
|
233
|
+
if (m.hash) dataHash.preencode(state, m.hash)
|
|
234
|
+
if (m.seek) dataSeek.preencode(state, m.seek)
|
|
235
|
+
if (m.upgrade) dataUpgrade.preencode(state, m.upgrade)
|
|
167
236
|
},
|
|
168
|
-
encode (state,
|
|
169
|
-
|
|
170
|
-
|
|
237
|
+
encode (state, m) {
|
|
238
|
+
const flags = (m.block ? 1 : 0) | (m.hash ? 2 : 0) | (m.seek ? 4 : 0) | (m.upgrade ? 8 : 0)
|
|
239
|
+
|
|
240
|
+
c.uint.encode(state, flags)
|
|
241
|
+
c.uint.encode(state, m.request)
|
|
242
|
+
c.uint.encode(state, m.fork)
|
|
243
|
+
|
|
244
|
+
if (m.block) dataBlock.encode(state, m.block)
|
|
245
|
+
if (m.hash) dataHash.encode(state, m.hash)
|
|
246
|
+
if (m.seek) dataSeek.encode(state, m.seek)
|
|
247
|
+
if (m.upgrade) dataUpgrade.encode(state, m.upgrade)
|
|
171
248
|
},
|
|
172
249
|
decode (state) {
|
|
250
|
+
const flags = c.uint.decode(state)
|
|
251
|
+
|
|
173
252
|
return {
|
|
174
|
-
|
|
175
|
-
|
|
253
|
+
request: c.uint.decode(state),
|
|
254
|
+
fork: c.uint.decode(state),
|
|
255
|
+
block: flags & 1 ? dataBlock.decode(state) : null,
|
|
256
|
+
hash: flags & 2 ? dataHash.decode(state) : null,
|
|
257
|
+
seek: flags & 4 ? dataSeek.decode(state) : null,
|
|
258
|
+
upgrade: flags & 8 ? dataUpgrade.decode(state) : null
|
|
176
259
|
}
|
|
177
260
|
}
|
|
178
261
|
}
|
|
179
262
|
|
|
180
|
-
|
|
181
|
-
preencode (state,
|
|
182
|
-
c.uint.preencode(state,
|
|
183
|
-
state.end++ // flags
|
|
184
|
-
if (r.block) requestBlock.preencode(state, r.block)
|
|
185
|
-
if (r.seek) requestSeek.preencode(state, r.seek)
|
|
186
|
-
if (r.upgrade) requestUpgrade.preencode(state, r.upgrade)
|
|
263
|
+
wire.noData = {
|
|
264
|
+
preencode (state, m) {
|
|
265
|
+
c.uint.preencode(state, m.request)
|
|
187
266
|
},
|
|
188
|
-
encode (state,
|
|
189
|
-
c.uint.encode(state,
|
|
190
|
-
|
|
191
|
-
const s = state.start++
|
|
192
|
-
let flags = 0
|
|
193
|
-
|
|
194
|
-
if (r.block) {
|
|
195
|
-
flags |= 1
|
|
196
|
-
requestBlock.encode(state, r.block)
|
|
197
|
-
}
|
|
198
|
-
if (r.seek) {
|
|
199
|
-
flags |= 2
|
|
200
|
-
requestSeek.encode(state, r.seek)
|
|
201
|
-
}
|
|
202
|
-
if (r.upgrade) {
|
|
203
|
-
flags |= 4
|
|
204
|
-
requestUpgrade.encode(state, r.upgrade)
|
|
205
|
-
}
|
|
206
|
-
|
|
207
|
-
state.buffer[s] = flags
|
|
267
|
+
encode (state, m) {
|
|
268
|
+
c.uint.encode(state, m.request)
|
|
208
269
|
},
|
|
209
|
-
decode (state) {
|
|
210
|
-
const fork = c.uint.decode(state)
|
|
211
|
-
const flags = c.uint.decode(state)
|
|
270
|
+
decode (state, m) {
|
|
212
271
|
return {
|
|
213
|
-
|
|
214
|
-
block: (flags & 1) === 0 ? null : requestBlock.decode(state),
|
|
215
|
-
seek: (flags & 2) === 0 ? null : requestSeek.decode(state),
|
|
216
|
-
upgrade: (flags & 4) === 0 ? null : requestUpgrade.decode(state)
|
|
272
|
+
request: c.uint.decode(state)
|
|
217
273
|
}
|
|
218
274
|
}
|
|
219
275
|
}
|
|
220
276
|
|
|
221
|
-
|
|
222
|
-
preencode (state,
|
|
223
|
-
c.uint.preencode(state,
|
|
224
|
-
|
|
277
|
+
wire.want = {
|
|
278
|
+
preencode (state, m) {
|
|
279
|
+
c.uint.preencode(state, m.start)
|
|
280
|
+
c.uint.preencode(state, m.length)
|
|
225
281
|
},
|
|
226
|
-
encode (state,
|
|
227
|
-
c.uint.encode(state,
|
|
228
|
-
|
|
282
|
+
encode (state, m) {
|
|
283
|
+
c.uint.encode(state, m.start)
|
|
284
|
+
c.uint.encode(state, m.length)
|
|
229
285
|
},
|
|
230
286
|
decode (state) {
|
|
231
287
|
return {
|
|
232
288
|
start: c.uint.decode(state),
|
|
233
|
-
length:
|
|
289
|
+
length: c.uint.decode(state)
|
|
234
290
|
}
|
|
235
291
|
}
|
|
236
292
|
}
|
|
237
293
|
|
|
238
|
-
|
|
239
|
-
preencode (state,
|
|
240
|
-
c.uint.preencode(state,
|
|
241
|
-
c.
|
|
294
|
+
wire.unwant = {
|
|
295
|
+
preencode (state, m) {
|
|
296
|
+
c.uint.preencode(state, m.start)
|
|
297
|
+
c.uint.preencode(state, m.length)
|
|
242
298
|
},
|
|
243
|
-
encode (state,
|
|
244
|
-
c.uint.encode(state,
|
|
245
|
-
c.
|
|
299
|
+
encode (state, m) {
|
|
300
|
+
c.uint.encode(state, m.start)
|
|
301
|
+
c.uint.encode(state, m.length)
|
|
246
302
|
},
|
|
247
|
-
decode (state) {
|
|
303
|
+
decode (state, m) {
|
|
248
304
|
return {
|
|
249
305
|
start: c.uint.decode(state),
|
|
250
|
-
|
|
306
|
+
length: c.uint.decode(state)
|
|
251
307
|
}
|
|
252
308
|
}
|
|
253
309
|
}
|
|
254
310
|
|
|
255
|
-
|
|
256
|
-
preencode (state,
|
|
257
|
-
|
|
258
|
-
c.uint.preencode(state,
|
|
259
|
-
c.uint.preencode(state,
|
|
311
|
+
wire.range = {
|
|
312
|
+
preencode (state, m) {
|
|
313
|
+
state.end++ // flags
|
|
314
|
+
c.uint.preencode(state, m.start)
|
|
315
|
+
if (m.length !== 1) c.uint.preencode(state, m.length)
|
|
260
316
|
},
|
|
261
|
-
encode (state,
|
|
262
|
-
c.uint.encode(state,
|
|
263
|
-
c.uint.encode(state,
|
|
264
|
-
c.uint.encode(state,
|
|
317
|
+
encode (state, m) {
|
|
318
|
+
c.uint.encode(state, (m.drop ? 1 : 0) | (m.length === 1 ? 2 : 0))
|
|
319
|
+
c.uint.encode(state, m.start)
|
|
320
|
+
if (m.length !== 1) c.uint.encode(state, m.length)
|
|
265
321
|
},
|
|
266
322
|
decode (state) {
|
|
267
|
-
const i = {
|
|
268
|
-
length: c.uint.decode(state),
|
|
269
|
-
fork: c.uint.decode(state),
|
|
270
|
-
uploading: true,
|
|
271
|
-
downloading: true
|
|
272
|
-
}
|
|
273
|
-
if (state.end <= state.start) return i // backwards compat with prev alphas
|
|
274
323
|
const flags = c.uint.decode(state)
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
324
|
+
|
|
325
|
+
return {
|
|
326
|
+
drop: (flags & 1) !== 0,
|
|
327
|
+
start: c.uint.decode(state),
|
|
328
|
+
length: (flags & 2) !== 0 ? 1 : c.uint.decode(state)
|
|
329
|
+
}
|
|
278
330
|
}
|
|
279
331
|
}
|
|
280
332
|
|
|
281
|
-
|
|
282
|
-
preencode (state,
|
|
283
|
-
c.uint.preencode(state,
|
|
284
|
-
c.
|
|
333
|
+
wire.bitfield = {
|
|
334
|
+
preencode (state, m) {
|
|
335
|
+
c.uint.preencode(state, m.start)
|
|
336
|
+
c.uint32array.preencode(state, m.bitfield)
|
|
285
337
|
},
|
|
286
|
-
encode (state,
|
|
287
|
-
c.uint.encode(state,
|
|
288
|
-
c.
|
|
338
|
+
encode (state, m) {
|
|
339
|
+
c.uint.encode(state, m.start)
|
|
340
|
+
c.uint32array.encode(state, m.bitfield)
|
|
289
341
|
},
|
|
290
|
-
decode (state) {
|
|
342
|
+
decode (state, m) {
|
|
291
343
|
return {
|
|
292
|
-
|
|
293
|
-
|
|
344
|
+
start: c.uint.decode(state),
|
|
345
|
+
bitfield: c.uint32array.decode(state)
|
|
294
346
|
}
|
|
295
347
|
}
|
|
296
348
|
}
|
|
297
349
|
|
|
298
|
-
|
|
299
|
-
preencode (state,
|
|
300
|
-
|
|
301
|
-
c.
|
|
350
|
+
wire.sync = {
|
|
351
|
+
preencode (state, m) {
|
|
352
|
+
state.end++ // flags
|
|
353
|
+
c.uint.preencode(state, m.fork)
|
|
354
|
+
c.uint.preencode(state, m.length)
|
|
355
|
+
c.uint.preencode(state, m.remoteLength)
|
|
302
356
|
},
|
|
303
|
-
encode (state,
|
|
304
|
-
c.uint.encode(state,
|
|
305
|
-
c.
|
|
357
|
+
encode (state, m) {
|
|
358
|
+
c.uint.encode(state, (m.canUpgrade ? 1 : 0) | (m.uploading ? 2 : 0) | (m.downloading ? 4 : 0))
|
|
359
|
+
c.uint.encode(state, m.fork)
|
|
360
|
+
c.uint.encode(state, m.length)
|
|
361
|
+
c.uint.encode(state, m.remoteLength)
|
|
306
362
|
},
|
|
307
363
|
decode (state) {
|
|
364
|
+
const flags = c.uint.decode(state)
|
|
365
|
+
|
|
308
366
|
return {
|
|
309
|
-
|
|
310
|
-
|
|
367
|
+
fork: c.uint.decode(state),
|
|
368
|
+
length: c.uint.decode(state),
|
|
369
|
+
remoteLength: c.uint.decode(state),
|
|
370
|
+
canUpgrade: (flags & 1) !== 0,
|
|
371
|
+
uploading: (flags & 2) !== 0,
|
|
372
|
+
downloading: (flags & 4) !== 0
|
|
311
373
|
}
|
|
312
374
|
}
|
|
313
375
|
}
|
|
314
376
|
|
|
315
|
-
|
|
377
|
+
wire.reorgHint = {
|
|
316
378
|
preencode (state, m) {
|
|
317
|
-
c.uint.preencode(state, m.
|
|
318
|
-
c.
|
|
319
|
-
c.
|
|
379
|
+
c.uint.preencode(state, m.from)
|
|
380
|
+
c.uint.preencode(state, m.to)
|
|
381
|
+
c.uint.preencode(state, m.ancestors)
|
|
320
382
|
},
|
|
321
383
|
encode (state, m) {
|
|
322
|
-
c.uint.encode(state, m.
|
|
323
|
-
c.
|
|
324
|
-
c.
|
|
384
|
+
c.uint.encode(state, m.from)
|
|
385
|
+
c.uint.encode(state, m.to)
|
|
386
|
+
c.uint.encode(state, m.ancestors)
|
|
325
387
|
},
|
|
326
388
|
decode (state) {
|
|
327
389
|
return {
|
|
328
|
-
|
|
329
|
-
|
|
330
|
-
|
|
390
|
+
from: c.uint.encode(state),
|
|
391
|
+
to: c.uint.encode(state),
|
|
392
|
+
ancestors: c.uint.encode(state)
|
|
331
393
|
}
|
|
332
394
|
}
|
|
333
395
|
}
|
|
334
396
|
|
|
335
|
-
|
|
397
|
+
wire.extension = {
|
|
336
398
|
preencode (state, m) {
|
|
337
|
-
c.
|
|
399
|
+
c.string.preencode(state, m.name)
|
|
400
|
+
c.raw.preencode(state, m.message)
|
|
338
401
|
},
|
|
339
402
|
encode (state, m) {
|
|
340
|
-
c.
|
|
403
|
+
c.string.encode(state, m.name)
|
|
404
|
+
c.raw.encode(state, m.message)
|
|
341
405
|
},
|
|
342
406
|
decode (state) {
|
|
343
|
-
return {
|
|
407
|
+
return {
|
|
408
|
+
name: c.string.decode(state),
|
|
409
|
+
message: c.raw.decode(state)
|
|
410
|
+
}
|
|
344
411
|
}
|
|
345
412
|
}
|
|
346
413
|
|
|
@@ -405,7 +472,9 @@ const bitfieldUpdate = { // TODO: can maybe be folded into a HAVE later on with
|
|
|
405
472
|
}
|
|
406
473
|
}
|
|
407
474
|
|
|
408
|
-
exports.
|
|
475
|
+
const oplog = exports.oplog = {}
|
|
476
|
+
|
|
477
|
+
oplog.entry = {
|
|
409
478
|
preencode (state, m) {
|
|
410
479
|
state.end++ // flags
|
|
411
480
|
if (m.userData) keyValue.preencode(state, m.userData)
|
|
@@ -545,7 +614,7 @@ const types = {
|
|
|
545
614
|
|
|
546
615
|
const keyValueArray = c.array(keyValue)
|
|
547
616
|
|
|
548
|
-
|
|
617
|
+
oplog.header = {
|
|
549
618
|
preencode (state, h) {
|
|
550
619
|
state.end += 1 // version
|
|
551
620
|
types.preencode(state, h.types)
|