@libp2p/utils 4.0.7-effcfaa8e → 5.0.0
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/README.md +1 -1
- package/dist/src/abstract-stream.d.ts +144 -0
- package/dist/src/abstract-stream.d.ts.map +1 -0
- package/dist/src/abstract-stream.js +340 -0
- package/dist/src/abstract-stream.js.map +1 -0
- package/dist/src/address-sort.d.ts +1 -1
- package/dist/src/address-sort.d.ts.map +1 -1
- package/dist/src/address-sort.js.map +1 -1
- package/dist/src/array-equals.js.map +1 -1
- package/dist/src/close-source.d.ts +4 -0
- package/dist/src/close-source.d.ts.map +1 -0
- package/dist/src/close-source.js +11 -0
- package/dist/src/close-source.js.map +1 -0
- package/dist/src/ip-port-to-multiaddr.d.ts.map +1 -1
- package/dist/src/ip-port-to-multiaddr.js +2 -6
- package/dist/src/ip-port-to-multiaddr.js.map +1 -1
- package/dist/src/is-promise.d.ts +2 -0
- package/dist/src/is-promise.d.ts.map +1 -0
- package/dist/src/is-promise.js +9 -0
- package/dist/src/is-promise.js.map +1 -0
- package/dist/src/multiaddr/is-private.js.map +1 -1
- package/dist/src/peer-job-queue.d.ts +33 -0
- package/dist/src/peer-job-queue.d.ts.map +1 -0
- package/dist/src/peer-job-queue.js +81 -0
- package/dist/src/peer-job-queue.js.map +1 -0
- package/dist/src/stream-to-ma-conn.d.ts +2 -1
- package/dist/src/stream-to-ma-conn.d.ts.map +1 -1
- package/dist/src/stream-to-ma-conn.js +57 -35
- package/dist/src/stream-to-ma-conn.js.map +1 -1
- package/dist/src/tracked-map.d.ts +17 -0
- package/dist/src/tracked-map.d.ts.map +1 -0
- package/dist/src/tracked-map.js +38 -0
- package/dist/src/tracked-map.js.map +1 -0
- package/dist/typedoc-urls.json +36 -0
- package/package.json +43 -9
- package/src/abstract-stream.ts +508 -0
- package/src/address-sort.ts +1 -1
- package/src/close-source.ts +14 -0
- package/src/ip-port-to-multiaddr.ts +2 -7
- package/src/is-promise.ts +9 -0
- package/src/peer-job-queue.ts +118 -0
- package/src/stream-to-ma-conn.ts +59 -36
- package/src/tracked-map.ts +65 -0
package/README.md
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
[](http://libp2p.io/)
|
|
2
2
|
[](https://discuss.libp2p.io)
|
|
3
3
|
[](https://codecov.io/gh/libp2p/js-libp2p)
|
|
4
|
-
[](https://github.com/libp2p/js-libp2p/actions/workflows/main.yml?query=branch%3Amain)
|
|
5
5
|
|
|
6
6
|
> Package to aggregate shared logic and dependencies for the libp2p ecosystem
|
|
7
7
|
|
|
@@ -0,0 +1,144 @@
|
|
|
1
|
+
import { Uint8ArrayList } from 'uint8arraylist';
|
|
2
|
+
import type { AbortOptions, Direction, ReadStatus, Stream, StreamStatus, StreamTimeline, WriteStatus } from '@libp2p/interface';
|
|
3
|
+
import type { Logger } from '@libp2p/logger';
|
|
4
|
+
import type { Source } from 'it-stream-types';
|
|
5
|
+
export interface AbstractStreamInit {
|
|
6
|
+
/**
|
|
7
|
+
* A unique identifier for this stream
|
|
8
|
+
*/
|
|
9
|
+
id: string;
|
|
10
|
+
/**
|
|
11
|
+
* The stream direction
|
|
12
|
+
*/
|
|
13
|
+
direction: Direction;
|
|
14
|
+
/**
|
|
15
|
+
* A Logger implementation used to log stream-specific information
|
|
16
|
+
*/
|
|
17
|
+
log: Logger;
|
|
18
|
+
/**
|
|
19
|
+
* User specific stream metadata
|
|
20
|
+
*/
|
|
21
|
+
metadata?: Record<string, unknown>;
|
|
22
|
+
/**
|
|
23
|
+
* Invoked when the stream ends
|
|
24
|
+
*/
|
|
25
|
+
onEnd?(err?: Error | undefined): void;
|
|
26
|
+
/**
|
|
27
|
+
* Invoked when the readable end of the stream is closed
|
|
28
|
+
*/
|
|
29
|
+
onCloseRead?(): void;
|
|
30
|
+
/**
|
|
31
|
+
* Invoked when the writable end of the stream is closed
|
|
32
|
+
*/
|
|
33
|
+
onCloseWrite?(): void;
|
|
34
|
+
/**
|
|
35
|
+
* Invoked when the the stream has been reset by the remote
|
|
36
|
+
*/
|
|
37
|
+
onReset?(): void;
|
|
38
|
+
/**
|
|
39
|
+
* Invoked when the the stream has errored
|
|
40
|
+
*/
|
|
41
|
+
onAbort?(err: Error): void;
|
|
42
|
+
/**
|
|
43
|
+
* How long to wait in ms for stream data to be written to the underlying
|
|
44
|
+
* connection when closing the writable end of the stream. (default: 500)
|
|
45
|
+
*/
|
|
46
|
+
closeTimeout?: number;
|
|
47
|
+
/**
|
|
48
|
+
* After the stream sink has closed, a limit on how long it takes to send
|
|
49
|
+
* a close-write message to the remote peer.
|
|
50
|
+
*/
|
|
51
|
+
sendCloseWriteTimeout?: number;
|
|
52
|
+
}
|
|
53
|
+
export declare abstract class AbstractStream implements Stream {
|
|
54
|
+
id: string;
|
|
55
|
+
direction: Direction;
|
|
56
|
+
timeline: StreamTimeline;
|
|
57
|
+
protocol?: string;
|
|
58
|
+
metadata: Record<string, unknown>;
|
|
59
|
+
source: AsyncGenerator<Uint8ArrayList, void, unknown>;
|
|
60
|
+
status: StreamStatus;
|
|
61
|
+
readStatus: ReadStatus;
|
|
62
|
+
writeStatus: WriteStatus;
|
|
63
|
+
readonly log: Logger;
|
|
64
|
+
private readonly sinkController;
|
|
65
|
+
private readonly sinkEnd;
|
|
66
|
+
private readonly closed;
|
|
67
|
+
private endErr;
|
|
68
|
+
private readonly streamSource;
|
|
69
|
+
private readonly onEnd?;
|
|
70
|
+
private readonly onCloseRead?;
|
|
71
|
+
private readonly onCloseWrite?;
|
|
72
|
+
private readonly onReset?;
|
|
73
|
+
private readonly onAbort?;
|
|
74
|
+
private readonly sendCloseWriteTimeout;
|
|
75
|
+
constructor(init: AbstractStreamInit);
|
|
76
|
+
sink(source: Source<Uint8ArrayList | Uint8Array>): Promise<void>;
|
|
77
|
+
protected onSourceEnd(err?: Error): void;
|
|
78
|
+
protected onSinkEnd(err?: Error): void;
|
|
79
|
+
close(options?: AbortOptions): Promise<void>;
|
|
80
|
+
closeRead(options?: AbortOptions): Promise<void>;
|
|
81
|
+
closeWrite(options?: AbortOptions): Promise<void>;
|
|
82
|
+
/**
|
|
83
|
+
* Close immediately for reading and writing and send a reset message (local
|
|
84
|
+
* error)
|
|
85
|
+
*/
|
|
86
|
+
abort(err: Error): void;
|
|
87
|
+
/**
|
|
88
|
+
* Receive a reset message - close immediately for reading and writing (remote
|
|
89
|
+
* error)
|
|
90
|
+
*/
|
|
91
|
+
reset(): void;
|
|
92
|
+
_closeSinkAndSource(err?: Error): void;
|
|
93
|
+
_closeSink(err?: Error): void;
|
|
94
|
+
_closeSource(err?: Error): void;
|
|
95
|
+
/**
|
|
96
|
+
* The remote closed for writing so we should expect to receive no more
|
|
97
|
+
* messages
|
|
98
|
+
*/
|
|
99
|
+
remoteCloseWrite(): void;
|
|
100
|
+
/**
|
|
101
|
+
* The remote closed for reading so we should not send any more
|
|
102
|
+
* messages
|
|
103
|
+
*/
|
|
104
|
+
remoteCloseRead(): void;
|
|
105
|
+
/**
|
|
106
|
+
* The underlying muxer has closed, no more messages can be sent or will
|
|
107
|
+
* be received, close immediately to free up resources
|
|
108
|
+
*/
|
|
109
|
+
destroy(): void;
|
|
110
|
+
/**
|
|
111
|
+
* When an extending class reads data from it's implementation-specific source,
|
|
112
|
+
* call this method to allow the stream consumer to read the data.
|
|
113
|
+
*/
|
|
114
|
+
sourcePush(data: Uint8ArrayList): void;
|
|
115
|
+
/**
|
|
116
|
+
* Returns the amount of unread data - can be used to prevent large amounts of
|
|
117
|
+
* data building up when the stream consumer is too slow.
|
|
118
|
+
*/
|
|
119
|
+
sourceReadableLength(): number;
|
|
120
|
+
/**
|
|
121
|
+
* Send a message to the remote muxer informing them a new stream is being
|
|
122
|
+
* opened
|
|
123
|
+
*/
|
|
124
|
+
abstract sendNewStream(options?: AbortOptions): void | Promise<void>;
|
|
125
|
+
/**
|
|
126
|
+
* Send a data message to the remote muxer
|
|
127
|
+
*/
|
|
128
|
+
abstract sendData(buf: Uint8ArrayList, options?: AbortOptions): void | Promise<void>;
|
|
129
|
+
/**
|
|
130
|
+
* Send a reset message to the remote muxer
|
|
131
|
+
*/
|
|
132
|
+
abstract sendReset(options?: AbortOptions): void | Promise<void>;
|
|
133
|
+
/**
|
|
134
|
+
* Send a message to the remote muxer, informing them no more data messages
|
|
135
|
+
* will be sent by this end of the stream
|
|
136
|
+
*/
|
|
137
|
+
abstract sendCloseWrite(options?: AbortOptions): void | Promise<void>;
|
|
138
|
+
/**
|
|
139
|
+
* Send a message to the remote muxer, informing them no more data messages
|
|
140
|
+
* will be read by this end of the stream
|
|
141
|
+
*/
|
|
142
|
+
abstract sendCloseRead(options?: AbortOptions): void | Promise<void>;
|
|
143
|
+
}
|
|
144
|
+
//# sourceMappingURL=abstract-stream.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"abstract-stream.d.ts","sourceRoot":"","sources":["../../src/abstract-stream.ts"],"names":[],"mappings":"AAIA,OAAO,EAAE,cAAc,EAAE,MAAM,gBAAgB,CAAA;AAE/C,OAAO,KAAK,EAAE,YAAY,EAAE,SAAS,EAAE,UAAU,EAAE,MAAM,EAAE,YAAY,EAAE,cAAc,EAAE,WAAW,EAAE,MAAM,mBAAmB,CAAA;AAC/H,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,gBAAgB,CAAA;AAC5C,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,iBAAiB,CAAA;AAM7C,MAAM,WAAW,kBAAkB;IACjC;;OAEG;IACH,EAAE,EAAE,MAAM,CAAA;IAEV;;OAEG;IACH,SAAS,EAAE,SAAS,CAAA;IAEpB;;OAEG;IACH,GAAG,EAAE,MAAM,CAAA;IAEX;;OAEG;IACH,QAAQ,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAA;IAElC;;OAEG;IACH,KAAK,CAAC,CAAC,GAAG,CAAC,EAAE,KAAK,GAAG,SAAS,GAAG,IAAI,CAAA;IAErC;;OAEG;IACH,WAAW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OAEG;IACH,QAAQ,CAAC,SAAS,CAAE,OAAO,CAAC,EAAE,YAAY,GAAG,IAAI,GAAG,OAAO,CAAC,IAAI,CAAC;IAEjE;;;OAGG;IACH,QAAQ,CAAC,cAAc,CAAE,OAAO,CAAC,EAAE,YAAY,GAAG,IAAI,GAAG,OAAO,CAAC,IAAI,CAAC;IAEtE;;;OAGG;IACH,QAAQ,CAAC,aAAa,CAAE,OAAO,CAAC,EAAE,YAAY,GAAG,IAAI,GAAG,OAAO,CAAC,IAAI,CAAC;CACtE"}
|
|
@@ -0,0 +1,340 @@
|
|
|
1
|
+
import { CodeError } from '@libp2p/interface';
|
|
2
|
+
import { pushable } from 'it-pushable';
|
|
3
|
+
import defer, {} from 'p-defer';
|
|
4
|
+
import { raceSignal } from 'race-signal';
|
|
5
|
+
import { Uint8ArrayList } from 'uint8arraylist';
|
|
6
|
+
import { closeSource } from './close-source.js';
|
|
7
|
+
const ERR_STREAM_RESET = 'ERR_STREAM_RESET';
|
|
8
|
+
const ERR_SINK_INVALID_STATE = 'ERR_SINK_INVALID_STATE';
|
|
9
|
+
const DEFAULT_SEND_CLOSE_WRITE_TIMEOUT = 5000;
|
|
10
|
+
function isPromise(thing) {
|
|
11
|
+
if (thing == null) {
|
|
12
|
+
return false;
|
|
13
|
+
}
|
|
14
|
+
return typeof thing.then === 'function' &&
|
|
15
|
+
typeof thing.catch === 'function' &&
|
|
16
|
+
typeof thing.finally === 'function';
|
|
17
|
+
}
|
|
18
|
+
export class AbstractStream {
|
|
19
|
+
id;
|
|
20
|
+
direction;
|
|
21
|
+
timeline;
|
|
22
|
+
protocol;
|
|
23
|
+
metadata;
|
|
24
|
+
source;
|
|
25
|
+
status;
|
|
26
|
+
readStatus;
|
|
27
|
+
writeStatus;
|
|
28
|
+
log;
|
|
29
|
+
sinkController;
|
|
30
|
+
sinkEnd;
|
|
31
|
+
closed;
|
|
32
|
+
endErr;
|
|
33
|
+
streamSource;
|
|
34
|
+
onEnd;
|
|
35
|
+
onCloseRead;
|
|
36
|
+
onCloseWrite;
|
|
37
|
+
onReset;
|
|
38
|
+
onAbort;
|
|
39
|
+
sendCloseWriteTimeout;
|
|
40
|
+
constructor(init) {
|
|
41
|
+
this.sinkController = new AbortController();
|
|
42
|
+
this.sinkEnd = defer();
|
|
43
|
+
this.closed = defer();
|
|
44
|
+
this.log = init.log;
|
|
45
|
+
// stream status
|
|
46
|
+
this.status = 'open';
|
|
47
|
+
this.readStatus = 'ready';
|
|
48
|
+
this.writeStatus = 'ready';
|
|
49
|
+
this.id = init.id;
|
|
50
|
+
this.metadata = init.metadata ?? {};
|
|
51
|
+
this.direction = init.direction;
|
|
52
|
+
this.timeline = {
|
|
53
|
+
open: Date.now()
|
|
54
|
+
};
|
|
55
|
+
this.sendCloseWriteTimeout = init.sendCloseWriteTimeout ?? DEFAULT_SEND_CLOSE_WRITE_TIMEOUT;
|
|
56
|
+
this.onEnd = init.onEnd;
|
|
57
|
+
this.onCloseRead = init?.onCloseRead;
|
|
58
|
+
this.onCloseWrite = init?.onCloseWrite;
|
|
59
|
+
this.onReset = init?.onReset;
|
|
60
|
+
this.onAbort = init?.onAbort;
|
|
61
|
+
this.source = this.streamSource = pushable({
|
|
62
|
+
onEnd: (err) => {
|
|
63
|
+
if (err != null) {
|
|
64
|
+
this.log.trace('source ended with error', err);
|
|
65
|
+
}
|
|
66
|
+
else {
|
|
67
|
+
this.log.trace('source ended');
|
|
68
|
+
}
|
|
69
|
+
this.onSourceEnd(err);
|
|
70
|
+
}
|
|
71
|
+
});
|
|
72
|
+
// necessary because the libp2p upgrader wraps the sink function
|
|
73
|
+
this.sink = this.sink.bind(this);
|
|
74
|
+
}
|
|
75
|
+
async sink(source) {
|
|
76
|
+
if (this.writeStatus !== 'ready') {
|
|
77
|
+
throw new CodeError(`writable end state is "${this.writeStatus}" not "ready"`, ERR_SINK_INVALID_STATE);
|
|
78
|
+
}
|
|
79
|
+
try {
|
|
80
|
+
this.writeStatus = 'writing';
|
|
81
|
+
const options = {
|
|
82
|
+
signal: this.sinkController.signal
|
|
83
|
+
};
|
|
84
|
+
if (this.direction === 'outbound') { // If initiator, open a new stream
|
|
85
|
+
const res = this.sendNewStream(options);
|
|
86
|
+
if (isPromise(res)) {
|
|
87
|
+
await res;
|
|
88
|
+
}
|
|
89
|
+
}
|
|
90
|
+
const abortListener = () => {
|
|
91
|
+
closeSource(source, this.log);
|
|
92
|
+
};
|
|
93
|
+
try {
|
|
94
|
+
this.sinkController.signal.addEventListener('abort', abortListener);
|
|
95
|
+
this.log.trace('sink reading from source');
|
|
96
|
+
for await (let data of source) {
|
|
97
|
+
data = data instanceof Uint8Array ? new Uint8ArrayList(data) : data;
|
|
98
|
+
const res = this.sendData(data, options);
|
|
99
|
+
if (isPromise(res)) { // eslint-disable-line max-depth
|
|
100
|
+
await res;
|
|
101
|
+
}
|
|
102
|
+
}
|
|
103
|
+
}
|
|
104
|
+
finally {
|
|
105
|
+
this.sinkController.signal.removeEventListener('abort', abortListener);
|
|
106
|
+
}
|
|
107
|
+
this.log.trace('sink finished reading from source, write status is "%s"', this.writeStatus);
|
|
108
|
+
if (this.writeStatus === 'writing') {
|
|
109
|
+
this.writeStatus = 'closing';
|
|
110
|
+
this.log.trace('send close write to remote');
|
|
111
|
+
await this.sendCloseWrite({
|
|
112
|
+
signal: AbortSignal.timeout(this.sendCloseWriteTimeout)
|
|
113
|
+
});
|
|
114
|
+
this.writeStatus = 'closed';
|
|
115
|
+
}
|
|
116
|
+
this.onSinkEnd();
|
|
117
|
+
}
|
|
118
|
+
catch (err) {
|
|
119
|
+
this.log.trace('sink ended with error, calling abort with error', err);
|
|
120
|
+
this.abort(err);
|
|
121
|
+
throw err;
|
|
122
|
+
}
|
|
123
|
+
finally {
|
|
124
|
+
this.log.trace('resolve sink end');
|
|
125
|
+
this.sinkEnd.resolve();
|
|
126
|
+
}
|
|
127
|
+
}
|
|
128
|
+
onSourceEnd(err) {
|
|
129
|
+
if (this.timeline.closeRead != null) {
|
|
130
|
+
return;
|
|
131
|
+
}
|
|
132
|
+
this.timeline.closeRead = Date.now();
|
|
133
|
+
this.readStatus = 'closed';
|
|
134
|
+
if (err != null && this.endErr == null) {
|
|
135
|
+
this.endErr = err;
|
|
136
|
+
}
|
|
137
|
+
this.onCloseRead?.();
|
|
138
|
+
if (this.timeline.closeWrite != null) {
|
|
139
|
+
this.log.trace('source and sink ended');
|
|
140
|
+
this.timeline.close = Date.now();
|
|
141
|
+
if (this.status !== 'aborted' && this.status !== 'reset') {
|
|
142
|
+
this.status = 'closed';
|
|
143
|
+
}
|
|
144
|
+
if (this.onEnd != null) {
|
|
145
|
+
this.onEnd(this.endErr);
|
|
146
|
+
}
|
|
147
|
+
this.closed.resolve();
|
|
148
|
+
}
|
|
149
|
+
else {
|
|
150
|
+
this.log.trace('source ended, waiting for sink to end');
|
|
151
|
+
}
|
|
152
|
+
}
|
|
153
|
+
onSinkEnd(err) {
|
|
154
|
+
if (this.timeline.closeWrite != null) {
|
|
155
|
+
return;
|
|
156
|
+
}
|
|
157
|
+
this.timeline.closeWrite = Date.now();
|
|
158
|
+
this.writeStatus = 'closed';
|
|
159
|
+
if (err != null && this.endErr == null) {
|
|
160
|
+
this.endErr = err;
|
|
161
|
+
}
|
|
162
|
+
this.onCloseWrite?.();
|
|
163
|
+
if (this.timeline.closeRead != null) {
|
|
164
|
+
this.log.trace('sink and source ended');
|
|
165
|
+
this.timeline.close = Date.now();
|
|
166
|
+
if (this.status !== 'aborted' && this.status !== 'reset') {
|
|
167
|
+
this.status = 'closed';
|
|
168
|
+
}
|
|
169
|
+
if (this.onEnd != null) {
|
|
170
|
+
this.onEnd(this.endErr);
|
|
171
|
+
}
|
|
172
|
+
this.closed.resolve();
|
|
173
|
+
}
|
|
174
|
+
else {
|
|
175
|
+
this.log.trace('sink ended, waiting for source to end');
|
|
176
|
+
}
|
|
177
|
+
}
|
|
178
|
+
// Close for both Reading and Writing
|
|
179
|
+
async close(options) {
|
|
180
|
+
this.log.trace('closing gracefully');
|
|
181
|
+
this.status = 'closing';
|
|
182
|
+
await Promise.all([
|
|
183
|
+
this.closeRead(options),
|
|
184
|
+
this.closeWrite(options)
|
|
185
|
+
]);
|
|
186
|
+
// wait for read and write ends to close
|
|
187
|
+
await raceSignal(this.closed.promise, options?.signal);
|
|
188
|
+
this.status = 'closed';
|
|
189
|
+
this.log.trace('closed gracefully');
|
|
190
|
+
}
|
|
191
|
+
async closeRead(options = {}) {
|
|
192
|
+
if (this.readStatus === 'closing' || this.readStatus === 'closed') {
|
|
193
|
+
return;
|
|
194
|
+
}
|
|
195
|
+
this.log.trace('closing readable end of stream with starting read status "%s"', this.readStatus);
|
|
196
|
+
const readStatus = this.readStatus;
|
|
197
|
+
this.readStatus = 'closing';
|
|
198
|
+
if (this.status !== 'reset' && this.status !== 'aborted' && this.timeline.closeRead == null) {
|
|
199
|
+
this.log.trace('send close read to remote');
|
|
200
|
+
await this.sendCloseRead(options);
|
|
201
|
+
}
|
|
202
|
+
if (readStatus === 'ready') {
|
|
203
|
+
this.log.trace('ending internal source queue with %d queued bytes', this.streamSource.readableLength);
|
|
204
|
+
this.streamSource.end();
|
|
205
|
+
}
|
|
206
|
+
this.log.trace('closed readable end of stream');
|
|
207
|
+
}
|
|
208
|
+
async closeWrite(options = {}) {
|
|
209
|
+
if (this.writeStatus === 'closing' || this.writeStatus === 'closed') {
|
|
210
|
+
return;
|
|
211
|
+
}
|
|
212
|
+
this.log.trace('closing writable end of stream with starting write status "%s"', this.writeStatus);
|
|
213
|
+
if (this.writeStatus === 'ready') {
|
|
214
|
+
this.log.trace('sink was never sunk, sink an empty array');
|
|
215
|
+
await raceSignal(this.sink([]), options.signal);
|
|
216
|
+
}
|
|
217
|
+
if (this.writeStatus === 'writing') {
|
|
218
|
+
// stop reading from the source passed to `.sink` in the microtask queue
|
|
219
|
+
// - this lets any data queued by the user in the current tick get read
|
|
220
|
+
// before we exit
|
|
221
|
+
await new Promise((resolve, reject) => {
|
|
222
|
+
queueMicrotask(() => {
|
|
223
|
+
this.log.trace('aborting source passed to .sink');
|
|
224
|
+
this.sinkController.abort();
|
|
225
|
+
raceSignal(this.sinkEnd.promise, options.signal)
|
|
226
|
+
.then(resolve, reject);
|
|
227
|
+
});
|
|
228
|
+
});
|
|
229
|
+
}
|
|
230
|
+
this.writeStatus = 'closed';
|
|
231
|
+
this.log.trace('closed writable end of stream');
|
|
232
|
+
}
|
|
233
|
+
/**
|
|
234
|
+
* Close immediately for reading and writing and send a reset message (local
|
|
235
|
+
* error)
|
|
236
|
+
*/
|
|
237
|
+
abort(err) {
|
|
238
|
+
if (this.status === 'closed' || this.status === 'aborted' || this.status === 'reset') {
|
|
239
|
+
return;
|
|
240
|
+
}
|
|
241
|
+
this.log('abort with error', err);
|
|
242
|
+
// try to send a reset message
|
|
243
|
+
this.log('try to send reset to remote');
|
|
244
|
+
const res = this.sendReset();
|
|
245
|
+
if (isPromise(res)) {
|
|
246
|
+
res.catch((err) => {
|
|
247
|
+
this.log.error('error sending reset message', err);
|
|
248
|
+
});
|
|
249
|
+
}
|
|
250
|
+
this.status = 'aborted';
|
|
251
|
+
this.timeline.abort = Date.now();
|
|
252
|
+
this._closeSinkAndSource(err);
|
|
253
|
+
this.onAbort?.(err);
|
|
254
|
+
}
|
|
255
|
+
/**
|
|
256
|
+
* Receive a reset message - close immediately for reading and writing (remote
|
|
257
|
+
* error)
|
|
258
|
+
*/
|
|
259
|
+
reset() {
|
|
260
|
+
if (this.status === 'closed' || this.status === 'aborted' || this.status === 'reset') {
|
|
261
|
+
return;
|
|
262
|
+
}
|
|
263
|
+
const err = new CodeError('stream reset', ERR_STREAM_RESET);
|
|
264
|
+
this.status = 'reset';
|
|
265
|
+
this.timeline.reset = Date.now();
|
|
266
|
+
this._closeSinkAndSource(err);
|
|
267
|
+
this.onReset?.();
|
|
268
|
+
}
|
|
269
|
+
_closeSinkAndSource(err) {
|
|
270
|
+
this._closeSink(err);
|
|
271
|
+
this._closeSource(err);
|
|
272
|
+
}
|
|
273
|
+
_closeSink(err) {
|
|
274
|
+
// if the sink function is running, cause it to end
|
|
275
|
+
if (this.writeStatus === 'writing') {
|
|
276
|
+
this.log.trace('end sink source');
|
|
277
|
+
this.sinkController.abort();
|
|
278
|
+
}
|
|
279
|
+
this.onSinkEnd(err);
|
|
280
|
+
}
|
|
281
|
+
_closeSource(err) {
|
|
282
|
+
// if the source is not ending, end it
|
|
283
|
+
if (this.readStatus !== 'closing' && this.readStatus !== 'closed') {
|
|
284
|
+
this.log.trace('ending source with %d bytes to be read by consumer', this.streamSource.readableLength);
|
|
285
|
+
this.readStatus = 'closing';
|
|
286
|
+
this.streamSource.end(err);
|
|
287
|
+
}
|
|
288
|
+
}
|
|
289
|
+
/**
|
|
290
|
+
* The remote closed for writing so we should expect to receive no more
|
|
291
|
+
* messages
|
|
292
|
+
*/
|
|
293
|
+
remoteCloseWrite() {
|
|
294
|
+
if (this.readStatus === 'closing' || this.readStatus === 'closed') {
|
|
295
|
+
this.log('received remote close write but local source is already closed');
|
|
296
|
+
return;
|
|
297
|
+
}
|
|
298
|
+
this.log.trace('remote close write');
|
|
299
|
+
this._closeSource();
|
|
300
|
+
}
|
|
301
|
+
/**
|
|
302
|
+
* The remote closed for reading so we should not send any more
|
|
303
|
+
* messages
|
|
304
|
+
*/
|
|
305
|
+
remoteCloseRead() {
|
|
306
|
+
if (this.writeStatus === 'closing' || this.writeStatus === 'closed') {
|
|
307
|
+
this.log('received remote close read but local sink is already closed');
|
|
308
|
+
return;
|
|
309
|
+
}
|
|
310
|
+
this.log.trace('remote close read');
|
|
311
|
+
this._closeSink();
|
|
312
|
+
}
|
|
313
|
+
/**
|
|
314
|
+
* The underlying muxer has closed, no more messages can be sent or will
|
|
315
|
+
* be received, close immediately to free up resources
|
|
316
|
+
*/
|
|
317
|
+
destroy() {
|
|
318
|
+
if (this.status === 'closed' || this.status === 'aborted' || this.status === 'reset') {
|
|
319
|
+
this.log('received destroy but we are already closed');
|
|
320
|
+
return;
|
|
321
|
+
}
|
|
322
|
+
this.log.trace('stream destroyed');
|
|
323
|
+
this._closeSinkAndSource();
|
|
324
|
+
}
|
|
325
|
+
/**
|
|
326
|
+
* When an extending class reads data from it's implementation-specific source,
|
|
327
|
+
* call this method to allow the stream consumer to read the data.
|
|
328
|
+
*/
|
|
329
|
+
sourcePush(data) {
|
|
330
|
+
this.streamSource.push(data);
|
|
331
|
+
}
|
|
332
|
+
/**
|
|
333
|
+
* Returns the amount of unread data - can be used to prevent large amounts of
|
|
334
|
+
* data building up when the stream consumer is too slow.
|
|
335
|
+
*/
|
|
336
|
+
sourceReadableLength() {
|
|
337
|
+
return this.streamSource.readableLength;
|
|
338
|
+
}
|
|
339
|
+
}
|
|
340
|
+
//# sourceMappingURL=abstract-stream.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"abstract-stream.js","sourceRoot":"","sources":["../../src/abstract-stream.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,mBAAmB,CAAA;AAC7C,OAAO,EAAiB,QAAQ,EAAE,MAAM,aAAa,CAAA;AACrD,OAAO,KAAK,EAAE,EAAwB,MAAM,SAAS,CAAA;AACrD,OAAO,EAAE,UAAU,EAAE,MAAM,aAAa,CAAA;AACxC,OAAO,EAAE,cAAc,EAAE,MAAM,gBAAgB,CAAA;AAC/C,OAAO,EAAE,WAAW,EAAE,MAAM,mBAAmB,CAAA;AAK/C,MAAM,gBAAgB,GAAG,kBAAkB,CAAA;AAC3C,MAAM,sBAAsB,GAAG,wBAAwB,CAAA;AACvD,MAAM,gCAAgC,GAAG,IAAI,CAAA;AA6D7C,SAAS,SAAS,CAAgB,KAAU;IAC1C,IAAI,KAAK,IAAI,IAAI,EAAE,CAAC;QAClB,OAAO,KAAK,CAAA;IACd,CAAC;IAED,OAAO,OAAO,KAAK,CAAC,IAAI,KAAK,UAAU;QACrC,OAAO,KAAK,CAAC,KAAK,KAAK,UAAU;QACjC,OAAO,KAAK,CAAC,OAAO,KAAK,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AS,IAAI,IAAI,CAAC,WAAW,KAAK,QAAQ,EAAE,CAAC;YACpE,IAAI,CAAC,GAAG,CAAC,6DAA6D,CAAC,CAAA;YACvE,OAAM;QACR,CAAC;QAED,IAAI,CAAC,GAAG,CAAC,KAAK,CAAC,mBAAmB,CAAC,CAAA;QACnC,IAAI,CAAC,UAAU,EAAE,CAAA;IACnB,CAAC;IAED;;;OAGG;IACH,OAAO;QACL,IAAI,IAAI,CAAC,MAAM,KAAK,QAAQ,IAAI,IAAI,CAAC,MAAM,KAAK,SAAS,IAAI,IAAI,CAAC,MAAM,KAAK,OAAO,EAAE,CAAC;YACrF,IAAI,CAAC,GAAG,CAAC,4CAA4C,CAAC,CAAA;YACtD,OAAM;QACR,CAAC;QAED,IAAI,CAAC,GAAG,CAAC,KAAK,CAAC,kBAAkB,CAAC,CAAA;QAElC,IAAI,CAAC,mBAAmB,EAAE,CAAA;IAC5B,CAAC;IAED;;;OAGG;IACH,UAAU,CAAE,IAAoB;QAC9B,IAAI,CAAC,YAAY,CAAC,IAAI,CAAC,IAAI,CAAC,CAAA;IAC9B,CAAC;IAED;;;OAGG;IACH,oBAAoB;QAClB,OAAO,IAAI,CAAC,YAAY,CAAC,cAAc,CAAA;IACzC,CAAC;CA6BF"}
|
|
@@ -19,7 +19,7 @@
|
|
|
19
19
|
* // ['/ip4/82.41.53.1/tcp/9000', '/ip4/127.0.0.1/tcp/9000']
|
|
20
20
|
* ```
|
|
21
21
|
*/
|
|
22
|
-
import type { Address } from '@libp2p/interface
|
|
22
|
+
import type { Address } from '@libp2p/interface';
|
|
23
23
|
/**
|
|
24
24
|
* Compare function for array.sort() that moves public addresses to the start
|
|
25
25
|
* of the array.
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"address-sort.d.ts","sourceRoot":"","sources":["../../src/address-sort.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;GAoBG;AAIH,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,
|
|
1
|
+
{"version":3,"file":"address-sort.d.ts","sourceRoot":"","sources":["../../src/address-sort.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;GAoBG;AAIH,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,mBAAmB,CAAA;AAEhD;;;GAGG;AACH,wBAAgB,oBAAoB,CAAE,CAAC,EAAE,OAAO,EAAE,CAAC,EAAE,OAAO,GAAG,CAAC,CAAC,GAAG,CAAC,GAAG,CAAC,CAWxE;AAED;;;GAGG;AACH,wBAAgB,uBAAuB,CAAE,CAAC,EAAE,OAAO,EAAE,CAAC,EAAE,OAAO,GAAG,CAAC,CAAC,GAAG,CAAC,GAAG,CAAC,CAQ3E;AAED;;;GAGG;AACH,wBAAgB,yBAAyB,CAAE,CAAC,EAAE,OAAO,EAAE,CAAC,EAAE,OAAO,GAAG,CAAC,CAAC,GAAG,CAAC,GAAG,CAAC,CAW7E;AAED,wBAAgB,kBAAkB,CAAE,CAAC,EAAE,OAAO,EAAE,CAAC,EAAE,OAAO,GAAG,CAAC,CAAC,GAAG,CAAC,GAAG,CAAC,CAgBtE"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"address-sort.js","sourceRoot":"","sources":["../../src/address-sort.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;GAoBG;AAEH,OAAO,EAAE,OAAO,EAAE,MAAM,iCAAiC,CAAA;AACzD,OAAO,EAAE,SAAS,EAAE,MAAM,2BAA2B,CAAA;AAGrD;;;GAGG;AACH,MAAM,UAAU,oBAAoB,CAAE,CAAU,EAAE,CAAU;IAC1D,MAAM,UAAU,GAAG,SAAS,CAAC,CAAC,CAAC,SAAS,CAAC,CAAA;IACzC,MAAM,UAAU,GAAG,SAAS,CAAC,CAAC,CAAC,SAAS,CAAC,CAAA;IAEzC,IAAI,UAAU,IAAI,CAAC,UAAU,EAAE;
|
|
1
|
+
{"version":3,"file":"address-sort.js","sourceRoot":"","sources":["../../src/address-sort.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QACrC,OAAO,CAAC,CAAC,CAAA;IACX,CAAC;IAED,OAAO,CAAC,CAAA;AACV,CAAC;AAED,MAAM,UAAU,kBAAkB,CAAE,CAAU,EAAE,CAAU;IACxD,MAAM,YAAY,GAAG,oBAAoB,CAAC,CAAC,EAAE,CAAC,CAAC,CAAA;IAE/C,IAAI,YAAY,KAAK,CAAC,EAAE,CAAC;QACvB,OAAO,YAAY,CAAA;IACrB,CAAC;IAED,MAAM,WAAW,GAAG,yBAAyB,CAAC,CAAC,EAAE,CAAC,CAAC,CAAA;IAEnD,IAAI,WAAW,KAAK,CAAC,EAAE,CAAC;QACtB,OAAO,WAAW,CAAA;IACpB,CAAC;IAED,MAAM,eAAe,GAAG,uBAAuB,CAAC,CAAC,EAAE,CAAC,CAAC,CAAA;IAErD,OAAO,eAAe,CAAA;AACxB,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"array-equals.js","sourceRoot":"","sources":["../../src/array-equals.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;GAiBG;AAEH;;;GAGG;AACH,MAAM,UAAU,WAAW,CAAE,CAAQ,EAAE,CAAQ;IAC7C,MAAM,IAAI,GAAG,CAAC,CAAM,EAAE,CAAM,EAAU,EAAE,CAAC,CAAC,CAAC,QAAQ,EAAE,CAAC,aAAa,CAAC,CAAC,CAAC,QAAQ,EAAE,CAAC,CAAA;IAEjF,IAAI,CAAC,CAAC,MAAM,KAAK,CAAC,CAAC,MAAM,EAAE;
|
|
1
|
+
{"version":3,"file":"array-equals.js","sourceRoot":"","sources":["../../src/array-equals.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;GAiBG;AAEH;;;GAGG;AACH,MAAM,UAAU,WAAW,CAAE,CAAQ,EAAE,CAAQ;IAC7C,MAAM,IAAI,GAAG,CAAC,CAAM,EAAE,CAAM,EAAU,EAAE,CAAC,CAAC,CAAC,QAAQ,EAAE,CAAC,aAAa,CAAC,CAAC,CAAC,QAAQ,EAAE,CAAC,CAAA;IAEjF,IAAI,CAAC,CAAC,MAAM,KAAK,CAAC,CAAC,MAAM,EAAE,CAAC;QAC1B,OAAO,KAAK,CAAA;IACd,CAAC;IAED,CAAC,CAAC,IAAI,CAAC,IAAI,CAAC,CAAA;IAEZ,OAAO,CAAC,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC,KAAK,CAAC,CAAC,IAAI,EAAE,KAAK,EAAE,EAAE,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,MAAM,CAAC,IAAI,CAAC,CAAC,CAAA;AACnE,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"close-source.d.ts","sourceRoot":"","sources":["../../src/close-source.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,gBAAgB,CAAA;AAC5C,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,iBAAiB,CAAA;AAE7C,wBAAgB,WAAW,CAAE,MAAM,EAAE,MAAM,CAAC,OAAO,CAAC,EAAE,GAAG,EAAE,MAAM,GAAG,IAAI,CAQvE"}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { getIterator } from 'get-iterator';
|
|
2
|
+
import { isPromise } from './is-promise.js';
|
|
3
|
+
export function closeSource(source, log) {
|
|
4
|
+
const res = getIterator(source).return?.();
|
|
5
|
+
if (isPromise(res)) {
|
|
6
|
+
res.catch(err => {
|
|
7
|
+
log.error('could not cause iterator to return', err);
|
|
8
|
+
});
|
|
9
|
+
}
|
|
10
|
+
}
|
|
11
|
+
//# sourceMappingURL=close-source.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"close-source.js","sourceRoot":"","sources":["../../src/close-source.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,MAAM,cAAc,CAAA;AAC1C,OAAO,EAAE,SAAS,EAAE,MAAM,iBAAiB,CAAA;AAI3C,MAAM,UAAU,WAAW,CAAE,MAAuB,EAAE,GAAW;IAC/D,MAAM,GAAG,GAAG,WAAW,CAAC,MAAM,CAAC,CAAC,MAAM,EAAE,EAAE,CAAA;IAE1C,IAAI,SAAS,CAAC,GAAG,CAAC,EAAE,CAAC;QACnB,GAAG,CAAC,KAAK,CAAC,GAAG,CAAC,EAAE;YACd,GAAG,CAAC,KAAK,CAAC,oCAAoC,EAAE,GAAG,CAAC,CAAA;QACtD,CAAC,CAAC,CAAA;IACJ,CAAC;AACH,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ip-port-to-multiaddr.d.ts","sourceRoot":"","sources":["../../src/ip-port-to-multiaddr.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"ip-port-to-multiaddr.d.ts","sourceRoot":"","sources":["../../src/ip-port-to-multiaddr.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,KAAK,SAAS,EAAa,MAAM,yBAAyB,CAAA;AAEnE,eAAO,MAAM,MAAM;;;;CAIlB,CAAA;AAED;;GAEG;AACH,wBAAgB,iBAAiB,CAAE,EAAE,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,GAAG,MAAM,GAAG,SAAS,CAsB/E"}
|
|
@@ -1,8 +1,6 @@
|
|
|
1
1
|
import { isIPv4, isIPv6 } from '@chainsafe/is-ip';
|
|
2
|
-
import { CodeError } from '@libp2p/interface
|
|
3
|
-
import { logger } from '@libp2p/logger';
|
|
2
|
+
import { CodeError } from '@libp2p/interface';
|
|
4
3
|
import { multiaddr } from '@multiformats/multiaddr';
|
|
5
|
-
const log = logger('libp2p:ip-port-to-multiaddr');
|
|
6
4
|
export const Errors = {
|
|
7
5
|
ERR_INVALID_IP_PARAMETER: 'ERR_INVALID_IP_PARAMETER',
|
|
8
6
|
ERR_INVALID_PORT_PARAMETER: 'ERR_INVALID_PORT_PARAMETER',
|
|
@@ -27,8 +25,6 @@ export function ipPortToMultiaddr(ip, port) {
|
|
|
27
25
|
if (isIPv6(ip)) {
|
|
28
26
|
return multiaddr(`/ip6/${ip}/tcp/${port}`);
|
|
29
27
|
}
|
|
30
|
-
|
|
31
|
-
log.error(errMsg);
|
|
32
|
-
throw new CodeError(errMsg, Errors.ERR_INVALID_IP);
|
|
28
|
+
throw new CodeError(`invalid ip:port for creating a multiaddr: ${ip}:${port}`, Errors.ERR_INVALID_IP);
|
|
33
29
|
}
|
|
34
30
|
//# sourceMappingURL=ip-port-to-multiaddr.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ip-port-to-multiaddr.js","sourceRoot":"","sources":["../../src/ip-port-to-multiaddr.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,kBAAkB,CAAA;AACjD,OAAO,EAAE,SAAS,EAAE,MAAM,
|
|
1
|
+
{"version":3,"file":"ip-port-to-multiaddr.js","sourceRoot":"","sources":["../../src/ip-port-to-multiaddr.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,kBAAkB,CAAA;AACjD,OAAO,EAAE,SAAS,EAAE,MAAM,mBAAmB,CAAA;AAC7C,OAAO,EAAkB,SAAS,EAAE,MAAM,yBAAyB,CAAA;AAEnE,MAAM,CAAC,MAAM,MAAM,GAAG;IACpB,wBAAwB,EAAE,0BAA0B;IACpD,0BAA0B,EAAE,4BAA4B;IACxD,cAAc,EAAE,gBAAgB;CACjC,CAAA;AAED;;GAEG;AACH,MAAM,UAAU,iBAAiB,CAAE,EAAU,EAAE,IAAqB;IAClE,IAAI,OAAO,EAAE,KAAK,QAAQ,EAAE,CAAC;QAC3B,MAAM,IAAI,SAAS,CAAC,wBAAwB,EAAE,EAAE,EAAE,MAAM,CAAC,wBAAwB,CAAC,CAAA,CAAC,uEAAuE;IAC5J,CAAC;IAED,IAAI,OAAO,IAAI,KAAK,QAAQ,EAAE,CAAC;QAC7B,IAAI,GAAG,QAAQ,CAAC,IAAI,CAAC,CAAA;IACvB,CAAC;IAED,IAAI,KAAK,CAAC,IAAI,CAAC,EAAE,CAAC;QAChB,MAAM,IAAI,SAAS,CAAC,0BAA0B,IAAI,EAAE,EAAE,MAAM,CAAC,0BAA0B,CAAC,CAAA;IAC1F,CAAC;IAED,IAAI,MAAM,CAAC,EAAE,CAAC,EAAE,CAAC;QACf,OAAO,SAAS,CAAC,QAAQ,EAAE,QAAQ,IAAI,EAAE,CAAC,CAAA;IAC5C,CAAC;IAED,IAAI,MAAM,CAAC,EAAE,CAAC,EAAE,CAAC;QACf,OAAO,SAAS,CAAC,QAAQ,EAAE,QAAQ,IAAI,EAAE,CAAC,CAAA;IAC5C,CAAC;IAED,MAAM,IAAI,SAAS,CAAC,6CAA6C,EAAE,IAAI,IAAI,EAAE,EAAE,MAAM,CAAC,cAAc,CAAC,CAAA;AACvG,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"is-promise.d.ts","sourceRoot":"","sources":["../../src/is-promise.ts"],"names":[],"mappings":"AAAA,wBAAgB,SAAS,CAAE,CAAC,GAAG,OAAO,EAAG,KAAK,EAAE,GAAG,GAAG,KAAK,IAAI,OAAO,CAAC,CAAC,CAAC,CAQxE"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"is-promise.js","sourceRoot":"","sources":["../../src/is-promise.ts"],"names":[],"mappings":"AAAA,MAAM,UAAU,SAAS,CAAgB,KAAU;IACjD,IAAI,KAAK,IAAI,IAAI,EAAE,CAAC;QAClB,OAAO,KAAK,CAAA;IACd,CAAC;IAED,OAAO,OAAO,KAAK,CAAC,IAAI,KAAK,UAAU;QACrC,OAAO,KAAK,CAAC,KAAK,KAAK,UAAU;QACjC,OAAO,KAAK,CAAC,OAAO,KAAK,UAAU,CAAA;AACvC,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"is-private.js","sourceRoot":"","sources":["../../../src/multiaddr/is-private.ts"],"names":[],"mappings":"AAAA,OAAO,WAAW,MAAM,YAAY,CAAA;AAGpC;;GAEG;AACH,MAAM,UAAU,SAAS,CAAE,EAAa;IACtC,IAAI;
|
|
1
|
+
{"version":3,"file":"is-private.js","sourceRoot":"","sources":["../../../src/multiaddr/is-private.ts"],"names":[],"mappings":"AAAA,OAAO,WAAW,MAAM,YAAY,CAAA;AAGpC;;GAEG;AACH,MAAM,UAAU,SAAS,CAAE,EAAa;IACtC,IAAI,CAAC;QACH,MAAM,EAAE,OAAO,EAAE,GAAG,EAAE,CAAC,WAAW,EAAE,CAAA;QAEpC,OAAO,OAAO,CAAC,WAAW,CAAC,OAAO,CAAC,CAAC,CAAA;IACtC,CAAC;IAAC,MAAM,CAAC;QACP,OAAO,IAAI,CAAA;IACb,CAAC;AACH,CAAC"}
|