@libp2p/kad-dht 1.0.3 → 1.0.6
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/src/message/dht.d.ts +46 -287
- package/dist/src/message/dht.d.ts.map +1 -0
- package/dist/src/message/dht.js +75 -913
- package/dist/src/message/dht.js.map +1 -0
- package/dist/src/message/index.d.ts +5 -5
- package/dist/src/message/index.d.ts.map +1 -1
- package/dist/src/message/index.js +7 -7
- package/dist/src/message/index.js.map +1 -1
- package/dist/src/network.d.ts.map +1 -1
- package/dist/src/network.js +3 -3
- package/dist/src/network.js.map +1 -1
- package/dist/src/peer-routing/index.d.ts.map +1 -1
- package/dist/src/peer-routing/index.js +3 -0
- package/dist/src/peer-routing/index.js.map +1 -1
- package/dist/src/query/events.d.ts +4 -3
- package/dist/src/query/events.d.ts.map +1 -1
- package/dist/src/query/events.js +3 -13
- package/dist/src/query/events.js.map +1 -1
- package/dist/src/query/manager.d.ts.map +1 -1
- package/dist/src/query/manager.js +11 -4
- package/dist/src/query/manager.js.map +1 -1
- package/dist/src/rpc/handlers/get-value.js +1 -1
- package/dist/src/rpc/handlers/get-value.js.map +1 -1
- package/dist/src/rpc/index.d.ts.map +1 -1
- package/dist/src/rpc/index.js +2 -2
- package/dist/src/rpc/index.js.map +1 -1
- package/dist/src/utils.d.ts.map +1 -1
- package/dist/src/utils.js +6 -2
- package/dist/src/utils.js.map +1 -1
- package/package.json +19 -22
- package/src/message/dht.ts +112 -0
- package/src/message/index.ts +11 -13
- package/src/network.ts +3 -3
- package/src/peer-routing/index.ts +4 -0
- package/src/query/events.ts +7 -17
- package/src/query/manager.ts +11 -5
- package/src/rpc/handlers/get-value.ts +1 -1
- package/src/rpc/index.ts +3 -3
- package/src/utils.ts +8 -2
- package/src/message/dht.d.ts +0 -297
- package/src/message/dht.js +0 -921
|
@@ -1,297 +1,56 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
/** Record value */
|
|
9
|
-
value?: (Uint8Array|null);
|
|
10
|
-
|
|
11
|
-
/** Record author */
|
|
12
|
-
author?: (Uint8Array|null);
|
|
13
|
-
|
|
14
|
-
/** Record signature */
|
|
15
|
-
signature?: (Uint8Array|null);
|
|
16
|
-
|
|
17
|
-
/** Record timeReceived */
|
|
18
|
-
timeReceived?: (string|null);
|
|
1
|
+
export interface Record {
|
|
2
|
+
key?: Uint8Array;
|
|
3
|
+
value?: Uint8Array;
|
|
4
|
+
author?: Uint8Array;
|
|
5
|
+
signature?: Uint8Array;
|
|
6
|
+
timeReceived?: string;
|
|
19
7
|
}
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
/**
|
|
25
|
-
* Constructs a new Record.
|
|
26
|
-
* @param [p] Properties to set
|
|
27
|
-
*/
|
|
28
|
-
constructor(p?: IRecord);
|
|
29
|
-
|
|
30
|
-
/** Record key. */
|
|
31
|
-
public key?: (Uint8Array|null);
|
|
32
|
-
|
|
33
|
-
/** Record value. */
|
|
34
|
-
public value?: (Uint8Array|null);
|
|
35
|
-
|
|
36
|
-
/** Record author. */
|
|
37
|
-
public author?: (Uint8Array|null);
|
|
38
|
-
|
|
39
|
-
/** Record signature. */
|
|
40
|
-
public signature?: (Uint8Array|null);
|
|
41
|
-
|
|
42
|
-
/** Record timeReceived. */
|
|
43
|
-
public timeReceived?: (string|null);
|
|
44
|
-
|
|
45
|
-
/** Record _key. */
|
|
46
|
-
public _key?: "key";
|
|
47
|
-
|
|
48
|
-
/** Record _value. */
|
|
49
|
-
public _value?: "value";
|
|
50
|
-
|
|
51
|
-
/** Record _author. */
|
|
52
|
-
public _author?: "author";
|
|
53
|
-
|
|
54
|
-
/** Record _signature. */
|
|
55
|
-
public _signature?: "signature";
|
|
56
|
-
|
|
57
|
-
/** Record _timeReceived. */
|
|
58
|
-
public _timeReceived?: "timeReceived";
|
|
59
|
-
|
|
60
|
-
/**
|
|
61
|
-
* Encodes the specified Record message. Does not implicitly {@link Record.verify|verify} messages.
|
|
62
|
-
* @param m Record message or plain object to encode
|
|
63
|
-
* @param [w] Writer to encode to
|
|
64
|
-
* @returns Writer
|
|
65
|
-
*/
|
|
66
|
-
public static encode(m: IRecord, w?: $protobuf.Writer): $protobuf.Writer;
|
|
67
|
-
|
|
68
|
-
/**
|
|
69
|
-
* Decodes a Record message from the specified reader or buffer.
|
|
70
|
-
* @param r Reader or buffer to decode from
|
|
71
|
-
* @param [l] Message length if known beforehand
|
|
72
|
-
* @returns Record
|
|
73
|
-
* @throws {Error} If the payload is not a reader or valid buffer
|
|
74
|
-
* @throws {$protobuf.util.ProtocolError} If required fields are missing
|
|
75
|
-
*/
|
|
76
|
-
public static decode(r: ($protobuf.Reader|Uint8Array), l?: number): Record;
|
|
77
|
-
|
|
78
|
-
/**
|
|
79
|
-
* Creates a Record message from a plain object. Also converts values to their respective internal types.
|
|
80
|
-
* @param d Plain object
|
|
81
|
-
* @returns Record
|
|
82
|
-
*/
|
|
83
|
-
public static fromObject(d: { [k: string]: any }): Record;
|
|
84
|
-
|
|
85
|
-
/**
|
|
86
|
-
* Creates a plain object from a Record message. Also converts values to other types if specified.
|
|
87
|
-
* @param m Record
|
|
88
|
-
* @param [o] Conversion options
|
|
89
|
-
* @returns Plain object
|
|
90
|
-
*/
|
|
91
|
-
public static toObject(m: Record, o?: $protobuf.IConversionOptions): { [k: string]: any };
|
|
92
|
-
|
|
93
|
-
/**
|
|
94
|
-
* Converts this Record to JSON.
|
|
95
|
-
* @returns JSON object
|
|
96
|
-
*/
|
|
97
|
-
public toJSON(): { [k: string]: any };
|
|
8
|
+
export declare namespace Record {
|
|
9
|
+
const codec: () => import("protons-runtime").Codec<Record>;
|
|
10
|
+
const encode: (obj: Record) => Uint8Array;
|
|
11
|
+
const decode: (buf: Uint8Array) => Record;
|
|
98
12
|
}
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
/** Message clusterLevelRaw */
|
|
107
|
-
clusterLevelRaw?: (number|null);
|
|
108
|
-
|
|
109
|
-
/** Message key */
|
|
110
|
-
key?: (Uint8Array|null);
|
|
111
|
-
|
|
112
|
-
/** Message record */
|
|
113
|
-
record?: (Uint8Array|null);
|
|
114
|
-
|
|
115
|
-
/** Message closerPeers */
|
|
116
|
-
closerPeers?: (Message.IPeer[]|null);
|
|
117
|
-
|
|
118
|
-
/** Message providerPeers */
|
|
119
|
-
providerPeers?: (Message.IPeer[]|null);
|
|
13
|
+
export interface Message {
|
|
14
|
+
type?: Message.MessageType;
|
|
15
|
+
clusterLevelRaw?: number;
|
|
16
|
+
key?: Uint8Array;
|
|
17
|
+
record?: Uint8Array;
|
|
18
|
+
closerPeers: Message.Peer[];
|
|
19
|
+
providerPeers: Message.Peer[];
|
|
120
20
|
}
|
|
121
|
-
|
|
122
|
-
/** Represents a Message. */
|
|
123
|
-
export class Message implements IMessage {
|
|
124
|
-
|
|
125
|
-
/**
|
|
126
|
-
* Constructs a new Message.
|
|
127
|
-
* @param [p] Properties to set
|
|
128
|
-
*/
|
|
129
|
-
constructor(p?: IMessage);
|
|
130
|
-
|
|
131
|
-
/** Message type. */
|
|
132
|
-
public type?: (Message.MessageType|null);
|
|
133
|
-
|
|
134
|
-
/** Message clusterLevelRaw. */
|
|
135
|
-
public clusterLevelRaw?: (number|null);
|
|
136
|
-
|
|
137
|
-
/** Message key. */
|
|
138
|
-
public key?: (Uint8Array|null);
|
|
139
|
-
|
|
140
|
-
/** Message record. */
|
|
141
|
-
public record?: (Uint8Array|null);
|
|
142
|
-
|
|
143
|
-
/** Message closerPeers. */
|
|
144
|
-
public closerPeers: Message.IPeer[];
|
|
145
|
-
|
|
146
|
-
/** Message providerPeers. */
|
|
147
|
-
public providerPeers: Message.IPeer[];
|
|
148
|
-
|
|
149
|
-
/** Message _type. */
|
|
150
|
-
public _type?: "type";
|
|
151
|
-
|
|
152
|
-
/** Message _clusterLevelRaw. */
|
|
153
|
-
public _clusterLevelRaw?: "clusterLevelRaw";
|
|
154
|
-
|
|
155
|
-
/** Message _key. */
|
|
156
|
-
public _key?: "key";
|
|
157
|
-
|
|
158
|
-
/** Message _record. */
|
|
159
|
-
public _record?: "record";
|
|
160
|
-
|
|
161
|
-
/**
|
|
162
|
-
* Encodes the specified Message message. Does not implicitly {@link Message.verify|verify} messages.
|
|
163
|
-
* @param m Message message or plain object to encode
|
|
164
|
-
* @param [w] Writer to encode to
|
|
165
|
-
* @returns Writer
|
|
166
|
-
*/
|
|
167
|
-
public static encode(m: IMessage, w?: $protobuf.Writer): $protobuf.Writer;
|
|
168
|
-
|
|
169
|
-
/**
|
|
170
|
-
* Decodes a Message message from the specified reader or buffer.
|
|
171
|
-
* @param r Reader or buffer to decode from
|
|
172
|
-
* @param [l] Message length if known beforehand
|
|
173
|
-
* @returns Message
|
|
174
|
-
* @throws {Error} If the payload is not a reader or valid buffer
|
|
175
|
-
* @throws {$protobuf.util.ProtocolError} If required fields are missing
|
|
176
|
-
*/
|
|
177
|
-
public static decode(r: ($protobuf.Reader|Uint8Array), l?: number): Message;
|
|
178
|
-
|
|
179
|
-
/**
|
|
180
|
-
* Creates a Message message from a plain object. Also converts values to their respective internal types.
|
|
181
|
-
* @param d Plain object
|
|
182
|
-
* @returns Message
|
|
183
|
-
*/
|
|
184
|
-
public static fromObject(d: { [k: string]: any }): Message;
|
|
185
|
-
|
|
186
|
-
/**
|
|
187
|
-
* Creates a plain object from a Message message. Also converts values to other types if specified.
|
|
188
|
-
* @param m Message
|
|
189
|
-
* @param [o] Conversion options
|
|
190
|
-
* @returns Plain object
|
|
191
|
-
*/
|
|
192
|
-
public static toObject(m: Message, o?: $protobuf.IConversionOptions): { [k: string]: any };
|
|
193
|
-
|
|
194
|
-
/**
|
|
195
|
-
* Converts this Message to JSON.
|
|
196
|
-
* @returns JSON object
|
|
197
|
-
*/
|
|
198
|
-
public toJSON(): { [k: string]: any };
|
|
199
|
-
}
|
|
200
|
-
|
|
201
|
-
export namespace Message {
|
|
202
|
-
|
|
203
|
-
/** MessageType enum. */
|
|
21
|
+
export declare namespace Message {
|
|
204
22
|
enum MessageType {
|
|
205
|
-
PUT_VALUE =
|
|
206
|
-
GET_VALUE =
|
|
207
|
-
ADD_PROVIDER =
|
|
208
|
-
GET_PROVIDERS =
|
|
209
|
-
FIND_NODE =
|
|
210
|
-
PING =
|
|
23
|
+
PUT_VALUE = "PUT_VALUE",
|
|
24
|
+
GET_VALUE = "GET_VALUE",
|
|
25
|
+
ADD_PROVIDER = "ADD_PROVIDER",
|
|
26
|
+
GET_PROVIDERS = "GET_PROVIDERS",
|
|
27
|
+
FIND_NODE = "FIND_NODE",
|
|
28
|
+
PING = "PING"
|
|
29
|
+
}
|
|
30
|
+
namespace MessageType {
|
|
31
|
+
const codec: () => import("protons-runtime").Codec<typeof MessageType>;
|
|
211
32
|
}
|
|
212
|
-
|
|
213
|
-
/** ConnectionType enum. */
|
|
214
33
|
enum ConnectionType {
|
|
215
|
-
NOT_CONNECTED =
|
|
216
|
-
CONNECTED =
|
|
217
|
-
CAN_CONNECT =
|
|
218
|
-
CANNOT_CONNECT =
|
|
34
|
+
NOT_CONNECTED = "NOT_CONNECTED",
|
|
35
|
+
CONNECTED = "CONNECTED",
|
|
36
|
+
CAN_CONNECT = "CAN_CONNECT",
|
|
37
|
+
CANNOT_CONNECT = "CANNOT_CONNECT"
|
|
38
|
+
}
|
|
39
|
+
namespace ConnectionType {
|
|
40
|
+
const codec: () => import("protons-runtime").Codec<typeof ConnectionType>;
|
|
219
41
|
}
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
/** Peer id */
|
|
225
|
-
id?: (Uint8Array|null);
|
|
226
|
-
|
|
227
|
-
/** Peer addrs */
|
|
228
|
-
addrs?: (Uint8Array[]|null);
|
|
229
|
-
|
|
230
|
-
/** Peer connection */
|
|
231
|
-
connection?: (Message.ConnectionType|null);
|
|
42
|
+
interface Peer {
|
|
43
|
+
id?: Uint8Array;
|
|
44
|
+
addrs: Uint8Array[];
|
|
45
|
+
connection?: Message.ConnectionType;
|
|
232
46
|
}
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
/**
|
|
238
|
-
* Constructs a new Peer.
|
|
239
|
-
* @param [p] Properties to set
|
|
240
|
-
*/
|
|
241
|
-
constructor(p?: Message.IPeer);
|
|
242
|
-
|
|
243
|
-
/** Peer id. */
|
|
244
|
-
public id?: (Uint8Array|null);
|
|
245
|
-
|
|
246
|
-
/** Peer addrs. */
|
|
247
|
-
public addrs: Uint8Array[];
|
|
248
|
-
|
|
249
|
-
/** Peer connection. */
|
|
250
|
-
public connection?: (Message.ConnectionType|null);
|
|
251
|
-
|
|
252
|
-
/** Peer _id. */
|
|
253
|
-
public _id?: "id";
|
|
254
|
-
|
|
255
|
-
/** Peer _connection. */
|
|
256
|
-
public _connection?: "connection";
|
|
257
|
-
|
|
258
|
-
/**
|
|
259
|
-
* Encodes the specified Peer message. Does not implicitly {@link Message.Peer.verify|verify} messages.
|
|
260
|
-
* @param m Peer message or plain object to encode
|
|
261
|
-
* @param [w] Writer to encode to
|
|
262
|
-
* @returns Writer
|
|
263
|
-
*/
|
|
264
|
-
public static encode(m: Message.IPeer, w?: $protobuf.Writer): $protobuf.Writer;
|
|
265
|
-
|
|
266
|
-
/**
|
|
267
|
-
* Decodes a Peer message from the specified reader or buffer.
|
|
268
|
-
* @param r Reader or buffer to decode from
|
|
269
|
-
* @param [l] Message length if known beforehand
|
|
270
|
-
* @returns Peer
|
|
271
|
-
* @throws {Error} If the payload is not a reader or valid buffer
|
|
272
|
-
* @throws {$protobuf.util.ProtocolError} If required fields are missing
|
|
273
|
-
*/
|
|
274
|
-
public static decode(r: ($protobuf.Reader|Uint8Array), l?: number): Message.Peer;
|
|
275
|
-
|
|
276
|
-
/**
|
|
277
|
-
* Creates a Peer message from a plain object. Also converts values to their respective internal types.
|
|
278
|
-
* @param d Plain object
|
|
279
|
-
* @returns Peer
|
|
280
|
-
*/
|
|
281
|
-
public static fromObject(d: { [k: string]: any }): Message.Peer;
|
|
282
|
-
|
|
283
|
-
/**
|
|
284
|
-
* Creates a plain object from a Peer message. Also converts values to other types if specified.
|
|
285
|
-
* @param m Peer
|
|
286
|
-
* @param [o] Conversion options
|
|
287
|
-
* @returns Plain object
|
|
288
|
-
*/
|
|
289
|
-
public static toObject(m: Message.Peer, o?: $protobuf.IConversionOptions): { [k: string]: any };
|
|
290
|
-
|
|
291
|
-
/**
|
|
292
|
-
* Converts this Peer to JSON.
|
|
293
|
-
* @returns JSON object
|
|
294
|
-
*/
|
|
295
|
-
public toJSON(): { [k: string]: any };
|
|
47
|
+
namespace Peer {
|
|
48
|
+
const codec: () => import("protons-runtime").Codec<Peer>;
|
|
49
|
+
const encode: (obj: Peer) => Uint8Array;
|
|
50
|
+
const decode: (buf: Uint8Array) => Peer;
|
|
296
51
|
}
|
|
52
|
+
const codec: () => import("protons-runtime").Codec<Message>;
|
|
53
|
+
const encode: (obj: Message) => Uint8Array;
|
|
54
|
+
const decode: (buf: Uint8Array) => Message;
|
|
297
55
|
}
|
|
56
|
+
//# sourceMappingURL=dht.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"dht.d.ts","sourceRoot":"","sources":["../../../src/message/dht.ts"],"names":[],"mappings":"AAKA,MAAM,WAAW,MAAM;IACrB,GAAG,CAAC,EAAE,UAAU,CAAA;IAChB,KAAK,CAAC,EAAE,UAAU,CAAA;IAClB,MAAM,CAAC,EAAE,UAAU,CAAA;IACnB,SAAS,CAAC,EAAE,UAAU,CAAA;IACtB,YAAY,CAAC,EAAE,MAAM,CAAA;CACtB;AAED,yBAAiB,MAAM,CAAC;IACf,MAAM,KAAK,+CAQjB,CAAA;IAEM,MAAM,MAAM,QAAS,MAAM,KAAG,UAEpC,CAAA;IAEM,MAA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