web-dc-api 0.0.87 → 0.0.89

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.
Files changed (142) hide show
  1. package/dist/cjs/index.js +1 -0
  2. package/dist/cjs/protobuf-BVBdi7Hh.js +1 -0
  3. package/dist/dc.min.js +1 -19
  4. package/dist/esm/chunks/protobuf-CbxDm-Gy.js +1 -0
  5. package/dist/esm/index.js +1 -0
  6. package/dist/index.d.ts +947 -886
  7. package/package.json +14 -17
  8. package/dist/index.cjs.js +0 -19
  9. package/dist/index.esm.js +0 -19
  10. package/lib/common/blowfish/block.ts +0 -259
  11. package/lib/common/blowfish/cipher.ts +0 -144
  12. package/lib/common/blowfish/const.ts +0 -195
  13. package/lib/common/chain.ts +0 -469
  14. package/lib/common/commonclient.ts +0 -202
  15. package/lib/common/constants.ts +0 -55
  16. package/lib/common/dc-key/ed25519.ts +0 -343
  17. package/lib/common/dc-key/keyManager.ts +0 -424
  18. package/lib/common/dcapi.ts +0 -98
  19. package/lib/common/dcutil.ts +0 -595
  20. package/lib/common/define.ts +0 -66
  21. package/lib/common/error.ts +0 -67
  22. package/lib/common/grpc-dc.ts +0 -104
  23. package/lib/common/module-system.ts +0 -184
  24. package/lib/common/service-worker.ts +0 -234
  25. package/lib/common/types/types.ts +0 -344
  26. package/lib/dc.ts +0 -694
  27. package/lib/implements/account/client.ts +0 -185
  28. package/lib/implements/account/manager.ts +0 -683
  29. package/lib/implements/aiproxy/client.ts +0 -357
  30. package/lib/implements/aiproxy/manager.ts +0 -670
  31. package/lib/implements/cache/client.ts +0 -105
  32. package/lib/implements/cache/manager.ts +0 -127
  33. package/lib/implements/comment/client.ts +0 -982
  34. package/lib/implements/comment/manager.ts +0 -1151
  35. package/lib/implements/dc/client.ts +0 -51
  36. package/lib/implements/dc/manager.ts +0 -33
  37. package/lib/implements/file/client.ts +0 -253
  38. package/lib/implements/file/file-cache-manager.ts +0 -142
  39. package/lib/implements/file/manager.ts +0 -1240
  40. package/lib/implements/file/seekableFileStream.ts +0 -344
  41. package/lib/implements/file/streamwriter.ts +0 -322
  42. package/lib/implements/keyvalue/client.ts +0 -376
  43. package/lib/implements/keyvalue/manager.ts +0 -759
  44. package/lib/implements/message/client.ts +0 -250
  45. package/lib/implements/message/manager.ts +0 -215
  46. package/lib/implements/threaddb/cbor/coding.ts +0 -62
  47. package/lib/implements/threaddb/cbor/event.ts +0 -336
  48. package/lib/implements/threaddb/cbor/node.ts +0 -542
  49. package/lib/implements/threaddb/cbor/record.ts +0 -398
  50. package/lib/implements/threaddb/common/AsyncMutex.ts +0 -24
  51. package/lib/implements/threaddb/common/addrinfo.ts +0 -135
  52. package/lib/implements/threaddb/common/dispatcher.ts +0 -81
  53. package/lib/implements/threaddb/common/idbstore-adapter.ts +0 -260
  54. package/lib/implements/threaddb/common/json-patcher.ts +0 -204
  55. package/lib/implements/threaddb/common/key.ts +0 -290
  56. package/lib/implements/threaddb/common/level-adapter.ts +0 -235
  57. package/lib/implements/threaddb/common/lineReader.ts +0 -79
  58. package/lib/implements/threaddb/common/logstore.ts +0 -215
  59. package/lib/implements/threaddb/common/transformed-datastore.ts +0 -308
  60. package/lib/implements/threaddb/core/app.ts +0 -202
  61. package/lib/implements/threaddb/core/core.ts +0 -230
  62. package/lib/implements/threaddb/core/db.ts +0 -249
  63. package/lib/implements/threaddb/core/event.ts +0 -54
  64. package/lib/implements/threaddb/core/head.ts +0 -89
  65. package/lib/implements/threaddb/core/identity.ts +0 -171
  66. package/lib/implements/threaddb/core/logstore.ts +0 -137
  67. package/lib/implements/threaddb/core/options.ts +0 -14
  68. package/lib/implements/threaddb/core/record.ts +0 -54
  69. package/lib/implements/threaddb/db/collection.ts +0 -1910
  70. package/lib/implements/threaddb/db/db.ts +0 -698
  71. package/lib/implements/threaddb/db/json2Query.ts +0 -192
  72. package/lib/implements/threaddb/db/query.ts +0 -524
  73. package/lib/implements/threaddb/dbclient.ts +0 -443
  74. package/lib/implements/threaddb/dbmanager.ts +0 -1901
  75. package/lib/implements/threaddb/lsstoreds/addr_book.ts +0 -452
  76. package/lib/implements/threaddb/lsstoreds/cache.ts +0 -36
  77. package/lib/implements/threaddb/lsstoreds/cyclic_batch.ts +0 -87
  78. package/lib/implements/threaddb/lsstoreds/global.ts +0 -151
  79. package/lib/implements/threaddb/lsstoreds/headbook.ts +0 -280
  80. package/lib/implements/threaddb/lsstoreds/keybook.ts +0 -297
  81. package/lib/implements/threaddb/lsstoreds/logstore.ts +0 -29
  82. package/lib/implements/threaddb/lsstoreds/metadata.ts +0 -223
  83. package/lib/implements/threaddb/net/define.ts +0 -138
  84. package/lib/implements/threaddb/net/grpcClient.ts +0 -582
  85. package/lib/implements/threaddb/net/grpcserver.ts +0 -146
  86. package/lib/implements/threaddb/net/net.ts +0 -2006
  87. package/lib/implements/threaddb/pb/lstore.proto +0 -38
  88. package/lib/implements/threaddb/pb/lstore.ts +0 -393
  89. package/lib/implements/threaddb/pb/lstore_pb.d.ts +0 -433
  90. package/lib/implements/threaddb/pb/lstore_pb.js +0 -1085
  91. package/lib/implements/threaddb/pb/net.proto +0 -194
  92. package/lib/implements/threaddb/pb/net_pb.d.ts +0 -2349
  93. package/lib/implements/threaddb/pb/net_pb.js +0 -5525
  94. package/lib/implements/threaddb/pb/proto-custom-types.ts +0 -212
  95. package/lib/implements/util/client.ts +0 -72
  96. package/lib/implements/util/manager.ts +0 -146
  97. package/lib/implements/wallet/manager.ts +0 -664
  98. package/lib/index.ts +0 -57
  99. package/lib/interfaces/DCContext.ts +0 -51
  100. package/lib/interfaces/aiproxy-interface.ts +0 -145
  101. package/lib/interfaces/auth-interface.ts +0 -118
  102. package/lib/interfaces/cache-interface.ts +0 -22
  103. package/lib/interfaces/client-interface.ts +0 -11
  104. package/lib/interfaces/comment-interface.ts +0 -167
  105. package/lib/interfaces/database-interface.ts +0 -169
  106. package/lib/interfaces/file-interface.ts +0 -120
  107. package/lib/interfaces/index.ts +0 -10
  108. package/lib/interfaces/keyvalue-interface.ts +0 -156
  109. package/lib/interfaces/message-interface.ts +0 -22
  110. package/lib/interfaces/util-interface.ts +0 -31
  111. package/lib/modules/aiproxy-module.ts +0 -246
  112. package/lib/modules/auth-module.ts +0 -753
  113. package/lib/modules/cache-module.ts +0 -99
  114. package/lib/modules/client-module.ts +0 -71
  115. package/lib/modules/comment-module.ts +0 -429
  116. package/lib/modules/database-module.ts +0 -598
  117. package/lib/modules/file-module.ts +0 -291
  118. package/lib/modules/index.ts +0 -13
  119. package/lib/modules/keyvalue-module.ts +0 -379
  120. package/lib/modules/message-module.ts +0 -107
  121. package/lib/modules/util-module.ts +0 -148
  122. package/lib/polyfills/process-env-browser.ts +0 -1
  123. package/lib/proto/datasource.ts +0 -93
  124. package/lib/proto/dcnet.proto +0 -1601
  125. package/lib/proto/dcnet_proto.d.ts +0 -22857
  126. package/lib/proto/dcnet_proto.js +0 -55204
  127. package/lib/proto/dcnet_proto_sparse.js +0 -55166
  128. package/lib/proto/oidfetch.proto +0 -25
  129. package/lib/proto/oidfetch_proto.d.ts +0 -585
  130. package/lib/proto/oidfetch_proto.js +0 -1247
  131. package/lib/serverless/babel-browser.ts +0 -39
  132. package/lib/serverless/base_entity.ts +0 -78
  133. package/lib/serverless/base_repository.ts +0 -414
  134. package/lib/serverless/browser_schema_extractor.ts +0 -283
  135. package/lib/serverless/decorator_factory.ts +0 -322
  136. package/lib/util/BrowserLineReader.ts +0 -73
  137. package/lib/util/base64.ts +0 -105
  138. package/lib/util/bcrypt.ts +0 -206
  139. package/lib/util/curve25519Encryption.ts +0 -418
  140. package/lib/util/dccrypt.ts +0 -73
  141. package/lib/util/logger.ts +0 -104
  142. package/lib/util/utils.ts +0 -289
