@libp2p/fetch 3.0.21 → 3.0.22-8484de8a2
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/index.min.js +1 -1
- package/dist/index.min.js.map +4 -4
- package/dist/src/fetch.d.ts +2 -3
- package/dist/src/fetch.d.ts.map +1 -1
- package/dist/src/fetch.js +56 -84
- package/dist/src/fetch.js.map +1 -1
- package/dist/src/index.d.ts +1 -2
- package/dist/src/index.d.ts.map +1 -1
- package/dist/src/index.js.map +1 -1
- package/package.json +10 -12
- package/src/fetch.ts +61 -88
- package/src/index.ts +1 -2
- package/dist/typedoc-urls.json +0 -12
package/dist/src/fetch.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import type { Fetch as FetchInterface, FetchComponents, FetchInit, LookupFunction } from './index.js';
|
|
2
|
-
import type { AbortOptions, PeerId, Startable
|
|
2
|
+
import type { AbortOptions, Stream, PeerId, Startable } from '@libp2p/interface';
|
|
3
3
|
/**
|
|
4
4
|
* A simple libp2p protocol for requesting a value corresponding to a key from a peer.
|
|
5
5
|
* Developers can register one or more lookup function for retrieving the value corresponding to
|
|
@@ -12,7 +12,6 @@ export declare class Fetch implements Startable, FetchInterface {
|
|
|
12
12
|
private readonly lookupFunctions;
|
|
13
13
|
private started;
|
|
14
14
|
private readonly init;
|
|
15
|
-
private readonly log;
|
|
16
15
|
constructor(components: FetchComponents, init?: FetchInit);
|
|
17
16
|
readonly [Symbol.toStringTag] = "@libp2p/fetch";
|
|
18
17
|
start(): Promise<void>;
|
|
@@ -27,7 +26,7 @@ export declare class Fetch implements Startable, FetchInterface {
|
|
|
27
26
|
* responds based on looking up the key in the request via the lookup callback that corresponds
|
|
28
27
|
* to the key's prefix.
|
|
29
28
|
*/
|
|
30
|
-
handleMessage(
|
|
29
|
+
handleMessage(stream: Stream): Promise<void>;
|
|
31
30
|
/**
|
|
32
31
|
* Given a key, finds the appropriate function for looking up its corresponding value, based on
|
|
33
32
|
* the key's prefix.
|
package/dist/src/fetch.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"fetch.d.ts","sourceRoot":"","sources":["../../src/fetch.ts"],"names":[],"mappings":"AAOA,OAAO,KAAK,EAAE,KAAK,IAAI,cAAc,EAAE,eAAe,EAAE,SAAS,EAAE,cAAc,EAAE,MAAM,YAAY,CAAA;AACrG,OAAO,KAAK,EAAE,YAAY,
|
|
1
|
+
{"version":3,"file":"fetch.d.ts","sourceRoot":"","sources":["../../src/fetch.ts"],"names":[],"mappings":"AAOA,OAAO,KAAK,EAAE,KAAK,IAAI,cAAc,EAAE,eAAe,EAAE,SAAS,EAAE,cAAc,EAAE,MAAM,YAAY,CAAA;AACrG,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,EAAE,MAAM,EAAE,SAAS,EAAE,MAAM,mBAAmB,CAAA;AAIhF;;;;;GAKG;AACH,qBAAa,KAAM,YAAW,SAAS,EAAE,cAAc;IACrD,SAAgB,QAAQ,EAAE,MAAM,CAAA;IAChC,OAAO,CAAC,QAAQ,CAAC,UAAU,CAAiB;IAC5C,OAAO,CAAC,QAAQ,CAAC,eAAe,CAA6B;IAC7D,OAAO,CAAC,OAAO,CAAS;IACxB,OAAO,CAAC,QAAQ,CAAC,IAAI,CAAW;gBAEnB,UAAU,EAAE,eAAe,EAAE,IAAI,GAAE,SAAc;IAU9D,QAAQ,CAAC,CAAC,MAAM,CAAC,WAAW,CAAC,mBAAkB;IAEzC,KAAK,IAAK,OAAO,CAAC,IAAI,CAAC;IAQvB,IAAI,IAAK,OAAO,CAAC,IAAI,CAAC;IAK5B,SAAS,IAAK,OAAO;IAIrB;;OAEG;IACG,KAAK,CAAE,IAAI,EAAE,MAAM,EAAE,GAAG,EAAE,MAAM,GAAG,UAAU,EAAE,OAAO,GAAE,YAAiB,GAAG,OAAO,CAAC,UAAU,GAAG,SAAS,CAAC;IA4DjH;;;;OAIG;IACG,aAAa,CAAE,MAAM,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC;IA+CnD;;;OAGG;IACH,kBAAkB,CAAE,GAAG,EAAE,MAAM,GAAG;QAAE,EAAE,EAAE,cAAc,CAAC;QAAC,MAAM,EAAE,MAAM,CAAA;KAAE,GAAG,SAAS;IAepF;;;;;;;;;;OAUG;IACH,sBAAsB,CAAE,MAAM,EAAE,MAAM,EAAE,MAAM,EAAE,cAAc,GAAG,IAAI;IAQrE;;;;;;;;;;OAUG;IACH,wBAAwB,CAAE,MAAM,EAAE,MAAM,EAAE,MAAM,CAAC,EAAE,cAAc,GAAG,IAAI;CAWzE"}
|
package/dist/src/fetch.js
CHANGED
|
@@ -1,11 +1,11 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { pbStream } from '
|
|
1
|
+
import { InvalidMessageError, InvalidParametersError, ProtocolError } from '@libp2p/interface';
|
|
2
|
+
import { pbStream } from '@libp2p/utils';
|
|
3
3
|
import { setMaxListeners } from 'main-event';
|
|
4
4
|
import { fromString as uint8arrayFromString } from 'uint8arrays/from-string';
|
|
5
5
|
import { toString as uint8arrayToString } from 'uint8arrays/to-string';
|
|
6
6
|
import { PROTOCOL_NAME, PROTOCOL_VERSION } from './constants.js';
|
|
7
7
|
import { FetchRequest, FetchResponse } from './pb/proto.js';
|
|
8
|
-
const DEFAULT_TIMEOUT =
|
|
8
|
+
const DEFAULT_TIMEOUT = 10_000;
|
|
9
9
|
/**
|
|
10
10
|
* A simple libp2p protocol for requesting a value corresponding to a key from a peer.
|
|
11
11
|
* Developers can register one or more lookup function for retrieving the value corresponding to
|
|
@@ -18,27 +18,17 @@ export class Fetch {
|
|
|
18
18
|
lookupFunctions;
|
|
19
19
|
started;
|
|
20
20
|
init;
|
|
21
|
-
log;
|
|
22
21
|
constructor(components, init = {}) {
|
|
23
|
-
this.log = components.logger.forComponent('libp2p:fetch');
|
|
24
22
|
this.started = false;
|
|
25
23
|
this.components = components;
|
|
26
24
|
this.protocol = `/${init.protocolPrefix ?? 'libp2p'}/${PROTOCOL_NAME}/${PROTOCOL_VERSION}`;
|
|
27
25
|
this.lookupFunctions = new Map(); // Maps key prefix to value lookup function
|
|
28
|
-
this.handleMessage = this.handleMessage.bind(this);
|
|
29
26
|
this.init = init;
|
|
27
|
+
this.handleMessage = this.handleMessage.bind(this);
|
|
30
28
|
}
|
|
31
29
|
[Symbol.toStringTag] = '@libp2p/fetch';
|
|
32
30
|
async start() {
|
|
33
|
-
await this.components.registrar.handle(this.protocol,
|
|
34
|
-
void this.handleMessage(data)
|
|
35
|
-
.then(async () => {
|
|
36
|
-
await data.stream.close();
|
|
37
|
-
})
|
|
38
|
-
.catch(err => {
|
|
39
|
-
this.log.error('error handling message - %e', err);
|
|
40
|
-
});
|
|
41
|
-
}, {
|
|
31
|
+
await this.components.registrar.handle(this.protocol, this.handleMessage, {
|
|
42
32
|
maxInboundStreams: this.init.maxInboundStreams,
|
|
43
33
|
maxOutboundStreams: this.init.maxOutboundStreams
|
|
44
34
|
});
|
|
@@ -58,50 +48,44 @@ export class Fetch {
|
|
|
58
48
|
if (typeof key === 'string') {
|
|
59
49
|
key = uint8arrayFromString(key);
|
|
60
50
|
}
|
|
61
|
-
this.log.trace('dialing %s to %p', this.protocol, peer);
|
|
62
|
-
const connection = await this.components.connectionManager.openConnection(peer, options);
|
|
63
|
-
let signal = options.signal;
|
|
64
|
-
let stream;
|
|
65
|
-
let onAbort = () => { };
|
|
66
51
|
// create a timeout if no abort signal passed
|
|
67
|
-
if (signal == null) {
|
|
52
|
+
if (options.signal == null) {
|
|
68
53
|
const timeout = this.init.timeout ?? DEFAULT_TIMEOUT;
|
|
69
|
-
|
|
70
|
-
signal = AbortSignal.timeout(timeout);
|
|
54
|
+
const signal = AbortSignal.timeout(timeout);
|
|
71
55
|
setMaxListeners(Infinity, signal);
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
stream = await connection.newStream(this.protocol, {
|
|
56
|
+
options = {
|
|
57
|
+
...options,
|
|
75
58
|
signal
|
|
76
|
-
});
|
|
77
|
-
onAbort = () => {
|
|
78
|
-
stream?.abort(new AbortError());
|
|
79
59
|
};
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
60
|
+
}
|
|
61
|
+
let stream;
|
|
62
|
+
try {
|
|
63
|
+
const connection = await this.components.connectionManager.openConnection(peer, options);
|
|
64
|
+
stream = await connection.newStream(this.protocol, options);
|
|
65
|
+
const log = stream.log.newScope('fetch');
|
|
66
|
+
log.trace('fetch %m', key);
|
|
83
67
|
const pb = pbStream(stream);
|
|
84
68
|
await pb.write({
|
|
85
69
|
identifier: key
|
|
86
70
|
}, FetchRequest, options);
|
|
87
71
|
const response = await pb.read(FetchResponse, options);
|
|
88
|
-
await
|
|
72
|
+
await stream.close(options);
|
|
89
73
|
switch (response.status) {
|
|
90
74
|
case (FetchResponse.StatusCode.OK): {
|
|
91
|
-
|
|
75
|
+
log.trace('received status OK for %m', key);
|
|
92
76
|
return response.data;
|
|
93
77
|
}
|
|
94
78
|
case (FetchResponse.StatusCode.NOT_FOUND): {
|
|
95
|
-
|
|
79
|
+
log('received status NOT_FOUND for %m', key);
|
|
96
80
|
return;
|
|
97
81
|
}
|
|
98
82
|
case (FetchResponse.StatusCode.ERROR): {
|
|
99
|
-
|
|
83
|
+
log('received status ERROR for %m', key);
|
|
100
84
|
const errMsg = uint8arrayToString(response.data);
|
|
101
85
|
throw new ProtocolError('Error in fetch protocol response: ' + errMsg);
|
|
102
86
|
}
|
|
103
87
|
default: {
|
|
104
|
-
|
|
88
|
+
log('received status unknown for %m', key);
|
|
105
89
|
throw new InvalidMessageError('Unknown response status');
|
|
106
90
|
}
|
|
107
91
|
}
|
|
@@ -110,64 +94,52 @@ export class Fetch {
|
|
|
110
94
|
stream?.abort(err);
|
|
111
95
|
throw err;
|
|
112
96
|
}
|
|
113
|
-
finally {
|
|
114
|
-
signal.removeEventListener('abort', onAbort);
|
|
115
|
-
if (stream != null) {
|
|
116
|
-
await stream.close();
|
|
117
|
-
}
|
|
118
|
-
}
|
|
119
97
|
}
|
|
120
98
|
/**
|
|
121
99
|
* Invoked when a fetch request is received. Reads the request message off the given stream and
|
|
122
100
|
* responds based on looking up the key in the request via the lookup callback that corresponds
|
|
123
101
|
* to the key's prefix.
|
|
124
102
|
*/
|
|
125
|
-
async handleMessage(
|
|
126
|
-
const
|
|
103
|
+
async handleMessage(stream) {
|
|
104
|
+
const log = stream.log.newScope('fetch');
|
|
127
105
|
const signal = AbortSignal.timeout(this.init.timeout ?? DEFAULT_TIMEOUT);
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
response = { status: FetchResponse.StatusCode.NOT_FOUND, data: new Uint8Array(0) };
|
|
148
|
-
}
|
|
149
|
-
else {
|
|
150
|
-
this.log.trace('sending status OK for %m', request.identifier);
|
|
151
|
-
response = { status: FetchResponse.StatusCode.OK, data };
|
|
152
|
-
}
|
|
106
|
+
const pb = pbStream(stream);
|
|
107
|
+
const request = await pb.read(FetchRequest, {
|
|
108
|
+
signal
|
|
109
|
+
});
|
|
110
|
+
let response;
|
|
111
|
+
const key = uint8arrayToString(request.identifier);
|
|
112
|
+
const lookup = this._getLookupFunction(key);
|
|
113
|
+
if (lookup == null) {
|
|
114
|
+
log.trace('sending status ERROR for %m', request.identifier);
|
|
115
|
+
const errMsg = uint8arrayFromString('No lookup function registered for key');
|
|
116
|
+
response = { status: FetchResponse.StatusCode.ERROR, data: errMsg };
|
|
117
|
+
}
|
|
118
|
+
else {
|
|
119
|
+
log.trace('lookup data with identifier %s', lookup.prefix);
|
|
120
|
+
try {
|
|
121
|
+
const data = await lookup.fn(request.identifier);
|
|
122
|
+
if (data == null) {
|
|
123
|
+
log.trace('sending status NOT_FOUND for %m', request.identifier);
|
|
124
|
+
response = { status: FetchResponse.StatusCode.NOT_FOUND, data: new Uint8Array(0) };
|
|
153
125
|
}
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
response = { status: FetchResponse.StatusCode.ERROR, data: errMsg };
|
|
126
|
+
else {
|
|
127
|
+
log.trace('sending status OK for %m', request.identifier);
|
|
128
|
+
response = { status: FetchResponse.StatusCode.OK, data };
|
|
158
129
|
}
|
|
159
130
|
}
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
});
|
|
166
|
-
}
|
|
167
|
-
catch (err) {
|
|
168
|
-
this.log.error('error answering fetch request - %e', err);
|
|
169
|
-
stream.abort(err);
|
|
131
|
+
catch (err) {
|
|
132
|
+
log.error('error during lookup of %m - %e', request.identifier, err);
|
|
133
|
+
const errMsg = uint8arrayFromString(err.message);
|
|
134
|
+
response = { status: FetchResponse.StatusCode.ERROR, data: errMsg };
|
|
135
|
+
}
|
|
170
136
|
}
|
|
137
|
+
await pb.write(response, FetchResponse, {
|
|
138
|
+
signal
|
|
139
|
+
});
|
|
140
|
+
await stream.close({
|
|
141
|
+
signal
|
|
142
|
+
});
|
|
171
143
|
}
|
|
172
144
|
/**
|
|
173
145
|
* Given a key, finds the appropriate function for looking up its corresponding value, based on
|
package/dist/src/fetch.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"fetch.js","sourceRoot":"","sources":["../../src/fetch.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,
|
|
1
|
+
{"version":3,"file":"fetch.js","sourceRoot":"","sources":["../../src/fetch.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,mBAAmB,EAAE,sBAAsB,EAAE,aAAa,EAAE,MAAM,mBAAmB,CAAA;AAC9F,OAAO,EAAE,QAAQ,EAAE,MAAM,eAAe,CAAA;AACxC,OAAO,EAAE,eAAe,EAAE,MA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YACrC,MAAM,IAAI,sBAAsB,CAAC,0CAA0C,MAAM,sBAAsB,CAAC,CAAA;QAC1G,CAAC;QAED,IAAI,CAAC,eAAe,CAAC,GAAG,CAAC,MAAM,EAAE,MAAM,CAAC,CAAA;IAC1C,CAAC;IAED;;;;;;;;;;OAUG;IACH,wBAAwB,CAAE,MAAc,EAAE,MAAuB;QAC/D,IAAI,MAAM,IAAI,IAAI,EAAE,CAAC;YACnB,MAAM,cAAc,GAAG,IAAI,CAAC,eAAe,CAAC,GAAG,CAAC,MAAM,CAAC,CAAA;YAEvD,IAAI,cAAc,KAAK,MAAM,EAAE,CAAC;gBAC9B,OAAM;YACR,CAAC;QACH,CAAC;QAED,IAAI,CAAC,eAAe,CAAC,MAAM,CAAC,MAAM,CAAC,CAAA;IACrC,CAAC;CACF"}
|
package/dist/src/index.d.ts
CHANGED
|
@@ -41,7 +41,7 @@
|
|
|
41
41
|
* })
|
|
42
42
|
* ```
|
|
43
43
|
*/
|
|
44
|
-
import type { AbortOptions,
|
|
44
|
+
import type { AbortOptions, PeerId } from '@libp2p/interface';
|
|
45
45
|
import type { ConnectionManager, Registrar } from '@libp2p/interface-internal';
|
|
46
46
|
export interface FetchInit {
|
|
47
47
|
protocolPrefix?: string;
|
|
@@ -65,7 +65,6 @@ export interface LookupFunction {
|
|
|
65
65
|
export interface FetchComponents {
|
|
66
66
|
registrar: Registrar;
|
|
67
67
|
connectionManager: ConnectionManager;
|
|
68
|
-
logger: ComponentLogger;
|
|
69
68
|
}
|
|
70
69
|
export interface Fetch {
|
|
71
70
|
/**
|
package/dist/src/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA0CG;AAGH,OAAO,KAAK,EAAE,YAAY,EAAE,
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot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","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA0CG;AAEH,OAAO,EAAE,KAAK,IAAI,UAAU,EAAE,MAAM,YAAY,CAAA;
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA0CG;AAEH,OAAO,EAAE,KAAK,IAAI,UAAU,EAAE,MAAM,YAAY,CAAA;AAgEhD,MAAM,UAAU,KAAK,CAAE,OAAkB,EAAE;IACzC,OAAO,CAAC,UAAU,EAAE,EAAE,CAAC,IAAI,UAAU,CAAC,UAAU,EAAE,IAAI,CAAC,CAAA;AACzD,CAAC"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@libp2p/fetch",
|
|
3
|
-
"version": "3.0.
|
|
3
|
+
"version": "3.0.22-8484de8a2",
|
|
4
4
|
"description": "Implementation of the Fetch Protocol",
|
|
5
5
|
"license": "Apache-2.0 OR MIT",
|
|
6
6
|
"homepage": "https://github.com/libp2p/js-libp2p/tree/main/packages/protocol-fetch#readme",
|
|
@@ -45,22 +45,20 @@
|
|
|
45
45
|
"doc-check": "aegir doc-check"
|
|
46
46
|
},
|
|
47
47
|
"dependencies": {
|
|
48
|
-
"@libp2p/interface": "
|
|
49
|
-
"@libp2p/interface-internal": "
|
|
50
|
-
"
|
|
48
|
+
"@libp2p/interface": "2.11.0-8484de8a2",
|
|
49
|
+
"@libp2p/interface-internal": "2.3.19-8484de8a2",
|
|
50
|
+
"@libp2p/utils": "6.7.2-8484de8a2",
|
|
51
51
|
"main-event": "^1.0.1",
|
|
52
|
-
"protons-runtime": "^5.
|
|
52
|
+
"protons-runtime": "^5.6.0",
|
|
53
53
|
"uint8arraylist": "^2.4.8",
|
|
54
54
|
"uint8arrays": "^5.1.0"
|
|
55
55
|
},
|
|
56
56
|
"devDependencies": {
|
|
57
|
-
"@libp2p/crypto": "
|
|
58
|
-
"@libp2p/
|
|
59
|
-
"
|
|
60
|
-
"
|
|
61
|
-
"
|
|
62
|
-
"protons": "^7.6.1",
|
|
63
|
-
"sinon": "^20.0.0",
|
|
57
|
+
"@libp2p/crypto": "5.1.8-8484de8a2",
|
|
58
|
+
"@libp2p/peer-id": "5.1.9-8484de8a2",
|
|
59
|
+
"aegir": "^47.0.21",
|
|
60
|
+
"protons": "^7.7.0",
|
|
61
|
+
"sinon": "^21.0.0",
|
|
64
62
|
"sinon-ts": "^2.0.0"
|
|
65
63
|
},
|
|
66
64
|
"sideEffects": false
|
package/src/fetch.ts
CHANGED
|
@@ -1,14 +1,14 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { pbStream } from '
|
|
1
|
+
import { InvalidMessageError, InvalidParametersError, ProtocolError } from '@libp2p/interface'
|
|
2
|
+
import { pbStream } from '@libp2p/utils'
|
|
3
3
|
import { setMaxListeners } from 'main-event'
|
|
4
4
|
import { fromString as uint8arrayFromString } from 'uint8arrays/from-string'
|
|
5
5
|
import { toString as uint8arrayToString } from 'uint8arrays/to-string'
|
|
6
6
|
import { PROTOCOL_NAME, PROTOCOL_VERSION } from './constants.js'
|
|
7
7
|
import { FetchRequest, FetchResponse } from './pb/proto.js'
|
|
8
8
|
import type { Fetch as FetchInterface, FetchComponents, FetchInit, LookupFunction } from './index.js'
|
|
9
|
-
import type { AbortOptions,
|
|
9
|
+
import type { AbortOptions, Stream, PeerId, Startable } from '@libp2p/interface'
|
|
10
10
|
|
|
11
|
-
const DEFAULT_TIMEOUT =
|
|
11
|
+
const DEFAULT_TIMEOUT = 10_000
|
|
12
12
|
|
|
13
13
|
/**
|
|
14
14
|
* A simple libp2p protocol for requesting a value corresponding to a key from a peer.
|
|
@@ -22,30 +22,21 @@ export class Fetch implements Startable, FetchInterface {
|
|
|
22
22
|
private readonly lookupFunctions: Map<string, LookupFunction>
|
|
23
23
|
private started: boolean
|
|
24
24
|
private readonly init: FetchInit
|
|
25
|
-
private readonly log: Logger
|
|
26
25
|
|
|
27
26
|
constructor (components: FetchComponents, init: FetchInit = {}) {
|
|
28
|
-
this.log = components.logger.forComponent('libp2p:fetch')
|
|
29
27
|
this.started = false
|
|
30
28
|
this.components = components
|
|
31
29
|
this.protocol = `/${init.protocolPrefix ?? 'libp2p'}/${PROTOCOL_NAME}/${PROTOCOL_VERSION}`
|
|
32
30
|
this.lookupFunctions = new Map() // Maps key prefix to value lookup function
|
|
33
|
-
this.handleMessage = this.handleMessage.bind(this)
|
|
34
31
|
this.init = init
|
|
32
|
+
|
|
33
|
+
this.handleMessage = this.handleMessage.bind(this)
|
|
35
34
|
}
|
|
36
35
|
|
|
37
36
|
readonly [Symbol.toStringTag] = '@libp2p/fetch'
|
|
38
37
|
|
|
39
38
|
async start (): Promise<void> {
|
|
40
|
-
await this.components.registrar.handle(this.protocol,
|
|
41
|
-
void this.handleMessage(data)
|
|
42
|
-
.then(async () => {
|
|
43
|
-
await data.stream.close()
|
|
44
|
-
})
|
|
45
|
-
.catch(err => {
|
|
46
|
-
this.log.error('error handling message - %e', err)
|
|
47
|
-
})
|
|
48
|
-
}, {
|
|
39
|
+
await this.components.registrar.handle(this.protocol, this.handleMessage, {
|
|
49
40
|
maxInboundStreams: this.init.maxInboundStreams,
|
|
50
41
|
maxOutboundStreams: this.init.maxOutboundStreams
|
|
51
42
|
})
|
|
@@ -69,35 +60,26 @@ export class Fetch implements Startable, FetchInterface {
|
|
|
69
60
|
key = uint8arrayFromString(key)
|
|
70
61
|
}
|
|
71
62
|
|
|
72
|
-
this.log.trace('dialing %s to %p', this.protocol, peer)
|
|
73
|
-
|
|
74
|
-
const connection = await this.components.connectionManager.openConnection(peer, options)
|
|
75
|
-
let signal = options.signal
|
|
76
|
-
let stream: Stream | undefined
|
|
77
|
-
let onAbort = (): void => {}
|
|
78
|
-
|
|
79
63
|
// create a timeout if no abort signal passed
|
|
80
|
-
if (signal == null) {
|
|
64
|
+
if (options.signal == null) {
|
|
81
65
|
const timeout = this.init.timeout ?? DEFAULT_TIMEOUT
|
|
82
|
-
|
|
83
|
-
signal = AbortSignal.timeout(timeout)
|
|
84
|
-
|
|
66
|
+
const signal = AbortSignal.timeout(timeout)
|
|
85
67
|
setMaxListeners(Infinity, signal)
|
|
86
|
-
}
|
|
87
68
|
|
|
88
|
-
|
|
89
|
-
|
|
69
|
+
options = {
|
|
70
|
+
...options,
|
|
90
71
|
signal
|
|
91
|
-
})
|
|
92
|
-
|
|
93
|
-
onAbort = () => {
|
|
94
|
-
stream?.abort(new AbortError())
|
|
95
72
|
}
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
let stream: Stream | undefined
|
|
96
76
|
|
|
97
|
-
|
|
98
|
-
|
|
77
|
+
try {
|
|
78
|
+
const connection = await this.components.connectionManager.openConnection(peer, options)
|
|
79
|
+
stream = await connection.newStream(this.protocol, options)
|
|
99
80
|
|
|
100
|
-
|
|
81
|
+
const log = stream.log.newScope('fetch')
|
|
82
|
+
log.trace('fetch %m', key)
|
|
101
83
|
|
|
102
84
|
const pb = pbStream(stream)
|
|
103
85
|
await pb.write({
|
|
@@ -105,35 +87,31 @@ export class Fetch implements Startable, FetchInterface {
|
|
|
105
87
|
}, FetchRequest, options)
|
|
106
88
|
|
|
107
89
|
const response = await pb.read(FetchResponse, options)
|
|
108
|
-
|
|
90
|
+
|
|
91
|
+
await stream.close(options)
|
|
109
92
|
|
|
110
93
|
switch (response.status) {
|
|
111
94
|
case (FetchResponse.StatusCode.OK): {
|
|
112
|
-
|
|
95
|
+
log.trace('received status OK for %m', key)
|
|
113
96
|
return response.data
|
|
114
97
|
}
|
|
115
98
|
case (FetchResponse.StatusCode.NOT_FOUND): {
|
|
116
|
-
|
|
99
|
+
log('received status NOT_FOUND for %m', key)
|
|
117
100
|
return
|
|
118
101
|
}
|
|
119
102
|
case (FetchResponse.StatusCode.ERROR): {
|
|
120
|
-
|
|
103
|
+
log('received status ERROR for %m', key)
|
|
121
104
|
const errMsg = uint8arrayToString(response.data)
|
|
122
105
|
throw new ProtocolError('Error in fetch protocol response: ' + errMsg)
|
|
123
106
|
}
|
|
124
107
|
default: {
|
|
125
|
-
|
|
108
|
+
log('received status unknown for %m', key)
|
|
126
109
|
throw new InvalidMessageError('Unknown response status')
|
|
127
110
|
}
|
|
128
111
|
}
|
|
129
112
|
} catch (err: any) {
|
|
130
113
|
stream?.abort(err)
|
|
131
114
|
throw err
|
|
132
|
-
} finally {
|
|
133
|
-
signal.removeEventListener('abort', onAbort)
|
|
134
|
-
if (stream != null) {
|
|
135
|
-
await stream.close()
|
|
136
|
-
}
|
|
137
115
|
}
|
|
138
116
|
}
|
|
139
117
|
|
|
@@ -142,56 +120,51 @@ export class Fetch implements Startable, FetchInterface {
|
|
|
142
120
|
* responds based on looking up the key in the request via the lookup callback that corresponds
|
|
143
121
|
* to the key's prefix.
|
|
144
122
|
*/
|
|
145
|
-
async handleMessage (
|
|
146
|
-
const
|
|
123
|
+
async handleMessage (stream: Stream): Promise<void> {
|
|
124
|
+
const log = stream.log.newScope('fetch')
|
|
147
125
|
const signal = AbortSignal.timeout(this.init.timeout ?? DEFAULT_TIMEOUT)
|
|
148
126
|
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
})
|
|
127
|
+
const pb = pbStream(stream)
|
|
128
|
+
const request = await pb.read(FetchRequest, {
|
|
129
|
+
signal
|
|
130
|
+
})
|
|
154
131
|
|
|
155
|
-
|
|
156
|
-
|
|
132
|
+
let response: FetchResponse
|
|
133
|
+
const key = uint8arrayToString(request.identifier)
|
|
157
134
|
|
|
158
|
-
|
|
135
|
+
const lookup = this._getLookupFunction(key)
|
|
159
136
|
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
}
|
|
177
|
-
} catch (err: any) {
|
|
178
|
-
this.log.error('error during lookup of %m - %e', request.identifier, err)
|
|
179
|
-
const errMsg = uint8arrayFromString(err.message)
|
|
180
|
-
response = { status: FetchResponse.StatusCode.ERROR, data: errMsg }
|
|
137
|
+
if (lookup == null) {
|
|
138
|
+
log.trace('sending status ERROR for %m', request.identifier)
|
|
139
|
+
const errMsg = uint8arrayFromString('No lookup function registered for key')
|
|
140
|
+
response = { status: FetchResponse.StatusCode.ERROR, data: errMsg }
|
|
141
|
+
} else {
|
|
142
|
+
log.trace('lookup data with identifier %s', lookup.prefix)
|
|
143
|
+
|
|
144
|
+
try {
|
|
145
|
+
const data = await lookup.fn(request.identifier)
|
|
146
|
+
|
|
147
|
+
if (data == null) {
|
|
148
|
+
log.trace('sending status NOT_FOUND for %m', request.identifier)
|
|
149
|
+
response = { status: FetchResponse.StatusCode.NOT_FOUND, data: new Uint8Array(0) }
|
|
150
|
+
} else {
|
|
151
|
+
log.trace('sending status OK for %m', request.identifier)
|
|
152
|
+
response = { status: FetchResponse.StatusCode.OK, data }
|
|
181
153
|
}
|
|
154
|
+
} catch (err: any) {
|
|
155
|
+
log.error('error during lookup of %m - %e', request.identifier, err)
|
|
156
|
+
const errMsg = uint8arrayFromString(err.message)
|
|
157
|
+
response = { status: FetchResponse.StatusCode.ERROR, data: errMsg }
|
|
182
158
|
}
|
|
159
|
+
}
|
|
183
160
|
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
161
|
+
await pb.write(response, FetchResponse, {
|
|
162
|
+
signal
|
|
163
|
+
})
|
|
187
164
|
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
} catch (err: any) {
|
|
192
|
-
this.log.error('error answering fetch request - %e', err)
|
|
193
|
-
stream.abort(err)
|
|
194
|
-
}
|
|
165
|
+
await stream.close({
|
|
166
|
+
signal
|
|
167
|
+
})
|
|
195
168
|
}
|
|
196
169
|
|
|
197
170
|
/**
|
package/src/index.ts
CHANGED
|
@@ -43,7 +43,7 @@
|
|
|
43
43
|
*/
|
|
44
44
|
|
|
45
45
|
import { Fetch as FetchClass } from './fetch.js'
|
|
46
|
-
import type { AbortOptions,
|
|
46
|
+
import type { AbortOptions, PeerId } from '@libp2p/interface'
|
|
47
47
|
import type { ConnectionManager, Registrar } from '@libp2p/interface-internal'
|
|
48
48
|
|
|
49
49
|
export interface FetchInit {
|
|
@@ -71,7 +71,6 @@ export interface LookupFunction {
|
|
|
71
71
|
export interface FetchComponents {
|
|
72
72
|
registrar: Registrar
|
|
73
73
|
connectionManager: ConnectionManager
|
|
74
|
-
logger: ComponentLogger
|
|
75
74
|
}
|
|
76
75
|
|
|
77
76
|
export interface Fetch {
|
package/dist/typedoc-urls.json
DELETED
|
@@ -1,12 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"Fetch": "https://libp2p.github.io/js-libp2p/interfaces/_libp2p_fetch.Fetch.html",
|
|
3
|
-
".:Fetch": "https://libp2p.github.io/js-libp2p/interfaces/_libp2p_fetch.Fetch.html",
|
|
4
|
-
"FetchComponents": "https://libp2p.github.io/js-libp2p/interfaces/_libp2p_fetch.FetchComponents.html",
|
|
5
|
-
".:FetchComponents": "https://libp2p.github.io/js-libp2p/interfaces/_libp2p_fetch.FetchComponents.html",
|
|
6
|
-
"FetchInit": "https://libp2p.github.io/js-libp2p/interfaces/_libp2p_fetch.FetchInit.html",
|
|
7
|
-
".:FetchInit": "https://libp2p.github.io/js-libp2p/interfaces/_libp2p_fetch.FetchInit.html",
|
|
8
|
-
"LookupFunction": "https://libp2p.github.io/js-libp2p/interfaces/_libp2p_fetch.LookupFunction.html",
|
|
9
|
-
".:LookupFunction": "https://libp2p.github.io/js-libp2p/interfaces/_libp2p_fetch.LookupFunction.html",
|
|
10
|
-
"fetch": "https://libp2p.github.io/js-libp2p/functions/_libp2p_fetch.fetch.html",
|
|
11
|
-
".:fetch": "https://libp2p.github.io/js-libp2p/functions/_libp2p_fetch.fetch.html"
|
|
12
|
-
}
|