105 Commits

Author SHA1 Message Date
Jacob Heun
3eef695bc0
fix: improve config defaults (#409)
This removes defaults from superstruct and instead uses
mergeOptions to deeply set the defaults on configuration.
This ensures that defaults are properly set.

This is a step toward removing superstruct altogether, #406,
but it is still being used for basic type validation.
2019-08-21 16:44:30 +02:00
Jacob Heun
b3deb356f1
fix: reference files directly to avoid npm install failures (#408) 2019-08-21 10:23:06 +02:00
Jacob Heun
aa95ab9928 fix: avoid using superstruct interface 2019-08-20 17:34:55 +02:00
a1300
b0f124b5ff fix: pubsub configuration (#404)
* fix: add pubsub default config (#401)

License: MIT
Signed-off-by: Matthias Knopp <matthias-knopp@gmx.net>

* docs: add default pubsub config to README (#401)

License: MIT
Signed-off-by: Matthias Knopp <matthias-knopp@gmx.net>

* fix: pass config to provided PubSub (#401)

License: MIT
Signed-off-by: Matthias Knopp <matthias-knopp@gmx.net>

* docs: adapt pubsub/example for new config (#401)

License: MIT
Signed-off-by: Matthias Knopp <matthias-knopp@gmx.net>

* Update examples/pubsub/README.md

Co-Authored-By: Jacob Heun <jacobheun@gmail.com>

* test: add pubsub config tests (#401)

License: MIT
Signed-off-by: Matthias Knopp <matthias-knopp@gmx.net>
2019-08-19 17:06:08 +02:00
Jacob Heun
b294301456
refactor: add core modules to libp2p (#400)
* refactor: add js-libp2p-connection-manager to repo

Co-authored-by: David Dias <daviddias.p@gmail.com>
Co-authored-by: Jacob Heun <jacobheun@gmail.com>
Co-authored-by: Pedro Teixeira <i@pgte.me>
Co-authored-by: Vasco Santos <vasco.santos@ua.pt>

* test(conn-mgr): only run in node

* refactor: add js-libp2p-identify to repo

Co-authored-by: David Dias <daviddias.p@gmail.com>
Co-authored-by: Friedel Ziegelmayer <dignifiedquire@gmail.com>
Co-authored-by: Hugo Dias <hugomrdias@gmail.com>
Co-authored-by: Jacob Heun <jacobheun@gmail.com>
Co-authored-by: Maciej Krüger <mkg20001@gmail.com>
Co-authored-by: Richard Littauer <richard.littauer@gmail.com>
Co-authored-by: Vasco Santos <vasco.santos@moxy.studio>
Co-authored-by: Yusef Napora <yusef@protocol.ai>
Co-authored-by: ᴠɪᴄᴛᴏʀ ʙᴊᴇʟᴋʜᴏʟᴍ <victorbjelkholm@gmail.com>

* refactor: add libp2p-pnet to repo

Co-authored-by: Jacob Heun <jacobheun@gmail.com>
Co-authored-by: Vasco Santos <vasco.santos@moxy.studio>

* refactor: add libp2p-ping to repo

Co-authored-by: David Dias <daviddias.p@gmail.com>
Co-authored-by: Francisco Baio Dias <xicombd@gmail.com>
Co-authored-by: Friedel Ziegelmayer <dignifiedquire@gmail.com>
Co-authored-by: Hugo Dias <mail@hugodias.me>
Co-authored-by: Jacob Heun <jacobheun@gmail.com>
Co-authored-by: João Antunes <j.goncalo.antunes@gmail.com>
Co-authored-by: Richard Littauer <richard.littauer@gmail.com>
Co-authored-by: Vasco Santos <vasco.santos@moxy.studio>
Co-authored-by: Vasco Santos <vasco.santos@ua.pt>
Co-authored-by: ᴠɪᴄᴛᴏʀ ʙᴊᴇʟᴋʜᴏʟᴍ <victorbjelkholm@gmail.com>

* refactor: add libp2p-circuit to repo

Co-authored-by: David Dias <daviddias.p@gmail.com>
Co-authored-by: Dmitriy Ryajov <dryajov@gmail.com>
Co-authored-by: Friedel Ziegelmayer <dignifiedquire@gmail.com>
Co-authored-by: Hugo Dias <mail@hugodias.me>
Co-authored-by: Jacob Heun <jacobheun@gmail.com>
Co-authored-by: Maciej Krüger <mkg20001@gmail.com>
Co-authored-by: Oli Evans <oli@tableflip.io>
Co-authored-by: Pedro Teixeira <i@pgte.me>
Co-authored-by: Vasco Santos <vasco.santos@ua.pt>
Co-authored-by: Victor Bjelkholm <victorbjelkholm@gmail.com>
Co-authored-by: Yusef Napora <yusef@napora.org>
Co-authored-by: dirkmc <dirk@mccormick.cx>

* test(switch): avoid using instanceof

* chore(switch): update bignumber dep

* refactor(circuit): clean up tests

* refactor(switch): consolidate get peer utils

* test(identify): do deep checks of addresses

* test(identify): bump timeout for identify test

* test(switch): tidy up limit dialer test

* refactor(switch): remove redundant circuit tests

* chore: add coverage script

* refactor(circuit): consolidate get peer info

* docs: reference original repositories in each sub readme

* docs: fix comment

* refactor: clean up sub package.json files and readmes
2019-08-16 17:30:03 +02:00
Jacob Heun
fd738f9d51
refactor: add js-libp2p-switch to the libp2p codebase (#388)
Co-authored-by: Alan Shaw <alan.shaw@protocol.ai>
Co-authored-by: Alan Shaw <alan@tableflip.io>
Co-authored-by: Arnaud <arnaud.valensi@gmail.com>
Co-authored-by: David Dias <daviddias.p@gmail.com>
Co-authored-by: David Dias <mail@daviddias.me>
Co-authored-by: Dmitriy Ryajov <dryajov@gmail.com>
Co-authored-by: Francisco Baio Dias <xicombd@gmail.com>
Co-authored-by: Friedel Ziegelmayer <dignifiedquire@gmail.com>
Co-authored-by: Haad <haadcode@users.noreply.github.com>
Co-authored-by: Hugo Dias <mail@hugodias.me>
Co-authored-by: Hugo Dias <hugomrdias@gmail.com>
Co-authored-by: Jacob Heun <jacobheun@gmail.com>
Co-authored-by: Kevin Kwok <antimatter15@gmail.com>
Co-authored-by: Kobi Gurkan <kobigurk@gmail.com>
Co-authored-by: Maciej Krüger <mkg20001@gmail.com>
Co-authored-by: Matteo Collina <matteo.collina@gmail.com>
Co-authored-by: Michael Fakhry <fakhrimichael@live.com>
Co-authored-by: Oli Evans <oli@tableflip.io>
Co-authored-by: Pau Ramon Revilla <masylum@gmail.com>
Co-authored-by: Pedro Teixeira <i@pgte.me>
Co-authored-by: Pius Nyakoojo <piusnyakoojo@gmail.com>
Co-authored-by: Richard Littauer <richard.littauer@gmail.com>
Co-authored-by: Sid Harder <sideharder@gmail.com>
Co-authored-by: Vasco Santos <vasco.santos@ua.pt>
Co-authored-by: harrshasri <35241544+harrshasri@users.noreply.github.com>
Co-authored-by: kumavis <kumavis@users.noreply.github.com>
Co-authored-by: ᴠɪᴄᴛᴏʀ ʙᴊᴇʟᴋʜᴏʟᴍ <victorbjelkholm@gmail.com>
2019-08-08 19:01:16 +02:00
Jacob Heun
ff7a6c86a0
fix: promisified methods (#398)
* chore: update ws rendezvous dep

test(fix): fix tests with latest ws rendezvous server

* fix: promisification of libp2p methods

test: add tests to verify promisify support until async/await endeavor is complete

* chore: fix linting
2019-08-06 10:53:23 +02:00
Jacob Heun
3e95e6f9e4
fix: dont override methods of created instance (#394)
* fix: dont override methods of created instance

* chore: fix lint
2019-08-01 16:08:38 +02:00
Jacob Heun
f4f3f0f03a
fix: pubsub default config (#393)
* docs: update browser example pubsub

* docs: fix pubsub example config

* fix: make pubsub default to enabled

This allows for only adding the module to have it enabled. Previously you would have to supply and enable the module which is unncessary for users
2019-07-31 18:47:30 +02:00
Vasco Santos
dd48d268ec chore: promisify pubsub start and stop (#392) 2019-07-31 14:33:00 +02:00
Vasco Santos
791f39a09b feat: integrate gossipsub by default (#365)
BREAKING CHANGE: new configuration for deciding the implementation of pubsub to be used.
In this context, the experimental flags were also removed. See the README for the latest usage.
2019-07-31 09:38:14 +02:00
Jacob Heun
65d52857a5
test(fix): correct findProviders test for missing provider (#391)
* test(fix): correct findProviders test for missing provider

* chore: fix lint
2019-07-30 15:11:24 +02:00
Jacob Heun
9554b05c6f
fix: make subscribe comply with ipfs interface (#389)
BREAKING CHANGE: The ipfs interface specified that options
should be provided after the handler, not before.
https://github.com/ipfs/interface-js-ipfs-core/blob/v0.109.0/SPEC/PUBSUB.md#pubsubsubscribe

This corrects the order of parameters. See the jsdocs examples
for subscribe to see how it should be used.
2019-07-30 12:36:23 +02:00
Alex Potsides
df6ef45a2d feat: promisify all api methods that accept callbacks (#381)
* feat: promisify all api methods that accept callbacks

This is a stop-gap until the full async/await migration can be
completed.  It means we can refactor tests of other modules that
depend on this module without having to mix async flow control
strategies.

N.b. some methods that were previously callable without callbacks
(e.g. `node.start()`, `node.stop()`, etc) now require callbacks
otherwise a promise is returned which, if rejected, can cause
`unhandledPromiseRejection` events and lead to memory leaks.

* docs: add a global note to the api about promisify

* fix: update the logic for unsubscribe

* test(fix): correct pubsub unsubscribe usage for api change

* test(fix): update content routing tests for latest delegate version
2019-07-29 15:40:40 +02:00
Vasco Santos
905c911946 fix: peer routing for delegate router (#377)
* fix: peer routing tests

* test: fix mock payload type

Provider results are type 4, not type 1: 6e566d10f4/routing/query.go (L15-L24)
2019-07-12 13:02:03 +01:00
Jacob Heun
04faf1806c
feat: add createLibp2p to generate a PeerInfo instance (#367)
createLibp2p is a new exported helper function that allows users to create a libp2p instance without worrying about creating a PeerInfo instance first.
2019-06-06 12:21:31 +02:00
Guy Sviry
b06ca1b3c7 feat: pass libp2p as option to transport creation (#363) 2019-05-17 12:11:22 +02:00
Jacob Heun
40978a1940
feat: sign pubsub messages (#362)
* fix: forward pubsub publish callback to floodsub

chore: update floodsub version

* test: add random walk delay to config

* chore: update floodsub
2019-05-07 13:45:59 +02:00
Jacob Heun
f3801f0e6c
fix: dht config (#359) 2019-04-17 15:04:35 +02:00
Jacob Heun
51cc993876
docs: fix incorrect references for enabling dht discovery (#358) 2019-04-16 15:04:23 +02:00
Jacob Heun
f28dffb268
fix: bail when discovering self (#357) 2019-04-16 12:05:22 +02:00
Jacob Heun
eb5aa03232
fix: allow switch to be configured (#354) 2019-04-12 11:10:09 +02:00
Jacob Heun
313b1eae20
fix: connection emits (#352)
* fix: add connection tracking events

* chore: update dependencies
2019-04-11 13:49:31 +02:00
Jacob Heun
01aa44724e
feat: auto dial discovered peers (#349) 2019-04-11 12:44:58 +02:00
Jacob Heun
e5f19e860b
fix: remove unneeded peerbook puts (#348) 2019-04-05 14:27:35 +02:00
Jacob Heun
eee60ed37d
feat: update to the latest switch (#336) 2019-03-21 14:23:00 +01:00
Jacob Heun
e52ce66ab7
fix: disable dht by default #338 (#339)
fix: correct transport config check
2019-03-20 09:12:02 +01:00
Vasco Santos
eb10b5c6d2 chore: disable dht discovery (#333) 2019-03-06 11:21:43 +01:00
Vasco Santos
de84ee473c chore: add error codes to dht and pubsub errors (#328)
* chore: add error codes to dht and pubsub errors

* fix: code review
2019-02-26 15:15:30 +01:00
Jacob Heun
5f92acd5bb
fix: make the config less restrictive (#329) 2019-02-25 12:19:37 +01:00
Hugo Dias
d497961938 fix: bundle-size (#298)
* fix: bundle-size

* fix: feedback

* fix: lint

* chore: update deps

* fix: add bundle size check and update deps

* fix: fix badges

* fix: add once to package.json

* fix: fix config validation
2019-02-21 17:07:35 +01:00
isan_rivkin
6e76aade7f feat: support unsubscribe all for pubsub (#321)
* chore: unsubscribe without handler reference

* chore: added unsubscribe 1 param
2019-02-21 14:46:31 +01:00
Thomas Eizinger
4ed5c039fc chore: change from ipfs to p2p protocol (#315)
https://github.com/multiformats/js-multiaddr/pull/76 changed the
default protocol from ipfs to p2p.

js-multiaddr is a transitive dependency of peer-info, so in order
to get this change, we had to bump the version of peer-info.

* fix: revert ipfs -> p2p change for some tests

As per PR feedback. Needed for backwards-compatibility.
2019-02-05 19:59:42 +01:00
Vasco Santos
9e7a080a5c fix: emit peer discovery for dht discovery 2019-02-05 19:54:02 +01:00
Jacob Heun
558e5987be chore: remove _isStarted as it's no longer used
_isStarted is an outdated property and shouldn't exist
in the code anymore. The state machine handles start
logic and the isStarted computed property pulls from there.
The code comments around dht and pubsub are also no
longer valid, so they were deleted.
2019-02-05 15:57:10 +01:00
Thomas Eizinger
91e60d4253
feat: prepare for new randomWalk config parameters
As per: https://github.com/libp2p/js-libp2p-kad-dht/issues/76

fix: pass whole dht config into DHT constructor
2019-02-05 12:42:40 +01:00
ebinks
679d446daa
fix: add callback to pubsub.unsubscribe and test (#300) 2019-02-01 19:27:47 +01:00
Jacob Heun
8047fb76fa
fix: start and stop error callback (#316)
* fix: ensure start and stop callbacks are called
2019-02-01 16:32:34 +01:00
Vasco Santos
c4cab007af feat: enable dht by default (#313)
BREAKING CHANGE: dht experimental flag was removed and a dht.enabled property was added to the config
2019-01-29 18:57:09 +01:00
Jacob Heun
fdfb7b4e86
fix: not started yet (#297)
* fix: callback when not started rather than throwing asserts

* fix: dont remove transports until the switch has stopped

* test: update connection check logic

* test: fix variable reference

* chore: update switch dep

* chore: update switch dep
2018-12-14 17:54:32 +01:00
Jacob Heun
53ed3bdb99
fix: use symbol instead of constructor name (#292) 2018-12-04 16:04:17 +01:00
Vasco Santos
7d12eb9e26 feat: allow configurable validators and selectors to the dht (#288)
* feat: allow configurable validators and selectors to the dht

* chore: remove fallback
2018-11-29 15:10:23 +01:00
Vasco Santos
970deec2a4 feat: add maxNumProviders to findprovs (#283)
* feat: add maxNumProviders to findprovs

* chore: upgrade libp2p-kad-dht
2018-11-13 11:46:51 +01:00
Jacob Heun
714b6ec2b9 fix: improve get peer info errors 2018-11-12 19:26:40 +01:00
Jacob Heun
f71fdfdf35 feat: conditionally emit errors
test: add tests for emit override
2018-11-12 19:26:04 +01:00
Jacob Heun
17b5f73b3d fix: dont call callback before it's properly set 2018-11-05 15:43:59 +01:00
Vasco Santos
40e840d5fd feat: add datastore to config 2018-10-31 14:43:16 +01:00
Jacob Heun
0b75f99d75
feat: make libp2p a state machine (#257)
* docs: add events to readme
2018-10-19 17:37:34 +02:00
Jacob Heun
686379efb0
feat: enable relay by default (no hop) (#254)
docs: update readme default relay
2018-10-19 16:31:40 +02:00
Jacob Heun
a95389a28e
feat: add delegated peer and content routing support (#242)
* feat: allow for configuring content and peer routing

* feat: support multiple peer and content routing modules

* docs: add delegated routing example
2018-10-19 16:28:28 +02:00