@@ -1,1085 +0,0 @@
1
- /*eslint-disable block-scoped-var, id-length, no-control-regex, no-magic-numbers, no-prototype-builtins, no-redeclare, no-shadow, no-var, sort-vars*/
2
- import * as $protobuf from "protobufjs/minimal";
3
-
4
- // Common aliases
5
- const $Reader = $protobuf.Reader, $Writer = $protobuf.Writer, $util = $protobuf.util;
6
-
7
- // Exported root namespace
8
- const $root = $protobuf.roots["default"] || ($protobuf.roots["default"] = {});
9
-
10
- export const net = $root.net = (() => {
11
-
12
- /**
13
- * Namespace net.
14
- * @exports net
15
- * @namespace
16
- */
17
- const net = {};
18
-
19
- net.pb = (function() {
20
-
21
- /**
22
- * Namespace pb.
23
- * @memberof net
24
- * @namespace
25
- */
26
- const pb = {};
27
-
28
- pb.AddrBookRecord = (function() {
29
-
30
- /**
31
- * Properties of an AddrBookRecord.
32
- * @memberof net.pb
33
- * @interface IAddrBookRecord
34
- * @property {Uint8Array|null} [threadID] AddrBookRecord threadID
35
- * @property {Uint8Array|null} [peerID] AddrBookRecord peerID
36
- * @property {Array.<net.pb.AddrBookRecord.IAddrEntry>|null} [addrs] AddrBookRecord addrs
37
- */
38
-
39
- /**
40
- * Constructs a new AddrBookRecord.
41
- * @memberof net.pb
42
- * @classdesc Represents an AddrBookRecord.
43
- * @implements IAddrBookRecord
44
- * @constructor
45
- * @param {net.pb.IAddrBookRecord=} [properties] Properties to set
46
- */
47
- function AddrBookRecord(properties) {
48
- this.addrs = [];
49
- if (properties)
50
- for (let keys = Object.keys(properties), i = 0; i < keys.length; ++i)
51
- if (properties[keys[i]] != null)
52
- this[keys[i]] = properties[keys[i]];
53
- }
54
-
55
- /**
56
- * AddrBookRecord threadID.
57
- * @member {Uint8Array} threadID
58
- * @memberof net.pb.AddrBookRecord
59
- * @instance
60
- */
61
- AddrBookRecord.prototype.threadID = $util.newBuffer([]);
62
-
63
- /**
64
- * AddrBookRecord peerID.
65
- * @member {Uint8Array} peerID
66
- * @memberof net.pb.AddrBookRecord
67
- * @instance
68
- */
69
- AddrBookRecord.prototype.peerID = $util.newBuffer([]);
70
-
71
- /**
72
- * AddrBookRecord addrs.
73
- * @member {Array.<net.pb.AddrBookRecord.IAddrEntry>} addrs
74
- * @memberof net.pb.AddrBookRecord
75
- * @instance
76
- */
77
- AddrBookRecord.prototype.addrs = $util.emptyArray;
78
-
79
- /**
80
- * Creates a new AddrBookRecord instance using the specified properties.
81
- * @function create
82
- * @memberof net.pb.AddrBookRecord
83
- * @static
84
- * @param {net.pb.IAddrBookRecord=} [properties] Properties to set
85
- * @returns {net.pb.AddrBookRecord} AddrBookRecord instance
86
- */
87
- AddrBookRecord.create = function create(properties) {
88
- return new AddrBookRecord(properties);
89
- };
90
-
91
- /**
92
- * Encodes the specified AddrBookRecord message. Does not implicitly {@link net.pb.AddrBookRecord.verify|verify} messages.
93
- * @function encode
94
- * @memberof net.pb.AddrBookRecord
95
- * @static
96
- * @param {net.pb.IAddrBookRecord} message AddrBookRecord message or plain object to encode
97
- * @param {$protobuf.Writer} [writer] Writer to encode to
98
- * @returns {$protobuf.Writer} Writer
99
- */
100
- AddrBookRecord.encode = function encode(message, writer) {
101
- if (!writer)
102
- writer = $Writer.create();
103
- if (message.threadID != null && Object.hasOwnProperty.call(message, "threadID"))
104
- writer.uint32(/* id 1, wireType 2 =*/10).bytes(message.threadID);
105
- if (message.peerID != null && Object.hasOwnProperty.call(message, "peerID"))
106
- writer.uint32(/* id 2, wireType 2 =*/18).bytes(message.peerID);
107
- if (message.addrs != null && message.addrs.length)
108
- for (let i = 0; i < message.addrs.length; ++i)
109
- $root.net.pb.AddrBookRecord.AddrEntry.encode(message.addrs[i], writer.uint32(/* id 3, wireType 2 =*/26).fork()).ldelim();
110
- return writer;
111
- };
112
-
113
- /**
114
- * Encodes the specified AddrBookRecord message, length delimited. Does not implicitly {@link net.pb.AddrBookRecord.verify|verify} messages.
115
- * @function encodeDelimited
116
- * @memberof net.pb.AddrBookRecord
117
- * @static
118
- * @param {net.pb.IAddrBookRecord} message AddrBookRecord message or plain object to encode
119
- * @param {$protobuf.Writer} [writer] Writer to encode to
120
- * @returns {$protobuf.Writer} Writer
121
- */
122
- AddrBookRecord.encodeDelimited = function encodeDelimited(message, writer) {
123
- return this.encode(message, writer).ldelim();
124
- };
125
-
126
- /**
127
- * Decodes an AddrBookRecord message from the specified reader or buffer.
128
- * @function decode
129
- * @memberof net.pb.AddrBookRecord
130
- * @static
131
- * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from
132
- * @param {number} [length] Message length if known beforehand
133
- * @returns {net.pb.AddrBookRecord} AddrBookRecord
134
- * @throws {Error} If the payload is not a reader or valid buffer
135
- * @throws {$protobuf.util.ProtocolError} If required fields are missing
136
- */
137
- AddrBookRecord.decode = function decode(reader, length) {
138
- if (!(reader instanceof $Reader))
139
- reader = $Reader.create(reader);
140
- let end = length === undefined ? reader.len : reader.pos + length, message = new $root.net.pb.AddrBookRecord();
141
- while (reader.pos < end) {
142
- let tag = reader.uint32();
143
- switch (tag >>> 3) {
144
- case 1: {
145
- message.threadID = reader.bytes();
146
- break;
147
- }
148
- case 2: {
149
- message.peerID = reader.bytes();
150
- break;
151
- }
152
- case 3: {
153
- if (!(message.addrs && message.addrs.length))
154
- message.addrs = [];
155
- message.addrs.push($root.net.pb.AddrBookRecord.AddrEntry.decode(reader, reader.uint32()));
156
- break;
157
- }
158
- default:
159
- reader.skipType(tag & 7);
160
- break;
161
- }
162
- }
163
- return message;
164
- };
165
-
166
- /**
167
- * Decodes an AddrBookRecord message from the specified reader or buffer, length delimited.
168
- * @function decodeDelimited
169
- * @memberof net.pb.AddrBookRecord
170
- * @static
171
- * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from
172
- * @returns {net.pb.AddrBookRecord} AddrBookRecord
173
- * @throws {Error} If the payload is not a reader or valid buffer
174
- * @throws {$protobuf.util.ProtocolError} If required fields are missing
175
- */
176
- AddrBookRecord.decodeDelimited = function decodeDelimited(reader) {
177
- if (!(reader instanceof $Reader))
178
- reader = new $Reader(reader);
179
- return this.decode(reader, reader.uint32());
180
- };
181
-
182
- /**
183
- * Verifies an AddrBookRecord message.
184
- * @function verify
185
- * @memberof net.pb.AddrBookRecord
186
- * @static
187
- * @param {Object.<string,*>} message Plain object to verify
188
- * @returns {string|null} `null` if valid, otherwise the reason why it is not
189
- */
190
- AddrBookRecord.verify = function verify(message) {
191
- if (typeof message !== "object" || message === null)
192
- return "object expected";
193
- if (message.threadID != null && message.hasOwnProperty("threadID"))
194
- if (!(message.threadID && typeof message.threadID.length === "number" || $util.isString(message.threadID)))
195
- return "threadID: buffer expected";
196
- if (message.peerID != null && message.hasOwnProperty("peerID"))
197
- if (!(message.peerID && typeof message.peerID.length === "number" || $util.isString(message.peerID)))
198
- return "peerID: buffer expected";
199
- if (message.addrs != null && message.hasOwnProperty("addrs")) {
200
- if (!Array.isArray(message.addrs))
201
- return "addrs: array expected";
202
- for (let i = 0; i < message.addrs.length; ++i) {
203
- let error = $root.net.pb.AddrBookRecord.AddrEntry.verify(message.addrs[i]);
204
- if (error)
205
- return "addrs." + error;
206
- }
207
- }
208
- return null;
209
- };
210
-
211
- /**
212
- * Creates an AddrBookRecord message from a plain object. Also converts values to their respective internal types.
213
- * @function fromObject
214
- * @memberof net.pb.AddrBookRecord
215
- * @static
216
- * @param {Object.<string,*>} object Plain object
217
- * @returns {net.pb.AddrBookRecord} AddrBookRecord
218
- */
219
- AddrBookRecord.fromObject = function fromObject(object) {
220
- if (object instanceof $root.net.pb.AddrBookRecord)
221
- return object;
222
- let message = new $root.net.pb.AddrBookRecord();
223
- if (object.threadID != null)
224
- if (typeof object.threadID === "string")
225
- $util.base64.decode(object.threadID, message.threadID = $util.newBuffer($util.base64.length(object.threadID)), 0);
226
- else if (object.threadID.length >= 0)
227
- message.threadID = object.threadID;
228
- if (object.peerID != null)
229
- if (typeof object.peerID === "string")
230
- $util.base64.decode(object.peerID, message.peerID = $util.newBuffer($util.base64.length(object.peerID)), 0);
231
- else if (object.peerID.length >= 0)
232
- message.peerID = object.peerID;
233
- if (object.addrs) {
234
- if (!Array.isArray(object.addrs))
235
- throw TypeError(".net.pb.AddrBookRecord.addrs: array expected");
236
- message.addrs = [];
237
- for (let i = 0; i < object.addrs.length; ++i) {
238
- if (typeof object.addrs[i] !== "object")
239
- throw TypeError(".net.pb.AddrBookRecord.addrs: object expected");
240
- message.addrs[i] = $root.net.pb.AddrBookRecord.AddrEntry.fromObject(object.addrs[i]);
241
- }
242
- }
243
- return message;
244
- };
245
-
246
- /**
247
- * Creates a plain object from an AddrBookRecord message. Also converts values to other types if specified.
248
- * @function toObject
249
- * @memberof net.pb.AddrBookRecord
250
- * @static
251
- * @param {net.pb.AddrBookRecord} message AddrBookRecord
252
- * @param {$protobuf.IConversionOptions} [options] Conversion options
253
- * @returns {Object.<string,*>} Plain object
254
- */
255
- AddrBookRecord.toObject = function toObject(message, options) {
256
- if (!options)
257
- options = {};
258
- let object = {};
259
- if (options.arrays || options.defaults)
260
- object.addrs = [];
261
- if (options.defaults) {
262
- if (options.bytes === String)
263
- object.threadID = "";
264
- else {
265
- object.threadID = [];
266
- if (options.bytes !== Array)
267
- object.threadID = $util.newBuffer(object.threadID);
268
- }
269
- if (options.bytes === String)
270
- object.peerID = "";
271
- else {
272
- object.peerID = [];
273
- if (options.bytes !== Array)
274
- object.peerID = $util.newBuffer(object.peerID);
275
- }
276
- }
277
- if (message.threadID != null && message.hasOwnProperty("threadID"))
278
- object.threadID = options.bytes === String ? $util.base64.encode(message.threadID, 0, message.threadID.length) : options.bytes === Array ? Array.prototype.slice.call(message.threadID) : message.threadID;
279
- if (message.peerID != null && message.hasOwnProperty("peerID"))
280
- object.peerID = options.bytes === String ? $util.base64.encode(message.peerID, 0, message.peerID.length) : options.bytes === Array ? Array.prototype.slice.call(message.peerID) : message.peerID;
281
- if (message.addrs && message.addrs.length) {
282
- object.addrs = [];
283
- for (let j = 0; j < message.addrs.length; ++j)
284
- object.addrs[j] = $root.net.pb.AddrBookRecord.AddrEntry.toObject(message.addrs[j], options);
285
- }
286
- return object;
287
- };
288
-
289
- /**
290
- * Converts this AddrBookRecord to JSON.
291
- * @function toJSON
292
- * @memberof net.pb.AddrBookRecord
293
- * @instance
294
- * @returns {Object.<string,*>} JSON object
295
- */
296
- AddrBookRecord.prototype.toJSON = function toJSON() {
297
- return this.constructor.toObject(this, $protobuf.util.toJSONOptions);
298
- };
299
-
300
- /**
301
- * Gets the default type url for AddrBookRecord
302
- * @function getTypeUrl
303
- * @memberof net.pb.AddrBookRecord
304
- * @static
305
- * @param {string} [typeUrlPrefix] your custom typeUrlPrefix(default "type.googleapis.com")
306
- * @returns {string} The default type url
307
- */
308
- AddrBookRecord.getTypeUrl = function getTypeUrl(typeUrlPrefix) {
309
- if (typeUrlPrefix === undefined) {
310
- typeUrlPrefix = "type.googleapis.com";
311
- }
312
- return typeUrlPrefix + "/net.pb.AddrBookRecord";
313
- };
314
-
315
- AddrBookRecord.AddrEntry = (function() {
316
-
317
- /**
318
- * Properties of an AddrEntry.
319
- * @memberof net.pb.AddrBookRecord
320
- * @interface IAddrEntry
321
- * @property {Uint8Array|null} [addr] AddrEntry addr
322
- * @property {number|Long|null} [expiry] AddrEntry expiry
323
- * @property {number|Long|null} [ttl] AddrEntry ttl
324
- */
325
-
326
- /**
327
- * Constructs a new AddrEntry.
328
- * @memberof net.pb.AddrBookRecord
329
- * @classdesc Represents an AddrEntry.
330
- * @implements IAddrEntry
331
- * @constructor
332
- * @param {net.pb.AddrBookRecord.IAddrEntry=} [properties] Properties to set
333
- */
334
- function AddrEntry(properties) {
335
- if (properties)
336
- for (let keys = Object.keys(properties), i = 0; i < keys.length; ++i)
337
- if (properties[keys[i]] != null)
338
- this[keys[i]] = properties[keys[i]];
339
- }
340
-
341
- /**
342
- * AddrEntry addr.
343
- * @member {Uint8Array} addr
344
- * @memberof net.pb.AddrBookRecord.AddrEntry
345
- * @instance
346
- */
347
- AddrEntry.prototype.addr = $util.newBuffer([]);
348
-
349
- /**
350
- * AddrEntry expiry.
351
- * @member {number|Long} expiry
352
- * @memberof net.pb.AddrBookRecord.AddrEntry
353
- * @instance
354
- */
355
- AddrEntry.prototype.expiry = $util.Long ? $util.Long.fromBits(0,0,false) : 0;
356
-
357
- /**
358
- * AddrEntry ttl.
359
- * @member {number|Long} ttl
360
- * @memberof net.pb.AddrBookRecord.AddrEntry
361
- * @instance
362
- */
363
- AddrEntry.prototype.ttl = $util.Long ? $util.Long.fromBits(0,0,false) : 0;
364
-
365
- /**
366
- * Creates a new AddrEntry instance using the specified properties.
367
- * @function create
368
- * @memberof net.pb.AddrBookRecord.AddrEntry
369
- * @static
370
- * @param {net.pb.AddrBookRecord.IAddrEntry=} [properties] Properties to set
371
- * @returns {net.pb.AddrBookRecord.AddrEntry} AddrEntry instance
372
- */
373
- AddrEntry.create = function create(properties) {
374
- return new AddrEntry(properties);
375
- };
376
-
377
- /**
378
- * Encodes the specified AddrEntry message. Does not implicitly {@link net.pb.AddrBookRecord.AddrEntry.verify|verify} messages.
379
- * @function encode
380
- * @memberof net.pb.AddrBookRecord.AddrEntry
381
- * @static
382
- * @param {net.pb.AddrBookRecord.IAddrEntry} message AddrEntry message or plain object to encode
383
- * @param {$protobuf.Writer} [writer] Writer to encode to
384
- * @returns {$protobuf.Writer} Writer
385
- */
386
- AddrEntry.encode = function encode(message, writer) {
387
- if (!writer)
388
- writer = $Writer.create();
389
- if (message.addr != null && Object.hasOwnProperty.call(message, "addr"))
390
- writer.uint32(/* id 1, wireType 2 =*/10).bytes(message.addr);
391
- if (message.expiry != null && Object.hasOwnProperty.call(message, "expiry"))
392
- writer.uint32(/* id 2, wireType 0 =*/16).int64(message.expiry);
393
- if (message.ttl != null && Object.hasOwnProperty.call(message, "ttl"))
394
- writer.uint32(/* id 3, wireType 0 =*/24).int64(message.ttl);
395
- return writer;
396
- };
397
-
398
- /**
399
- * Encodes the specified AddrEntry message, length delimited. Does not implicitly {@link net.pb.AddrBookRecord.AddrEntry.verify|verify} messages.
400
- * @function encodeDelimited
401
- * @memberof net.pb.AddrBookRecord.AddrEntry
402
- * @static
403
- * @param {net.pb.AddrBookRecord.IAddrEntry} message AddrEntry message or plain object to encode
404
- * @param {$protobuf.Writer} [writer] Writer to encode to
405
- * @returns {$protobuf.Writer} Writer
406
- */
407
- AddrEntry.encodeDelimited = function encodeDelimited(message, writer) {
408
- return this.encode(message, writer).ldelim();
409
- };
410
-
411
- /**
412
- * Decodes an AddrEntry message from the specified reader or buffer.
413
- * @function decode
414
- * @memberof net.pb.AddrBookRecord.AddrEntry
415
- * @static
416
- * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from
417
- * @param {number} [length] Message length if known beforehand
418
- * @returns {net.pb.AddrBookRecord.AddrEntry} AddrEntry
419
- * @throws {Error} If the payload is not a reader or valid buffer
420
- * @throws {$protobuf.util.ProtocolError} If required fields are missing
421
- */
422
- AddrEntry.decode = function decode(reader, length) {
423
- if (!(reader instanceof $Reader))
424
- reader = $Reader.create(reader);
425
- let end = length === undefined ? reader.len : reader.pos + length, message = new $root.net.pb.AddrBookRecord.AddrEntry();
426
- while (reader.pos < end) {
427
- let tag = reader.uint32();
428
- switch (tag >>> 3) {
429
- case 1: {
430
- message.addr = reader.bytes();
431
- break;
432
- }
433
- case 2: {
434
- message.expiry = reader.int64();
435
- break;
436
- }
437
- case 3: {
438
- message.ttl = reader.int64();
439
- break;
440
- }
441
- default:
442
- reader.skipType(tag & 7);
443
- break;
444
- }
445
- }
446
- return message;
447
- };
448
-
449
- /**
450
- * Decodes an AddrEntry message from the specified reader or buffer, length delimited.
451
- * @function decodeDelimited
452
- * @memberof net.pb.AddrBookRecord.AddrEntry
453
- * @static
454
- * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from
455
- * @returns {net.pb.AddrBookRecord.AddrEntry} AddrEntry
456
- * @throws {Error} If the payload is not a reader or valid buffer
457
- * @throws {$protobuf.util.ProtocolError} If required fields are missing
458
- */
459
- AddrEntry.decodeDelimited = function decodeDelimited(reader) {
460
- if (!(reader instanceof $Reader))
461
- reader = new $Reader(reader);
462
- return this.decode(reader, reader.uint32());
463
- };
464
-
465
- /**
466
- * Verifies an AddrEntry message.
467
- * @function verify
468
- * @memberof net.pb.AddrBookRecord.AddrEntry
469
- * @static
470
- * @param {Object.<string,*>} message Plain object to verify
471
- * @returns {string|null} `null` if valid, otherwise the reason why it is not
472
- */
473
- AddrEntry.verify = function verify(message) {
474
- if (typeof message !== "object" || message === null)
475
- return "object expected";
476
- if (message.addr != null && message.hasOwnProperty("addr"))
477
- if (!(message.addr && typeof message.addr.length === "number" || $util.isString(message.addr)))
478
- return "addr: buffer expected";
479
- if (message.expiry != null && message.hasOwnProperty("expiry"))
480
- if (!$util.isInteger(message.expiry) && !(message.expiry && $util.isInteger(message.expiry.low) && $util.isInteger(message.expiry.high)))
481
- return "expiry: integer|Long expected";
482
- if (message.ttl != null && message.hasOwnProperty("ttl"))
483
- if (!$util.isInteger(message.ttl) && !(message.ttl && $util.isInteger(message.ttl.low) && $util.isInteger(message.ttl.high)))
484
- return "ttl: integer|Long expected";
485
- return null;
486
- };
487
-
488
- /**
489
- * Creates an AddrEntry message from a plain object. Also converts values to their respective internal types.
490
- * @function fromObject
491
- * @memberof net.pb.AddrBookRecord.AddrEntry
492
- * @static
493
- * @param {Object.<string,*>} object Plain object
494
- * @returns {net.pb.AddrBookRecord.AddrEntry} AddrEntry
495
- */
496
- AddrEntry.fromObject = function fromObject(object) {
497
- if (object instanceof $root.net.pb.AddrBookRecord.AddrEntry)
498
- return object;
499
- let message = new $root.net.pb.AddrBookRecord.AddrEntry();
500
- if (object.addr != null)
501
- if (typeof object.addr === "string")
502
- $util.base64.decode(object.addr, message.addr = $util.newBuffer($util.base64.length(object.addr)), 0);
503
- else if (object.addr.length >= 0)
504
- message.addr = object.addr;
505
- if (object.expiry != null)
506
- if ($util.Long)
507
- (message.expiry = $util.Long.fromValue(object.expiry)).unsigned = false;
508
- else if (typeof object.expiry === "string")
509
- message.expiry = parseInt(object.expiry, 10);
510
- else if (typeof object.expiry === "number")
511
- message.expiry = object.expiry;
512
- else if (typeof object.expiry === "object")
513
- message.expiry = new $util.LongBits(object.expiry.low >>> 0, object.expiry.high >>> 0).toNumber();
514
- if (object.ttl != null)
515
- if ($util.Long)
516
- (message.ttl = $util.Long.fromValue(object.ttl)).unsigned = false;
517
- else if (typeof object.ttl === "string")
518
- message.ttl = parseInt(object.ttl, 10);
519
- else if (typeof object.ttl === "number")
520
- message.ttl = object.ttl;
521
- else if (typeof object.ttl === "object")
522
- message.ttl = new $util.LongBits(object.ttl.low >>> 0, object.ttl.high >>> 0).toNumber();
523
- return message;
524
- };
525
-
526
- /**
527
- * Creates a plain object from an AddrEntry message. Also converts values to other types if specified.
528
- * @function toObject
529
- * @memberof net.pb.AddrBookRecord.AddrEntry
530
- * @static
531
- * @param {net.pb.AddrBookRecord.AddrEntry} message AddrEntry
532
- * @param {$protobuf.IConversionOptions} [options] Conversion options
533
- * @returns {Object.<string,*>} Plain object
534
- */
535
- AddrEntry.toObject = function toObject(message, options) {
536
- if (!options)
537
- options = {};
538
- let object = {};
539
- if (options.defaults) {
540
- if (options.bytes === String)
541
- object.addr = "";
542
- else {
543
- object.addr = [];
544
- if (options.bytes !== Array)
545
- object.addr = $util.newBuffer(object.addr);
546
- }
547
- if ($util.Long) {
548
- let long = new $util.Long(0, 0, false);
549
- object.expiry = options.longs === String ? long.toString() : options.longs === Number ? long.toNumber() : long;
550
- } else
551
- object.expiry = options.longs === String ? "0" : 0;
552
- if ($util.Long) {
553
- let long = new $util.Long(0, 0, false);
554
- object.ttl = options.longs === String ? long.toString() : options.longs === Number ? long.toNumber() : long;
555
- } else
556
- object.ttl = options.longs === String ? "0" : 0;
557
- }
558
- if (message.addr != null && message.hasOwnProperty("addr"))
559
- object.addr = options.bytes === String ? $util.base64.encode(message.addr, 0, message.addr.length) : options.bytes === Array ? Array.prototype.slice.call(message.addr) : message.addr;
560
- if (message.expiry != null && message.hasOwnProperty("expiry"))
561
- if (typeof message.expiry === "number")
562
- object.expiry = options.longs === String ? String(message.expiry) : message.expiry;
563
- else
564
- object.expiry = options.longs === String ? $util.Long.prototype.toString.call(message.expiry) : options.longs === Number ? new $util.LongBits(message.expiry.low >>> 0, message.expiry.high >>> 0).toNumber() : message.expiry;
565
- if (message.ttl != null && message.hasOwnProperty("ttl"))
566
- if (typeof message.ttl === "number")
567
- object.ttl = options.longs === String ? String(message.ttl) : message.ttl;
568
- else
569
- object.ttl = options.longs === String ? $util.Long.prototype.toString.call(message.ttl) : options.longs === Number ? new $util.LongBits(message.ttl.low >>> 0, message.ttl.high >>> 0).toNumber() : message.ttl;
570
- return object;
571
- };
572
-
573
- /**
574
- * Converts this AddrEntry to JSON.
575
- * @function toJSON
576
- * @memberof net.pb.AddrBookRecord.AddrEntry
577
- * @instance
578
- * @returns {Object.<string,*>} JSON object
579
- */
580
- AddrEntry.prototype.toJSON = function toJSON() {
581
- return this.constructor.toObject(this, $protobuf.util.toJSONOptions);
582
- };
583
-
584
- /**
585
- * Gets the default type url for AddrEntry
586
- * @function getTypeUrl
587
- * @memberof net.pb.AddrBookRecord.AddrEntry
588
- * @static
589
- * @param {string} [typeUrlPrefix] your custom typeUrlPrefix(default "type.googleapis.com")
590
- * @returns {string} The default type url
591
- */
592
- AddrEntry.getTypeUrl = function getTypeUrl(typeUrlPrefix) {
593
- if (typeUrlPrefix === undefined) {
594
- typeUrlPrefix = "type.googleapis.com";
595
- }
596
- return typeUrlPrefix + "/net.pb.AddrBookRecord.AddrEntry";
597
- };
598
-
599
- return AddrEntry;
600
- })();
601
-
602
- return AddrBookRecord;
603
- })();
604
-
605
- pb.HeadBookRecord = (function() {
606
-
607
- /**
608
- * Properties of a HeadBookRecord.
609
- * @memberof net.pb
610
- * @interface IHeadBookRecord
611
- * @property {Array.<net.pb.HeadBookRecord.IHeadEntry>|null} [heads] HeadBookRecord heads
612
- */
613
-
614
- /**
615
- * Constructs a new HeadBookRecord.
616
- * @memberof net.pb
617
- * @classdesc Represents a HeadBookRecord.
618
- * @implements IHeadBookRecord
619
- * @constructor
620
- * @param {net.pb.IHeadBookRecord=} [properties] Properties to set
621
- */
622
- function HeadBookRecord(properties) {
623
- this.heads = [];
624
- if (properties)
625
- for (let keys = Object.keys(properties), i = 0; i < keys.length; ++i)
626
- if (properties[keys[i]] != null)
627
- this[keys[i]] = properties[keys[i]];
628
- }
629
-
630
- /**
631
- * HeadBookRecord heads.
632
- * @member {Array.<net.pb.HeadBookRecord.IHeadEntry>} heads
633
- * @memberof net.pb.HeadBookRecord
634
- * @instance
635
- */
636
- HeadBookRecord.prototype.heads = $util.emptyArray;
637
-
638
- /**
639
- * Creates a new HeadBookRecord instance using the specified properties.
640
- * @function create
641
- * @memberof net.pb.HeadBookRecord
642
- * @static
643
- * @param {net.pb.IHeadBookRecord=} [properties] Properties to set
644
- * @returns {net.pb.HeadBookRecord} HeadBookRecord instance
645
- */
646
- HeadBookRecord.create = function create(properties) {
647
- return new HeadBookRecord(properties);
648
- };
649
-
650
- /**
651
- * Encodes the specified HeadBookRecord message. Does not implicitly {@link net.pb.HeadBookRecord.verify|verify} messages.
652
- * @function encode
653
- * @memberof net.pb.HeadBookRecord
654
- * @static
655
- * @param {net.pb.IHeadBookRecord} message HeadBookRecord message or plain object to encode
656
- * @param {$protobuf.Writer} [writer] Writer to encode to
657
- * @returns {$protobuf.Writer} Writer
658
- */
659
- HeadBookRecord.encode = function encode(message, writer) {
660
- if (!writer)
661
- writer = $Writer.create();
662
- if (message.heads != null && message.heads.length)
663
- for (let i = 0; i < message.heads.length; ++i)
664
- $root.net.pb.HeadBookRecord.HeadEntry.encode(message.heads[i], writer.uint32(/* id 1, wireType 2 =*/10).fork()).ldelim();
665
- return writer;
666
- };
667
-
668
- /**
669
- * Encodes the specified HeadBookRecord message, length delimited. Does not implicitly {@link net.pb.HeadBookRecord.verify|verify} messages.
670
- * @function encodeDelimited
671
- * @memberof net.pb.HeadBookRecord
672
- * @static
673
- * @param {net.pb.IHeadBookRecord} message HeadBookRecord message or plain object to encode
674
- * @param {$protobuf.Writer} [writer] Writer to encode to
675
- * @returns {$protobuf.Writer} Writer
676
- */
677
- HeadBookRecord.encodeDelimited = function encodeDelimited(message, writer) {
678
- return this.encode(message, writer).ldelim();
679
- };
680
-
681
- /**
682
- * Decodes a HeadBookRecord message from the specified reader or buffer.
683
- * @function decode
684
- * @memberof net.pb.HeadBookRecord
685
- * @static
686
- * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from
687
- * @param {number} [length] Message length if known beforehand
688
- * @returns {net.pb.HeadBookRecord} HeadBookRecord
689
- * @throws {Error} If the payload is not a reader or valid buffer
690
- * @throws {$protobuf.util.ProtocolError} If required fields are missing
691
- */
692
- HeadBookRecord.decode = function decode(reader, length) {
693
- if (!(reader instanceof $Reader))
694
- reader = $Reader.create(reader);
695
- let end = length === undefined ? reader.len : reader.pos + length, message = new $root.net.pb.HeadBookRecord();
696
- while (reader.pos < end) {
697
- let tag = reader.uint32();
698
- switch (tag >>> 3) {
699
- case 1: {
700
- if (!(message.heads && message.heads.length))
701
- message.heads = [];
702
- message.heads.push($root.net.pb.HeadBookRecord.HeadEntry.decode(reader, reader.uint32()));
703
- break;
704
- }
705
- default:
706
- reader.skipType(tag & 7);
707
- break;
708
- }
709
- }
710
- return message;
711
- };
712
-
713
- /**
714
- * Decodes a HeadBookRecord message from the specified reader or buffer, length delimited.
715
- * @function decodeDelimited
716
- * @memberof net.pb.HeadBookRecord
717
- * @static
718
- * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from
719
- * @returns {net.pb.HeadBookRecord} HeadBookRecord
720
- * @throws {Error} If the payload is not a reader or valid buffer
721
- * @throws {$protobuf.util.ProtocolError} If required fields are missing
722
- */
723
- HeadBookRecord.decodeDelimited = function decodeDelimited(reader) {
724
- if (!(reader instanceof $Reader))
725
- reader = new $Reader(reader);
726
- return this.decode(reader, reader.uint32());
727
- };
728
-
729
- /**
730
- * Verifies a HeadBookRecord message.
731
- * @function verify
732
- * @memberof net.pb.HeadBookRecord
733
- * @static
734
- * @param {Object.<string,*>} message Plain object to verify
735
- * @returns {string|null} `null` if valid, otherwise the reason why it is not
736
- */
737
- HeadBookRecord.verify = function verify(message) {
738
- if (typeof message !== "object" || message === null)
739
- return "object expected";
740
- if (message.heads != null && message.hasOwnProperty("heads")) {
741
- if (!Array.isArray(message.heads))
742
- return "heads: array expected";
743
- for (let i = 0; i < message.heads.length; ++i) {
744
- let error = $root.net.pb.HeadBookRecord.HeadEntry.verify(message.heads[i]);
745
- if (error)
746
- return "heads." + error;
747
- }
748
- }
749
- return null;
750
- };
751
-
752
- /**
753
- * Creates a HeadBookRecord message from a plain object. Also converts values to their respective internal types.
754
- * @function fromObject
755
- * @memberof net.pb.HeadBookRecord
756
- * @static
757
- * @param {Object.<string,*>} object Plain object
758
- * @returns {net.pb.HeadBookRecord} HeadBookRecord
759
- */
760
- HeadBookRecord.fromObject = function fromObject(object) {
761
- if (object instanceof $root.net.pb.HeadBookRecord)
762
- return object;
763
- let message = new $root.net.pb.HeadBookRecord();
764
- if (object.heads) {
765
- if (!Array.isArray(object.heads))
766
- throw TypeError(".net.pb.HeadBookRecord.heads: array expected");
767
- message.heads = [];
768
- for (let i = 0; i < object.heads.length; ++i) {
769
- if (typeof object.heads[i] !== "object")
770
- throw TypeError(".net.pb.HeadBookRecord.heads: object expected");
771
- message.heads[i] = $root.net.pb.HeadBookRecord.HeadEntry.fromObject(object.heads[i]);
772
- }
773
- }
774
- return message;
775
- };
776
-
777
- /**
778
- * Creates a plain object from a HeadBookRecord message. Also converts values to other types if specified.
779
- * @function toObject
780
- * @memberof net.pb.HeadBookRecord
781
- * @static
782
- * @param {net.pb.HeadBookRecord} message HeadBookRecord
783
- * @param {$protobuf.IConversionOptions} [options] Conversion options
784
- * @returns {Object.<string,*>} Plain object
785
- */
786
- HeadBookRecord.toObject = function toObject(message, options) {
787
- if (!options)
788
- options = {};
789
- let object = {};
790
- if (options.arrays || options.defaults)
791
- object.heads = [];
792
- if (message.heads && message.heads.length) {
793
- object.heads = [];
794
- for (let j = 0; j < message.heads.length; ++j)
795
- object.heads[j] = $root.net.pb.HeadBookRecord.HeadEntry.toObject(message.heads[j], options);
796
- }
797
- return object;
798
- };
799
-
800
- /**
801
- * Converts this HeadBookRecord to JSON.
802
- * @function toJSON
803
- * @memberof net.pb.HeadBookRecord
804
- * @instance
805
- * @returns {Object.<string,*>} JSON object
806
- */
807
- HeadBookRecord.prototype.toJSON = function toJSON() {
808
- return this.constructor.toObject(this, $protobuf.util.toJSONOptions);
809
- };
810
-
811
- /**
812
- * Gets the default type url for HeadBookRecord
813
- * @function getTypeUrl
814
- * @memberof net.pb.HeadBookRecord
815
- * @static
816
- * @param {string} [typeUrlPrefix] your custom typeUrlPrefix(default "type.googleapis.com")
817
- * @returns {string} The default type url
818
- */
819
- HeadBookRecord.getTypeUrl = function getTypeUrl(typeUrlPrefix) {
820
- if (typeUrlPrefix === undefined) {
821
- typeUrlPrefix = "type.googleapis.com";
822
- }
823
- return typeUrlPrefix + "/net.pb.HeadBookRecord";
824
- };
825
-
826
- HeadBookRecord.HeadEntry = (function() {
827
-
828
- /**
829
- * Properties of a HeadEntry.
830
- * @memberof net.pb.HeadBookRecord
831
- * @interface IHeadEntry
832
- * @property {Uint8Array|null} [cid] HeadEntry cid
833
- * @property {number|Long|null} [counter] HeadEntry counter
834
- */
835
-
836
- /**
837
- * Constructs a new HeadEntry.
838
- * @memberof net.pb.HeadBookRecord
839
- * @classdesc Represents a HeadEntry.
840
- * @implements IHeadEntry
841
- * @constructor
842
- * @param {net.pb.HeadBookRecord.IHeadEntry=} [properties] Properties to set
843
- */
844
- function HeadEntry(properties) {
845
- if (properties)
846
- for (let keys = Object.keys(properties), i = 0; i < keys.length; ++i)
847
- if (properties[keys[i]] != null)
848
- this[keys[i]] = properties[keys[i]];
849
- }
850
-
851
- /**
852
- * HeadEntry cid.
853
- * @member {Uint8Array} cid
854
- * @memberof net.pb.HeadBookRecord.HeadEntry
855
- * @instance
856
- */
857
- HeadEntry.prototype.cid = $util.newBuffer([]);
858
-
859
- /**
860
- * HeadEntry counter.
861
- * @member {number|Long} counter
862
- * @memberof net.pb.HeadBookRecord.HeadEntry
863
- * @instance
864
- */
865
- HeadEntry.prototype.counter = $util.Long ? $util.Long.fromBits(0,0,false) : 0;
866
-
867
- /**
868
- * Creates a new HeadEntry instance using the specified properties.
869
- * @function create
870
- * @memberof net.pb.HeadBookRecord.HeadEntry
871
- * @static
872
- * @param {net.pb.HeadBookRecord.IHeadEntry=} [properties] Properties to set
873
- * @returns {net.pb.HeadBookRecord.HeadEntry} HeadEntry instance
874
- */
875
- HeadEntry.create = function create(properties) {
876
- return new HeadEntry(properties);
877
- };
878
-
879
- /**
880
- * Encodes the specified HeadEntry message. Does not implicitly {@link net.pb.HeadBookRecord.HeadEntry.verify|verify} messages.
881
- * @function encode
882
- * @memberof net.pb.HeadBookRecord.HeadEntry
883
- * @static
884
- * @param {net.pb.HeadBookRecord.IHeadEntry} message HeadEntry message or plain object to encode
885
- * @param {$protobuf.Writer} [writer] Writer to encode to
886
- * @returns {$protobuf.Writer} Writer
887
- */
888
- HeadEntry.encode = function encode(message, writer) {
889
- if (!writer)
890
- writer = $Writer.create();
891
- if (message.cid != null && Object.hasOwnProperty.call(message, "cid"))
892
- writer.uint32(/* id 1, wireType 2 =*/10).bytes(message.cid);
893
- if (message.counter != null && Object.hasOwnProperty.call(message, "counter"))
894
- writer.uint32(/* id 2, wireType 0 =*/16).int64(message.counter);
895
- return writer;
896
- };
897
-
898
- /**
899
- * Encodes the specified HeadEntry message, length delimited. Does not implicitly {@link net.pb.HeadBookRecord.HeadEntry.verify|verify} messages.
900
- * @function encodeDelimited
901
- * @memberof net.pb.HeadBookRecord.HeadEntry
902
- * @static
903
- * @param {net.pb.HeadBookRecord.IHeadEntry} message HeadEntry message or plain object to encode
904
- * @param {$protobuf.Writer} [writer] Writer to encode to
905
- * @returns {$protobuf.Writer} Writer
906
- */
907
- HeadEntry.encodeDelimited = function encodeDelimited(message, writer) {
908
- return this.encode(message, writer).ldelim();
909
- };
910
-
911
- /**
912
- * Decodes a HeadEntry message from the specified reader or buffer.
913
- * @function decode
914
- * @memberof net.pb.HeadBookRecord.HeadEntry
915
- * @static
916
- * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from
917
- * @param {number} [length] Message length if known beforehand
918
- * @returns {net.pb.HeadBookRecord.HeadEntry} HeadEntry
919
- * @throws {Error} If the payload is not a reader or valid buffer
920
- * @throws {$protobuf.util.ProtocolError} If required fields are missing
921
- */
922
- HeadEntry.decode = function decode(reader, length) {
923
- if (!(reader instanceof $Reader))
924
- reader = $Reader.create(reader);
925
- let end = length === undefined ? reader.len : reader.pos + length, message = new $root.net.pb.HeadBookRecord.HeadEntry();
926
- while (reader.pos < end) {
927
- let tag = reader.uint32();
928
- switch (tag >>> 3) {
929
- case 1: {
930
- message.cid = reader.bytes();
931
- break;
932
- }
933
- case 2: {
934
- message.counter = reader.int64();
935
- break;
936
- }
937
- default:
938
- reader.skipType(tag & 7);
939
- break;
940
- }
941
- }
942
- return message;
943
- };
944
-
945
- /**
946
- * Decodes a HeadEntry message from the specified reader or buffer, length delimited.
947
- * @function decodeDelimited
948
- * @memberof net.pb.HeadBookRecord.HeadEntry
949
- * @static
950
- * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from
951
- * @returns {net.pb.HeadBookRecord.HeadEntry} HeadEntry
952
- * @throws {Error} If the payload is not a reader or valid buffer
953
- * @throws {$protobuf.util.ProtocolError} If required fields are missing
954
- */
955
- HeadEntry.decodeDelimited = function decodeDelimited(reader) {
956
- if (!(reader instanceof $Reader))
957
- reader = new $Reader(reader);
958
- return this.decode(reader, reader.uint32());
959
- };
960
-
961
- /**
962
- * Verifies a HeadEntry message.
963
- * @function verify
964
- * @memberof net.pb.HeadBookRecord.HeadEntry
965
- * @static
966
- * @param {Object.<string,*>} message Plain object to verify
967
- * @returns {string|null} `null` if valid, otherwise the reason why it is not
968
- */
969
- HeadEntry.verify = function verify(message) {
970
- if (typeof message !== "object" || message === null)
971
- return "object expected";
972
- if (message.cid != null && message.hasOwnProperty("cid"))
973
- if (!(message.cid && typeof message.cid.length === "number" || $util.isString(message.cid)))
974
- return "cid: buffer expected";
975
- if (message.counter != null && message.hasOwnProperty("counter"))
976
- if (!$util.isInteger(message.counter) && !(message.counter && $util.isInteger(message.counter.low) && $util.isInteger(message.counter.high)))
977
- return "counter: integer|Long expected";
978
- return null;
979
- };
980
-
981
- /**
982
- * Creates a HeadEntry message from a plain object. Also converts values to their respective internal types.
983
- * @function fromObject
984
- * @memberof net.pb.HeadBookRecord.HeadEntry
985
- * @static
986
- * @param {Object.<string,*>} object Plain object
987
- * @returns {net.pb.HeadBookRecord.HeadEntry} HeadEntry
988
- */
989
- HeadEntry.fromObject = function fromObject(object) {
990
- if (object instanceof $root.net.pb.HeadBookRecord.HeadEntry)
991
- return object;
992
- let message = new $root.net.pb.HeadBookRecord.HeadEntry();
993
- if (object.cid != null)
994
- if (typeof object.cid === "string")
995
- $util.base64.decode(object.cid, message.cid = $util.newBuffer($util.base64.length(object.cid)), 0);
996
- else if (object.cid.length >= 0)
997
- message.cid = object.cid;
998
- if (object.counter != null)
999
- if ($util.Long)
1000
- (message.counter = $util.Long.fromValue(object.counter)).unsigned = false;
1001
- else if (typeof object.counter === "string")
1002
- message.counter = parseInt(object.counter, 10);
1003
- else if (typeof object.counter === "number")
1004
- message.counter = object.counter;
1005
- else if (typeof object.counter === "object")
1006
- message.counter = new $util.LongBits(object.counter.low >>> 0, object.counter.high >>> 0).toNumber();
1007
- return message;
1008
- };
1009
-
1010
- /**
1011
- * Creates a plain object from a HeadEntry message. Also converts values to other types if specified.
1012
- * @function toObject
1013
- * @memberof net.pb.HeadBookRecord.HeadEntry
1014
- * @static
1015
- * @param {net.pb.HeadBookRecord.HeadEntry} message HeadEntry
1016
- * @param {$protobuf.IConversionOptions} [options] Conversion options
1017
- * @returns {Object.<string,*>} Plain object
1018
- */
1019
- HeadEntry.toObject = function toObject(message, options) {
1020
- if (!options)
1021
- options = {};
1022
- let object = {};
1023
- if (options.defaults) {
1024
- if (options.bytes === String)
1025
- object.cid = "";
1026
- else {
1027
- object.cid = [];
1028
- if (options.bytes !== Array)
1029
- object.cid = $util.newBuffer(object.cid);
1030
- }
1031
- if ($util.Long) {
1032
- let long = new $util.Long(0, 0, false);
1033
- object.counter = options.longs === String ? long.toString() : options.longs === Number ? long.toNumber() : long;
1034
- } else
1035
- object.counter = options.longs === String ? "0" : 0;
1036
- }
1037
- if (message.cid != null && message.hasOwnProperty("cid"))
1038
- object.cid = options.bytes === String ? $util.base64.encode(message.cid, 0, message.cid.length) : options.bytes === Array ? Array.prototype.slice.call(message.cid) : message.cid;
1039
- if (message.counter != null && message.hasOwnProperty("counter"))
1040
- if (typeof message.counter === "number")
1041
- object.counter = options.longs === String ? String(message.counter) : message.counter;
1042
- else
1043
- object.counter = options.longs === String ? $util.Long.prototype.toString.call(message.counter) : options.longs === Number ? new $util.LongBits(message.counter.low >>> 0, message.counter.high >>> 0).toNumber() : message.counter;
1044
- return object;
1045
- };
1046
-
1047
- /**
1048
- * Converts this HeadEntry to JSON.
1049
- * @function toJSON
1050
- * @memberof net.pb.HeadBookRecord.HeadEntry
1051
- * @instance
1052
- * @returns {Object.<string,*>} JSON object
1053
- */
1054
- HeadEntry.prototype.toJSON = function toJSON() {
1055
- return this.constructor.toObject(this, $protobuf.util.toJSONOptions);
1056
- };
1057
-
1058
- /**
1059
- * Gets the default type url for HeadEntry
1060
- * @function getTypeUrl
1061
- * @memberof net.pb.HeadBookRecord.HeadEntry
1062
- * @static
1063
- * @param {string} [typeUrlPrefix] your custom typeUrlPrefix(default "type.googleapis.com")
1064
- * @returns {string} The default type url
1065
- */
1066
- HeadEntry.getTypeUrl = function getTypeUrl(typeUrlPrefix) {
1067
- if (typeUrlPrefix === undefined) {
1068
- typeUrlPrefix = "type.googleapis.com";
1069
- }
1070
- return typeUrlPrefix + "/net.pb.HeadBookRecord.HeadEntry";
1071
- };
1072
-
1073
- return HeadEntry;
1074
- })();
1075
-
1076
- return HeadBookRecord;
1077
- })();
1078
-
1079
- return pb;
1080
- })();
1081
-
1082
- return net;
1083
- })();
1084
-
1085
- export { $root as default };