libp2p 1.0.9 → 1.0.10-07f3afe2d
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 +35 -35
- package/dist/src/connection-manager/dial-queue.d.ts.map +1 -1
- package/dist/src/connection-manager/dial-queue.js +4 -6
- package/dist/src/connection-manager/dial-queue.js.map +1 -1
- package/dist/src/{content-routing/index.d.ts → content-routing.d.ts} +6 -3
- package/dist/src/content-routing.d.ts.map +1 -0
- package/dist/src/content-routing.js +113 -0
- package/dist/src/content-routing.js.map +1 -0
- package/dist/src/libp2p.d.ts.map +1 -1
- package/dist/src/libp2p.js +7 -3
- package/dist/src/libp2p.js.map +1 -1
- package/dist/src/peer-routing.d.ts +3 -3
- package/dist/src/peer-routing.d.ts.map +1 -1
- package/dist/src/peer-routing.js +57 -10
- package/dist/src/peer-routing.js.map +1 -1
- package/dist/src/upgrader.d.ts.map +1 -1
- package/dist/src/upgrader.js +4 -2
- package/dist/src/upgrader.js.map +1 -1
- package/dist/src/version.d.ts +1 -1
- package/dist/src/version.d.ts.map +1 -1
- package/dist/src/version.js +1 -1
- package/dist/src/version.js.map +1 -1
- package/package.json +25 -27
- package/src/connection-manager/dial-queue.ts +8 -11
- package/src/{content-routing/index.ts → content-routing.ts} +66 -18
- package/src/libp2p.ts +7 -3
- package/src/peer-routing.ts +78 -35
- package/src/upgrader.ts +4 -2
- package/src/version.ts +1 -1
- package/dist/src/content-routing/index.d.ts.map +0 -1
- package/dist/src/content-routing/index.js +0 -67
- package/dist/src/content-routing/index.js.map +0 -1
- package/dist/src/content-routing/utils.d.ts +0 -15
- package/dist/src/content-routing/utils.d.ts.map +0 -1
- package/dist/src/content-routing/utils.js +0 -44
- package/dist/src/content-routing/utils.js.map +0 -1
- package/dist/typedoc-urls.json +0 -10
- package/src/content-routing/utils.ts +0 -55
|
@@ -1,15 +0,0 @@
|
|
|
1
|
-
import type { PeerInfo, PeerStore } from '@libp2p/interface';
|
|
2
|
-
import type { Source } from 'it-stream-types';
|
|
3
|
-
/**
|
|
4
|
-
* Store the multiaddrs from every peer in the passed peer store
|
|
5
|
-
*/
|
|
6
|
-
export declare function storeAddresses(source: Source<PeerInfo>, peerStore: PeerStore): AsyncIterable<PeerInfo>;
|
|
7
|
-
/**
|
|
8
|
-
* Filter peers by unique peer id
|
|
9
|
-
*/
|
|
10
|
-
export declare function uniquePeers(source: Source<PeerInfo>): AsyncIterable<PeerInfo>;
|
|
11
|
-
/**
|
|
12
|
-
* Require at least `min` peers to be yielded from `source`
|
|
13
|
-
*/
|
|
14
|
-
export declare function requirePeers(source: Source<PeerInfo>, min?: number): AsyncIterable<PeerInfo>;
|
|
15
|
-
//# sourceMappingURL=utils.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"utils.d.ts","sourceRoot":"","sources":["../../../src/content-routing/utils.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,QAAQ,EAAE,SAAS,EAAE,MAAM,mBAAmB,CAAA;AAC5D,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,iBAAiB,CAAA;AAE7C;;GAEG;AACH,wBAAwB,cAAc,CAAE,MAAM,EAAE,MAAM,CAAC,QAAQ,CAAC,EAAE,SAAS,EAAE,SAAS,GAAG,aAAa,CAAC,QAAQ,CAAC,CAS/G;AAED;;GAEG;AACH,wBAAgB,WAAW,CAAE,MAAM,EAAE,MAAM,CAAC,QAAQ,CAAC,GAAG,aAAa,CAAC,QAAQ,CAAC,CAc9E;AAED;;GAEG;AACH,wBAAwB,YAAY,CAAE,MAAM,EAAE,MAAM,CAAC,QAAQ,CAAC,EAAE,GAAG,GAAE,MAAU,GAAG,aAAa,CAAC,QAAQ,CAAC,CAYxG"}
|
|
@@ -1,44 +0,0 @@
|
|
|
1
|
-
import { CodeError } from '@libp2p/interface';
|
|
2
|
-
import filter from 'it-filter';
|
|
3
|
-
import map from 'it-map';
|
|
4
|
-
/**
|
|
5
|
-
* Store the multiaddrs from every peer in the passed peer store
|
|
6
|
-
*/
|
|
7
|
-
export async function* storeAddresses(source, peerStore) {
|
|
8
|
-
yield* map(source, async (peer) => {
|
|
9
|
-
// ensure we have the addresses for a given peer
|
|
10
|
-
await peerStore.merge(peer.id, {
|
|
11
|
-
multiaddrs: peer.multiaddrs
|
|
12
|
-
});
|
|
13
|
-
return peer;
|
|
14
|
-
});
|
|
15
|
-
}
|
|
16
|
-
/**
|
|
17
|
-
* Filter peers by unique peer id
|
|
18
|
-
*/
|
|
19
|
-
export function uniquePeers(source) {
|
|
20
|
-
/** @type Set<string> */
|
|
21
|
-
const seen = new Set();
|
|
22
|
-
return filter(source, (peer) => {
|
|
23
|
-
// dedupe by peer id
|
|
24
|
-
if (seen.has(peer.id.toString())) {
|
|
25
|
-
return false;
|
|
26
|
-
}
|
|
27
|
-
seen.add(peer.id.toString());
|
|
28
|
-
return true;
|
|
29
|
-
});
|
|
30
|
-
}
|
|
31
|
-
/**
|
|
32
|
-
* Require at least `min` peers to be yielded from `source`
|
|
33
|
-
*/
|
|
34
|
-
export async function* requirePeers(source, min = 1) {
|
|
35
|
-
let seen = 0;
|
|
36
|
-
for await (const peer of source) {
|
|
37
|
-
seen++;
|
|
38
|
-
yield peer;
|
|
39
|
-
}
|
|
40
|
-
if (seen < min) {
|
|
41
|
-
throw new CodeError(`more peers required, seen: ${seen} min: ${min}`, 'NOT_FOUND');
|
|
42
|
-
}
|
|
43
|
-
}
|
|
44
|
-
//# sourceMappingURL=utils.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"utils.js","sourceRoot":"","sources":["../../../src/content-routing/utils.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,mBAAmB,CAAA;AAC7C,OAAO,MAAM,MAAM,WAAW,CAAA;AAC9B,OAAO,GAAG,MAAM,QAAQ,CAAA;AAIxB;;GAEG;AACH,MAAM,CAAC,KAAK,SAAU,CAAC,CAAC,cAAc,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Init": "https://libp2p.github.io/js-libp2p/interfaces/libp2p.Libp2pInit.html",
|
|
3
|
-
".:Libp2pInit": "https://libp2p.github.io/js-libp2p/interfaces/libp2p.Libp2pInit.html",
|
|
4
|
-
"Libp2pOptions": "https://libp2p.github.io/js-libp2p/types/libp2p.Libp2pOptions.html",
|
|
5
|
-
".:Libp2pOptions": "https://libp2p.github.io/js-libp2p/types/libp2p.Libp2pOptions.html",
|
|
6
|
-
"ServiceFactoryMap": "https://libp2p.github.io/js-libp2p/types/libp2p.ServiceFactoryMap.html",
|
|
7
|
-
".:ServiceFactoryMap": "https://libp2p.github.io/js-libp2p/types/libp2p.ServiceFactoryMap.html",
|
|
8
|
-
"createLibp2p": "https://libp2p.github.io/js-libp2p/functions/libp2p.createLibp2p.html",
|
|
9
|
-
".:createLibp2p": "https://libp2p.github.io/js-libp2p/functions/libp2p.createLibp2p.html"
|
|
10
|
-
}
|
|
@@ -1,55 +0,0 @@
|
|
|
1
|
-
import { CodeError } from '@libp2p/interface'
|
|
2
|
-
import filter from 'it-filter'
|
|
3
|
-
import map from 'it-map'
|
|
4
|
-
import type { PeerInfo, PeerStore } from '@libp2p/interface'
|
|
5
|
-
import type { Source } from 'it-stream-types'
|
|
6
|
-
|
|
7
|
-
/**
|
|
8
|
-
* Store the multiaddrs from every peer in the passed peer store
|
|
9
|
-
*/
|
|
10
|
-
export async function * storeAddresses (source: Source<PeerInfo>, peerStore: PeerStore): AsyncIterable<PeerInfo> {
|
|
11
|
-
yield * map(source, async (peer) => {
|
|
12
|
-
// ensure we have the addresses for a given peer
|
|
13
|
-
await peerStore.merge(peer.id, {
|
|
14
|
-
multiaddrs: peer.multiaddrs
|
|
15
|
-
})
|
|
16
|
-
|
|
17
|
-
return peer
|
|
18
|
-
})
|
|
19
|
-
}
|
|
20
|
-
|
|
21
|
-
/**
|
|
22
|
-
* Filter peers by unique peer id
|
|
23
|
-
*/
|
|
24
|
-
export function uniquePeers (source: Source<PeerInfo>): AsyncIterable<PeerInfo> {
|
|
25
|
-
/** @type Set<string> */
|
|
26
|
-
const seen = new Set()
|
|
27
|
-
|
|
28
|
-
return filter(source, (peer) => {
|
|
29
|
-
// dedupe by peer id
|
|
30
|
-
if (seen.has(peer.id.toString())) {
|
|
31
|
-
return false
|
|
32
|
-
}
|
|
33
|
-
|
|
34
|
-
seen.add(peer.id.toString())
|
|
35
|
-
|
|
36
|
-
return true
|
|
37
|
-
})
|
|
38
|
-
}
|
|
39
|
-
|
|
40
|
-
/**
|
|
41
|
-
* Require at least `min` peers to be yielded from `source`
|
|
42
|
-
*/
|
|
43
|
-
export async function * requirePeers (source: Source<PeerInfo>, min: number = 1): AsyncIterable<PeerInfo> {
|
|
44
|
-
let seen = 0
|
|
45
|
-
|
|
46
|
-
for await (const peer of source) {
|
|
47
|
-
seen++
|
|
48
|
-
|
|
49
|
-
yield peer
|
|
50
|
-
}
|
|
51
|
-
|
|
52
|
-
if (seen < min) {
|
|
53
|
-
throw new CodeError(`more peers required, seen: ${seen} min: ${min}`, 'NOT_FOUND')
|
|
54
|
-
}
|
|
55
|
-
}
|