Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Chore/add typedefs peerstore book template 2 #831

Closed
wants to merge 57 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
57 commits
Select commit Hold shift + click to select a range
2548885
feat: auto relay (#723)
vasco-santos Sep 16, 2020
8d75093
chore: auto relay multiaddr update push
vasco-santos Sep 10, 2020
971655f
chore: _isStarted is false when stop starts
vasco-santos Sep 23, 2020
ee8ee5b
chore: use listening events to create self peer record on updates
vasco-santos Sep 23, 2020
87d20ac
chore: create signed peer record on new listen addresses in transport…
vasco-santos Sep 23, 2020
abba305
chore: add identify test for multiaddr change
vasco-santos Sep 24, 2020
05e6472
chore: address review
vasco-santos Sep 24, 2020
2530b83
chore: lint issue fixed 0.30
vasco-santos Oct 7, 2020
e6b0134
feat: auto relay network query for new relays
vasco-santos Sep 11, 2020
3d2181f
chore: address review
vasco-santos Sep 23, 2020
29e30c2
chore: add configuration docs for auto relay and hop service
vasco-santos Sep 23, 2020
2746b4b
chore: apply suggestions from code review
vasco-santos Oct 5, 2020
722cacd
chore: lint issues fixed
vasco-santos Oct 7, 2020
3bd1768
chore: sort relay addresses to listen for public first
vasco-santos Oct 8, 2020
558bcf9
chore: improve logging for auto relay active listen
vasco-santos Oct 8, 2020
8456d0e
chore: store self protocols in protobook (#760)
vasco-santos Oct 27, 2020
0c551d2
feat: custom announce filter
vasco-santos Oct 15, 2020
0d1a34b
chore: remove noAnnounce from address manager
vasco-santos Oct 27, 2020
10d449a
chore: update address manager readme
vasco-santos Nov 3, 2020
e1ffee1
fix: remove test/dialing/utils extra file
vasco-santos Nov 10, 2020
81c5c43
test: custom announce filter
vasco-santos Oct 15, 2020
bd214d5
chore: update pubsub (#801)
vasco-santos Nov 13, 2020
ad6187d
feat: custom dialer addr sorter (#792)
vasco-santos Nov 20, 2020
b5e38de
docs: auto relay example (#795)
vasco-santos Nov 20, 2020
c6fd23a
chore: update websockets (#806)
vasco-santos Nov 24, 2020
7c3f7e0
feat: discover and connect to closest peers (#798)
vasco-santos Nov 25, 2020
dbc2653
chore: use set-delayed-interval module on circuit (#809)
vasco-santos Nov 26, 2020
dfcce96
docs: migration 0.29 to 0.30 (#808)
vasco-santos Nov 26, 2020
26c40c8
chore: add typedefs
vasco-santos Nov 16, 2020
7e05c4a
chore: address review
vasco-santos Nov 25, 2020
28b9f85
chore: add types checker script and more fixes on the jsdocs
vasco-santos Nov 26, 2020
4b309ad
chore: use new libp2p interface
vasco-santos Dec 1, 2020
149c19a
chore: minor fixes and github ci
vasco-santos Dec 2, 2020
d3d6b35
chore: fix remaining ts ignores
vasco-santos Dec 2, 2020
89fd524
chore: reset cache ci...
vasco-santos Dec 2, 2020
2109ef0
chore: remove interfaces dep for ci cache
vasco-santos Dec 2, 2020
32dd055
chore: reset cache ci...
vasco-santos Dec 2, 2020
a5f5160
chore: update record, transport and stream muxer per latest interface…
vasco-santos Dec 3, 2020
77a0257
chore: add interop and examples in github actions
vasco-santos Dec 3, 2020
e519a6c
chore: minor changes from lodestar testing
vasco-santos Dec 3, 2020
bb0cbc1
chore: add typedefs peerstore book template
vasco-santos Dec 3, 2020
55910c8
chore: minor changes from lodestar testing
vasco-santos Dec 3, 2020
8cc03ca
chore: update pubsub example by disabled emit self (#823)
vasco-santos Dec 4, 2020
1992609
chore: add libp2p modules typedef
vasco-santos Dec 8, 2020
9b863bd
chore: apply suggestions from code review
vasco-santos Dec 9, 2020
b221e97
chore: address rest of review
vasco-santos Dec 9, 2020
a044b5d
chore: auto relay configuration example with noise (#828)
vasco-santos Dec 9, 2020
d1caeb3
Merge remote-tracking branch 'upstream/chore/add-typedefs' into chore…
Gozala Dec 10, 2020
ce07544
chore: use aegir with ts 4.1.x
Gozala Dec 10, 2020
7706e39
fix: remaining type errors
Gozala Dec 10, 2020
9966c6c
chore: apply suggestions from code review
vasco-santos Dec 10, 2020
aa98bc2
chore: address other review comments
vasco-santos Dec 10, 2020
c4bb3fa
chore: merge typedefs newest updates
vasco-santos Dec 10, 2020
e014fee
chore: fix lint
vasco-santos Dec 10, 2020
cba25c8
chore: remove ts ignore from add stream
vasco-santos Dec 10, 2020
a279926
chore: add typedefs (#802)
vasco-santos Dec 10, 2020
2e7f49e
chore: merge 0.30
vasco-santos Dec 10, 2020
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
67 changes: 67 additions & 0 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,67 @@
name: ci
on:
push:
branches:
- master
pull_request:
branches:
- '**'

jobs:
check:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- run: yarn
- run: yarn lint
- uses: gozala/typescript-error-reporter-action@v1.0.8
- run: yarn build
- run: yarn aegir dep-check
- uses: ipfs/aegir/actions/bundle-size@master
name: size
with:
github_token: ${{ secrets.GITHUB_TOKEN }}
test-node:
needs: check
runs-on: ${{ matrix.os }}
strategy:
matrix:
os: [windows-latest, ubuntu-latest, macos-latest]
node: [12, 14]
fail-fast: true
steps:
- uses: actions/checkout@v2
- uses: actions/setup-node@v1
with:
node-version: ${{ matrix.node }}
- run: yarn
- run: npx nyc --reporter=lcov aegir test -t node -- --bail
- uses: codecov/codecov-action@v1
test-chrome:
needs: check
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- run: yarn
- run: npx aegir test -t browser -t webworker --bail
test-firefox:
needs: check
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- run: yarn
- run: npx aegir test -t browser -t webworker --bail -- --browsers FirefoxHeadless
test-interop:
needs: check
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- run: yarn
- run: cd node_modules/interop-libp2p && yarn && LIBP2P_JS=${GITHUB_WORKSPACE}/src/index.js npx aegir test -t node --bail
test-auto-relay-example:
needs: check
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- run: yarn
- run: cd examples && yarn && npm run test -- auto-relay
50 changes: 0 additions & 50 deletions .travis.yml

This file was deleted.

134 changes: 85 additions & 49 deletions doc/API.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,14 +13,14 @@
* [`ping`](#ping)
* [`multiaddrs`](#multiaddrs)
* [`addressManager.getListenAddrs`](#addressmanagergetlistenaddrs)
* [`addressmger.getAnnounceAddrs`](#addressmanagergetannounceaddrs)
* [`addressManager.getNoAnnounceAddrs`](#addressmanagergetnoannounceaddrs)
* [`addressManager.getAnnounceAddrs`](#addressmanagergetannounceaddrs)
* [`contentRouting.findProviders`](#contentroutingfindproviders)
* [`contentRouting.provide`](#contentroutingprovide)
* [`contentRouting.put`](#contentroutingput)
* [`contentRouting.get`](#contentroutingget)
* [`contentRouting.getMany`](#contentroutinggetmany)
* [`peerRouting.findPeer`](#peerroutingfindpeer)
* [`peerRouting.getClosestPeers`](#peerroutinggetclosestpeers)
* [`peerStore.addressBook.add`](#peerstoreaddressbookadd)
* [`peerStore.addressBook.delete`](#peerstoreaddressbookdelete)
* [`peerStore.addressBook.get`](#peerstoreaddressbookget)
Expand All @@ -37,6 +37,7 @@
* [`peerStore.protoBook.add`](#peerstoreprotobookadd)
* [`peerStore.protoBook.delete`](#peerstoreprotobookdelete)
* [`peerStore.protoBook.get`](#peerstoreprotobookget)
* [`peerStore.protoBook.remove`](#peerstoreprotobookremove)
* [`peerStore.protoBook.set`](#peerstoreprotobookset)
* [`peerStore.delete`](#peerstoredelete)
* [`peerStore.get`](#peerstoreget)
Expand Down Expand Up @@ -90,7 +91,7 @@ Creates an instance of Libp2p.
|------|------|-------------|
| options | `object` | libp2p options |
| options.modules | [`Array<object>`](./CONFIGURATION.md#modules) | libp2p [modules](./CONFIGURATION.md#modules) to use |
| [options.addresses] | `{ listen: Array<string>, announce: Array<string>, noAnnounce: Array<string> }` | Addresses for transport listening and to advertise to the network |
| [options.addresses] | `{ listen: Array<string>, announce: Array<string>, announceFilter: (ma: Array<multiaddr>) => Array<multiaddr> }` | Addresses for transport listening and to advertise to the network |
| [options.config] | `object` | libp2p modules configuration and core configuration |
| [options.connectionManager] | [`object`](./CONFIGURATION.md#configuring-connection-manager) | libp2p Connection Manager [configuration](./CONFIGURATION.md#configuring-connection-manager) |
| [options.transportManager] | [`object`](./CONFIGURATION.md#configuring-transport-manager) | libp2p transport manager [configuration](./CONFIGURATION.md#configuring-transport-manager) |
Expand All @@ -99,6 +100,7 @@ Creates an instance of Libp2p.
| [options.keychain] | [`object`](./CONFIGURATION.md#setup-with-keychain) | keychain [configuration](./CONFIGURATION.md#setup-with-keychain) |
| [options.metrics] | [`object`](./CONFIGURATION.md#configuring-metrics) | libp2p Metrics [configuration](./CONFIGURATION.md#configuring-metrics) |
| [options.peerId] | [`PeerId`][peer-id] | peerId instance (it will be created if not provided) |
| [options.peerRouting] | [`object`](./CONFIGURATION.md#setup-with-content-and-peer-routing) | libp2p Peer routing service [configuration](./CONFIGURATION.md#setup-with-content-and-peer-routing) |
| [options.peerStore] | [`object`](./CONFIGURATION.md#configuring-peerstore) | libp2p PeerStore [configuration](./CONFIGURATION.md#configuring-peerstore) |

For Libp2p configurations and modules details read the [Configuration Document](./CONFIGURATION.md).
Expand Down Expand Up @@ -482,26 +484,6 @@ const announceMa = libp2p.addressManager.getAnnounceAddrs()
// [ <Multiaddr 047f00000106f9ba - /dns4/peer.io/...> ]
```

### addressManager.getNoAnnounceAddrs

Get the multiaddrs that were provided to not announce to the network.

`libp2p.addressManager.getNoAnnounceAddrs()`

#### Returns

| Type | Description |
|------|-------------|
| `Array<Multiaddr>` | Provided noAnnounce multiaddrs |

#### Example

```js
// ...
const noAnnounceMa = libp2p.addressManager.getNoAnnounceAddrs()
// [ <Multiaddr 047f00000106f9ba - /ip4/127.0.0.1/tcp/63930> ]
```

### transportManager.getAddrs

Get the multiaddrs that libp2p transports are using to listen on.
Expand Down Expand Up @@ -695,6 +677,36 @@ Iterates over all peer routers in series to find the given peer. If the DHT is e
const peer = await libp2p.peerRouting.findPeer(peerId, options)
```

### peerRouting.getClosestPeers

Iterates over all content routers in series to get the closest peers of the given key.
Once a content router succeeds, the iteration will stop. If the DHT is enabled, it will be queried first.

`libp2p.peerRouting.getClosestPeers(cid, options)`

#### Parameters

| Name | Type | Description |
|------|------|-------------|
| key | `Uint8Array` | A CID like key |
| options | `object` | operation options |
| options.timeout | `number` | How long the query can take (ms). |

#### Returns

| Type | Description |
|------|-------------|
| `AsyncIterable<{ id: PeerId, multiaddrs: Multiaddr[] }` | Async iterator for peer data |

#### Example

```js
// Iterate over the closest peers found for the given key
for await (const peer of libp2p.peerRouting.getClosestPeers(key)) {
console.log(peer.id, peer.multiaddrs)
}
```

### peerStore.addressBook.add

Adds known `multiaddrs` of a given peer. If the peer is not known, it will be set with the provided multiaddrs.
Expand Down Expand Up @@ -843,32 +855,6 @@ Consider using `addressBook.add()` if you're not sure this is what you want to d
peerStore.addressBook.add(peerId, multiaddr)
```

### peerStore.protoBook.add

Add known `protocols` of a given peer.

`peerStore.protoBook.add(peerId, protocols)`

#### Parameters

| Name | Type | Description |
|------|------|-------------|
| peerId | [`PeerId`][peer-id] | peerId to set |
| protocols | `Array<string>` | protocols to add |

#### Returns

| Type | Description |
|------|-------------|
| `ProtoBook` | Returns the Proto Book component |

#### Example

```js
peerStore.protoBook.add(peerId, protocols)
```


### peerStore.keyBook.delete

Delete the provided peer from the book.
Expand Down Expand Up @@ -1091,6 +1077,31 @@ Set known metadata of a given `peerId`.
peerStore.metadataBook.set(peerId, 'location', uint8ArrayFromString('Berlin'))
```

### peerStore.protoBook.add

Add known `protocols` of a given peer.

`peerStore.protoBook.add(peerId, protocols)`

#### Parameters

| Name | Type | Description |
|------|------|-------------|
| peerId | [`PeerId`][peer-id] | peerId to set |
| protocols | `Array<string>` | protocols to add |

#### Returns

| Type | Description |
|------|-------------|
| `ProtoBook` | Returns the Proto Book component |

#### Example

```js
peerStore.protoBook.add(peerId, protocols)
```

### peerStore.protoBook.delete

Delete the provided peer from the book.
Expand Down Expand Up @@ -1147,6 +1158,31 @@ peerStore.protoBook.get(peerId)
// [ '/proto/1.0.0', '/proto/1.1.0' ]
```

### peerStore.protoBook.remove

Remove given `protocols` of a given peer.

`peerStore.protoBook.remove(peerId, protocols)`

#### Parameters

| Name | Type | Description |
|------|------|-------------|
| peerId | [`PeerId`][peer-id] | peerId to set |
| protocols | `Array<string>` | protocols to remove |

#### Returns

| Type | Description |
|------|-------------|
| `ProtoBook` | Returns the Proto Book component |

#### Example

```js
peerStore.protoBook.remove(peerId, protocols)
```

### peerStore.protoBook.set

Set known `protocols` of a given peer.
Expand Down
Loading