Skip to content

refactor: async await #266 #538

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

Merged
merged 92 commits into from
Jan 24, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
92 commits
Select commit Hold shift + click to select a range
4f8043d
Add streaming iterables guide (#459)
jacobheun Sep 30, 2019
a7d5e67
refactor(async): update transports subsystem (#461)
jacobheun Oct 2, 2019
10c8553
docs: add stream wrapping example (#466)
jacobheun Oct 21, 2019
af364b0
refactor(async): add dialer and upgrader (#462)
jacobheun Oct 21, 2019
138bb0b
refactor: crypto and pnet (#469)
jacobheun Nov 4, 2019
f3e276e
feat: peer store (#470)
vasco-santos Nov 6, 2019
797d8f0
feat: registrar (#471)
vasco-santos Nov 6, 2019
44d4708
refactor: async identify and identify push (#473)
jacobheun Nov 7, 2019
ced2dbf
chore: update it-length-prefixed (#476)
jacobheun Nov 13, 2019
34d57f8
refactor: pubsub (#467)
vasco-santos Nov 15, 2019
3c79d33
chore: use gossipsub release (#479)
vasco-santos Nov 19, 2019
86b275a
refactor: core async (#478)
jacobheun Nov 19, 2019
c37703d
refactor: update secio and tests to use it (#484)
jacobheun Nov 26, 2019
1ea945a
refactor: dht async/await (#480)
vasco-santos Nov 26, 2019
b316cdd
refactor(docs): async await version of examples/echo (#483)
dirkmc Nov 27, 2019
995640e
refactor(docs): async await version of examples/chat (#482)
dirkmc Nov 27, 2019
acbbc0f
fix: replace peerInfo addresses with listen addresses (#485)
dirkmc Nov 28, 2019
997ee16
feat: discovery modules (#486)
vasco-santos Nov 28, 2019
b518391
refactor: circuit relay to async (#477)
jacobheun Nov 29, 2019
fc22c36
refactor: async routing (#489)
vasco-santos Dec 1, 2019
11ed6bd
feat: support peer-id instances in peer store operations (#491)
vasco-santos Dec 2, 2019
dbb9e57
chore: update pubsub implementations (#493)
vasco-santos Dec 3, 2019
f3eb1f1
fix: clean up peer discovery flow (#494)
jacobheun Dec 3, 2019
c4bc00b
fix: correct release readme
jacobheun Dec 1, 2019
0cacfe2
doc: add initial dialer readme
jacobheun Dec 2, 2019
f8540fa
feat: add token based dialer
jacobheun Dec 3, 2019
cba2c6d
chore: remove commented code
jacobheun Dec 3, 2019
571fd3b
chore: apply suggestions from code review
jacobheun Dec 4, 2019
d5405db
refactor: PER_PEER_LIMIT is now MAX_PER_PEER_DIALS
jacobheun Dec 4, 2019
f9fe44f
chore: use any-signal module
jacobheun Dec 4, 2019
ea62c52
refactor: simplify DialRequest logic per feedback
jacobheun Dec 4, 2019
24c6037
feat: add early token recycling in
jacobheun Dec 4, 2019
a37c5c0
refactor: clean up dial timeout abort
jacobheun Dec 4, 2019
c4be5f4
refactor: consolidation multiaddr dial methods
jacobheun Dec 4, 2019
7d1cb54
chore: fix linting
jacobheun Dec 4, 2019
e8bf12b
chore: update docs
jacobheun Dec 4, 2019
43a3b85
refactor: cleanup and reorganize
jacobheun Dec 4, 2019
53ce404
chore: update per feedback
jacobheun Dec 4, 2019
74bfe6b
docs(release): point to libp2p weekly sync
jacobheun Dec 4, 2019
3b06283
test(fix): fix support for it.only, it.skip, etc
jacobheun Dec 6, 2019
c7dcfe5
test: add tests for DialRequest
jacobheun Dec 6, 2019
3b52236
chore: fix lint
jacobheun Dec 6, 2019
0a8f9f3
test: reduce randomwalk timeout
jacobheun Dec 6, 2019
754fbc2
feat: abort all pending dials on stop
jacobheun Dec 6, 2019
962081f
test: remove timeout
jacobheun Dec 6, 2019
43b98e6
docs: add DialRequest description
jacobheun Dec 6, 2019
7c3371b
fix: clean up pending dials abort per feedback
jacobheun Dec 10, 2019
43440aa
fix: release tokens as soon as they are available
jacobheun Dec 10, 2019
3cadeb3
test: bump delay for ci
jacobheun Dec 10, 2019
1838a64
fix: token release logic
jacobheun Dec 10, 2019
8c6ad79
docs: new api (#472)
vasco-santos Dec 10, 2019
9b10e09
chore: move stats folder and delete old switch code
jacobheun Dec 8, 2019
edaa67d
chore: remove unused packages
jacobheun Dec 8, 2019
a2f31d9
chore: disable pull dep check until ping is refactored
jacobheun Dec 8, 2019
600f761
chore: remove uneeded dep check exclusions
jacobheun Dec 8, 2019
ad15d4e
chore: add bundlesize check back to ci
jacobheun Dec 8, 2019
7fc1900
chore: it-all over async-iterator-all
jacobheun Dec 10, 2019
64cbf90
refactor: ping (#505)
vasco-santos Dec 10, 2019
3d30cb1
docs: config (#495)
vasco-santos Dec 10, 2019
f540112
refactor: stats (#501)
jacobheun Dec 11, 2019
af96dcc
feat: discovery modules from transports should be added (#510)
vasco-santos Dec 11, 2019
45f4702
refactor: connection manager (#511)
jacobheun Dec 12, 2019
3ee1e22
chore: update contributors
jacobheun Dec 12, 2019
9c884a7
chore: release version v0.27.0-pre.0
jacobheun Dec 12, 2019
cc65a4b
chore: update readme (#513)
vasco-santos Dec 12, 2019
9bbe93c
docs: fix the ToC links (#515)
Dec 12, 2019
a39889c
docs: add ToC link to pubsub.unsubscribe
Dec 12, 2019
4a871bb
feat: coalescing dial support (#518)
jacobheun Dec 15, 2019
9900beb
chore: update contributors
jacobheun Dec 15, 2019
92ed566
chore: release version v0.27.0-pre.1
jacobheun Dec 15, 2019
56a1825
fix: upgrader should not need muxers (#517)
vasco-santos Dec 16, 2019
24c3ce6
fix: make dialer configurable (#521)
jacobheun Dec 16, 2019
6ca19c5
feat: add libp2p.connections getter (#522)
jacobheun Dec 16, 2019
9f0f08f
refactor: examples-pubsub (#504)
vasco-santos Dec 16, 2019
506af15
refactor: examples/encrypted-communications (#499)
vasco-santos Dec 18, 2019
fdb48c8
refactor: examples/peer-and-content-routing (#500)
vasco-santos Dec 18, 2019
0d4b2bd
feat: allow transport options to be passed on creation (#524)
jacobheun Dec 20, 2019
dec8dc4
refactor: examples/protocol-and-stream-muxing (#502)
vasco-santos Jan 2, 2020
a1717da
fix: conn mngr min/max connection values (#528)
Jan 6, 2020
f182f5b
refactor: examples/discovery-mechanisms (#498)
vasco-santos Jan 6, 2020
0840739
refactor: examples/pnet (#523)
vasco-santos Jan 7, 2020
21362b5
refactor: examples transports (#503)
vasco-santos Jan 7, 2020
122a114
chore: update contributors
jacobheun Jan 7, 2020
999d086
chore: release version v0.27.0-pre.2
jacobheun Jan 7, 2020
c44e6e3
fix: stop discoveries (#530)
Jan 7, 2020
83409de
fix: registrar should filter the disconnected conn (#532)
vasco-santos Jan 14, 2020
31d1b23
fix: use toB58String everywhere to be consistent (#537)
jacobheun Jan 22, 2020
461faca
docs: getting started (#514)
vasco-santos Jan 23, 2020
751a227
refactor: examples-browser (#508)
vasco-santos Jan 24, 2020
691e9b7
chore: update contributors
jacobheun Jan 24, 2020
1ba1ca7
chore: release version v0.27.0-rc.0
jacobheun Jan 24, 2020
7e1a9d6
test(fix): fix listening test for ci
jacobheun Jan 24, 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
129 changes: 23 additions & 106 deletions .aegir.js
Original file line number Diff line number Diff line change
@@ -1,130 +1,47 @@
'use strict'

const pull = require('pull-stream')
const WebSocketStarRendezvous = require('libp2p-websocket-star-rendezvous')
const sigServer = require('libp2p-webrtc-star/src/sig-server')
const promisify = require('promisify-es6')
const mplex = require('pull-mplex')
const spdy = require('libp2p-spdy')
const PeerBook = require('peer-book')
const Libp2p = require('./src')
const { MULTIADDRS_WEBSOCKETS } = require('./test/fixtures/browser')
const Peers = require('./test/fixtures/peers')
const PeerId = require('peer-id')
const PeerInfo = require('peer-info')
const path = require('path')
const Switch = require('./src/switch')
const WebSockets = require('libp2p-websockets')

const Node = require('./test/utils/bundle-nodejs.js')
const {
getPeerRelay,
WRTC_RENDEZVOUS_MULTIADDR,
WS_RENDEZVOUS_MULTIADDR
} = require('./test/utils/constants')

let wrtcRendezvous
let wsRendezvous
let node
let peerInfo
let switchA
let switchB

function echo (protocol, conn) { pull(conn, conn) }
function idJSON (id) {
const p = path.join(__dirname, `./test/switch/test-data/id-${id}.json`)
return require(p)
}

function createSwitchA () {
return new Promise((resolve, reject) => {
PeerId.createFromJSON(idJSON(1), (err, id) => {
if (err) { return reject(err) }

const peerA = new PeerInfo(id)
const maA = '/ip4/127.0.0.1/tcp/15337/ws'

peerA.multiaddrs.add(maA)
const sw = new Switch(peerA, new PeerBook())

sw.transport.add('ws', new WebSockets())
sw.start((err) => {
if (err) { return reject(err) }
resolve(sw)
})
})
})
}

function createSwitchB () {
return new Promise((resolve, reject) => {
PeerId.createFromJSON(idJSON(2), (err, id) => {
if (err) { return reject(err) }

const peerB = new PeerInfo(id)
const maB = '/ip4/127.0.0.1/tcp/15347/ws'

peerB.multiaddrs.add(maB)
const sw = new Switch(peerB, new PeerBook())

sw.transport.add('ws', new WebSockets())
sw.connection.addStreamMuxer(mplex)
sw.connection.addStreamMuxer(spdy)
sw.connection.reuse()
sw.handle('/echo/1.0.0', echo)
sw.start((err) => {
if (err) { return reject(err) }
resolve(sw)
})
})
})
}
const Muxer = require('libp2p-mplex')
const Crypto = require('libp2p-secio')
const pipe = require('it-pipe')
let libp2p

const before = async () => {
[
wrtcRendezvous,
wsRendezvous,
peerInfo,
switchA,
switchB
] = await Promise.all([
sigServer.start({
port: WRTC_RENDEZVOUS_MULTIADDR.nodeAddress().port
// cryptoChallenge: true TODO: needs https://github.com/libp2p/js-libp2p-webrtc-star/issues/128
}),
WebSocketStarRendezvous.start({
port: WS_RENDEZVOUS_MULTIADDR.nodeAddress().port,
refreshPeerListIntervalMS: 1000,
strictMultiaddr: false,
cryptoChallenge: true
}),
getPeerRelay(),
createSwitchA(),
createSwitchB()
])
// Use the last peer
const peerId = await PeerId.createFromJSON(Peers[Peers.length - 1])
const peerInfo = new PeerInfo(peerId)
peerInfo.multiaddrs.add(MULTIADDRS_WEBSOCKETS[0])

node = new Node({
libp2p = new Libp2p({
peerInfo,
modules: {
transport: [WebSockets],
streamMuxer: [Muxer],
connEncryption: [Crypto]
},
config: {
relay: {
enabled: true,
hop: {
enabled: true,
active: true
active: false
}
}
}
})
// Add the echo protocol
libp2p.handle('/echo/1.0.0', ({ stream }) => pipe(stream, stream))

node.handle('/echo/1.0.0', (protocol, conn) => pull(conn, conn))
await node.start()
await libp2p.start()
}

const after = () => {
return Promise.all([
wrtcRendezvous.stop(),
wsRendezvous.stop(),
node.stop(),
promisify(switchA.stop, { context: switchA })(),
promisify(switchB.stop, { context: switchB })()
])
const after = async () => {
await libp2p.stop()
}

module.exports = {
Expand Down
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ docs
**/*.log
test/repo-tests*
**/bundle.js
.cache

# Logs
logs
Expand Down
9 changes: 4 additions & 5 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -21,24 +21,23 @@ jobs:
- stage: check
script:
- npx aegir build --bundlesize
- npx aegir dep-check -- -i wrtc -i electron-webrtc
# Remove pull libs once ping is async
- npx aegir dep-check -- -i pull-handshake -i pull-stream
- npm run lint

- stage: test
name: chrome
addons:
chrome: stable
script:
- npx aegir test -t browser
- npx aegir test -t webworker
- npx aegir test -t browser -t webworker

- stage: test
name: firefox
addons:
firefox: latest
script:
- npx aegir test -t browser -- --browsers FirefoxHeadless
- npx aegir test -t webworker -- --browsers FirefoxHeadless
- npx aegir test -t browser -t webworker -- --browsers FirefoxHeadless

notifications:
email: false
69 changes: 69 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,72 @@
<a name="0.27.0-rc.0"></a>
# [0.27.0-rc.0](https://github.com/libp2p/js-libp2p/compare/v0.27.0-pre.2...v0.27.0-rc.0) (2020-01-24)


### Bug Fixes

* registrar should filter the disconnected conn ([#532](https://github.com/libp2p/js-libp2p/issues/532)) ([83409de](https://github.com/libp2p/js-libp2p/commit/83409de))
* stop discoveries ([#530](https://github.com/libp2p/js-libp2p/issues/530)) ([c44e6e3](https://github.com/libp2p/js-libp2p/commit/c44e6e3))
* use toB58String everywhere to be consistent ([#537](https://github.com/libp2p/js-libp2p/issues/537)) ([31d1b23](https://github.com/libp2p/js-libp2p/commit/31d1b23))



<a name="0.27.0-pre.2"></a>
# [0.27.0-pre.2](https://github.com/libp2p/js-libp2p/compare/v0.27.0-pre.1...v0.27.0-pre.2) (2020-01-07)


### Bug Fixes

* conn mngr min/max connection values ([#528](https://github.com/libp2p/js-libp2p/issues/528)) ([a1717da](https://github.com/libp2p/js-libp2p/commit/a1717da))
* make dialer configurable ([#521](https://github.com/libp2p/js-libp2p/issues/521)) ([24c3ce6](https://github.com/libp2p/js-libp2p/commit/24c3ce6))
* upgrader should not need muxers ([#517](https://github.com/libp2p/js-libp2p/issues/517)) ([56a1825](https://github.com/libp2p/js-libp2p/commit/56a1825))


### Features

* add libp2p.connections getter ([#522](https://github.com/libp2p/js-libp2p/issues/522)) ([6ca19c5](https://github.com/libp2p/js-libp2p/commit/6ca19c5))
* allow transport options to be passed on creation ([#524](https://github.com/libp2p/js-libp2p/issues/524)) ([0d4b2bd](https://github.com/libp2p/js-libp2p/commit/0d4b2bd))



<a name="0.27.0-pre.1"></a>
# [0.27.0-pre.1](https://github.com/libp2p/js-libp2p/compare/v0.27.0-pre.0...v0.27.0-pre.1) (2019-12-15)


### Features

* coalescing dial support ([#518](https://github.com/libp2p/js-libp2p/issues/518)) ([4a871bb](https://github.com/libp2p/js-libp2p/commit/4a871bb))



<a name="0.27.0-pre.0"></a>
# [0.27.0-pre.0](https://github.com/libp2p/js-libp2p/compare/v0.26.2...v0.27.0-pre.0) (2019-12-12)


### Bug Fixes

* clean up peer discovery flow ([#494](https://github.com/libp2p/js-libp2p/issues/494)) ([f3eb1f1](https://github.com/libp2p/js-libp2p/commit/f3eb1f1))
* clean up pending dials abort per feedback ([7c3371b](https://github.com/libp2p/js-libp2p/commit/7c3371b))
* correct release readme ([c4bc00b](https://github.com/libp2p/js-libp2p/commit/c4bc00b))
* examples readme typos ([#481](https://github.com/libp2p/js-libp2p/issues/481)) ([35ac02d](https://github.com/libp2p/js-libp2p/commit/35ac02d))
* performance bottleneck in stat.js ([#463](https://github.com/libp2p/js-libp2p/issues/463)) ([93a1e42](https://github.com/libp2p/js-libp2p/commit/93a1e42))
* release tokens as soon as they are available ([43440aa](https://github.com/libp2p/js-libp2p/commit/43440aa))
* replace peerInfo addresses with listen addresses ([#485](https://github.com/libp2p/js-libp2p/issues/485)) ([acbbc0f](https://github.com/libp2p/js-libp2p/commit/acbbc0f))
* token release logic ([1838a64](https://github.com/libp2p/js-libp2p/commit/1838a64))


### Features

* abort all pending dials on stop ([754fbc2](https://github.com/libp2p/js-libp2p/commit/754fbc2))
* add early token recycling in ([24c6037](https://github.com/libp2p/js-libp2p/commit/24c6037))
* add token based dialer ([f8540fa](https://github.com/libp2p/js-libp2p/commit/f8540fa))
* discovery modules ([#486](https://github.com/libp2p/js-libp2p/issues/486)) ([997ee16](https://github.com/libp2p/js-libp2p/commit/997ee16))
* discovery modules from transports should be added ([#510](https://github.com/libp2p/js-libp2p/issues/510)) ([af96dcc](https://github.com/libp2p/js-libp2p/commit/af96dcc))
* peer store ([#470](https://github.com/libp2p/js-libp2p/issues/470)) ([f3e276e](https://github.com/libp2p/js-libp2p/commit/f3e276e))
* registrar ([#471](https://github.com/libp2p/js-libp2p/issues/471)) ([797d8f0](https://github.com/libp2p/js-libp2p/commit/797d8f0))
* support peer-id instances in peer store operations ([#491](https://github.com/libp2p/js-libp2p/issues/491)) ([11ed6bd](https://github.com/libp2p/js-libp2p/commit/11ed6bd))



<a name="0.26.2"></a>
## [0.26.2](https://github.com/libp2p/js-libp2p/compare/v0.26.1...v0.26.2) (2019-09-24)

Expand Down
Loading