* 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
createLibp2p is a new exported helper function that allows users to create a libp2p instance without worrying about creating a PeerInfo instance first.
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.
_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.
* 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
* fix: start kad dht random walk
* chore: added tests and stop random walk
* chore: allows to disable discovery for dht
* chore: upgrade kad-dht version
Configuration for the peer discovery modules is now optional so this does not need to be validated. This also cleans up the config module to reduce repetition.
License: MIT
Signed-off-by: Alan Shaw <alan@tableflip.io>
This PR will enable any provided peer discovery modules by default if no configuration for the module is supplied/needed.
As before, modules can be explicitly disabled or enabled by passing config.
This also enables pre-configured modules (instances) to be passed and enabled without them having to have a `tag` and an unused config section.
License: MIT
Signed-off-by: Alan Shaw <alan@tableflip.io>
* docs: update chat example and add info to its readme
* docs: update echo example
* docs: update libp2p in browser example
* docs: update pubsub example
* docs: update peer and content routing examples
* docs: update discovery mechanisms example
* docs: update encrypted comms example
* docs: update protocol and stream muxing example
* feat: add config validation
* test: update CI configs, use only node 8