160 Commits

Author SHA1 Message Date
Vasco Santos
83409deaa6 fix: registrar should filter the disconnected conn (#532)
* fix: registrar on disconnect only when no connections

* chore: add test
2020-01-14 12:26:24 +01:00
Alan Shaw
c44e6e33ed fix: stop discoveries (#530)
* fix: stop discoveries

* test: add discovery stop test

* chore: fix lint

Co-authored-by: Jacob Heun <jacobheun@gmail.com>
2020-01-07 16:27:32 +01:00
Alan Shaw
a1717dac6a fix: conn mngr min/max connection values (#528)
Fixes the case when options are passed with `maxConnections` and/or `minConnections` set to `undefined`:

```console
{
  defaultOptions: {
    maxConnections: Infinity,
    minConnections: 0,
    maxData: Infinity,
    maxSentData: Infinity,
    maxReceivedData: Infinity,
    maxEventLoopDelay: Infinity,
    pollInterval: 2000,
    movingAverageInterval: 60000,
    defaultPeerValue: 1
  },
  options: {
    minPeers: 25,
    maxConnections: undefined,
    minConnections: undefined
  }
}
{ maxConnections: undefined, minConnections: undefined }
      1) "before all" hook in "custom config"
(node:67176) UnhandledPromiseRejectionWarning: AssertionError [ERR_ASSERTION]: Connection Manager maxConnections must be greater than minConnections
    at new ConnectionManager (node_modules/libp2p/src/connection-manager/index.js:43:5)
    at new Libp2p (node_modules/libp2p/src/index.js:92:30)
    at Object.module.exports [as libp2p] (src/core/components/libp2p.js:27:10)
    at Proxy.start (src/core/components/start.js:48:31)
    at async Daemon.start (src/cli/daemon.js:63:31)
    at async startHttpAPI (test/http-api/routes.js:29:5)
    at async Context.<anonymous> (test/http-api/routes.js:48:7)
```
2020-01-06 07:03:07 -07:00
Jacob Heun
0d4b2bd23d
feat: allow transport options to be passed on creation (#524)
* feat: allow transport options to be passed on creation

* fix: only add circuit transport if enabled

* chore: fix lint
2019-12-20 08:32:46 -08:00
Jacob Heun
6ca19c5ef4
feat: add libp2p.connections getter (#522)
* fix: make hangup accept what the API says it does

* feat: add libp2p.connections getter

* chore: fix typo
2019-12-16 19:24:35 +01:00
Jacob Heun
24c3ce6f8d
fix: make dialer configurable (#521)
docs: update configuration and api docs
2019-12-16 16:49:29 +01:00
Vasco Santos
56a1825639 fix: upgrader should not need muxers (#517)
* fix: upgrader should not need muxers

* chore: address review

* chore: apply suggestions from code review

Co-Authored-By: Jacob Heun <jacobheun@gmail.com>
2019-12-16 12:26:38 +01:00
Jacob Heun
4a871bbf8b
feat: coalescing dial support (#518)
* docs: fix spelling in api

* fix: dont create peerstore twice

* feat: add support for dial coalescing

* doc(fix): add setPeerValue to API TOC

* docs: add more jsdocs to dialer

* chore: remove old comment

* fix: ensure connections are closed

* fix: registrar.getConnections returns first open conn

* fix: directly set the closed status

* chore: remove unneeded log

* refactor: peerStore.put takes an options object
2019-12-15 17:33:16 +01:00
Jacob Heun
45f47023d2
refactor: connection manager (#511)
* refactor: initial refactor of the connection manager

* fix: start/stop issues

* fix: add tests and resolve pruning issues

* chore: fix lint

* test: move conn manager tests to node only for now

* chore: apply suggestions from code review

Co-Authored-By: Vasco Santos <vasco.santos@moxy.studio>

* fix: assert min max connection options

* test: fix assertion check for browser

* docs: add api and config docs for conn manager
2019-12-12 10:29:10 +01:00
Vasco Santos
af96dcc499
feat: discovery modules from transports should be added (#510)
* feat: discovery modules from transports should be added

* chore: apply suggestions from code review

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

* chore: address review

* chore: apply suggestions from code review

Co-Authored-By: Jacob Heun <jacobheun@gmail.com>
2019-12-12 10:29:10 +01:00
Jacob Heun
f540112835
refactor: stats (#501)
* docs: add initial notes on stats

* feat: initial refactor of stats to metrics

* feat: add support for placeholder metrics

This is helpful for tracking metrics prior to knowing the remote peers id

* fix: add metrics tests and fix issues

* fix: always clear the dial timeout timer

* docs: add metrics to api doc

* chore: apply suggestions from code review

Co-Authored-By: Vasco Santos <vasco.santos@moxy.studio>

* docs: update metrics docs

* fix: call metrics.onDisconnect

* docs(config): add example headers so they appear in the TOC

* docs(config): add metrics configuration

* docs(relay): fix relay configuration docs
2019-12-12 10:29:10 +01:00
Vasco Santos
64cbf90e02
refactor: ping (#505)
* refactor: ping

* chore: ping is now a function

* chore: address review
2019-12-12 10:29:10 +01:00
Jacob Heun
7fc1900343
chore: it-all over async-iterator-all 2019-12-12 10:29:09 +01:00
Jacob Heun
9b10e09cc0
chore: move stats folder and delete old switch code 2019-12-12 10:29:09 +01:00
Jacob Heun
1838a641d9
fix: token release logic 2019-12-12 10:29:08 +01:00
Jacob Heun
43440aa8a6
fix: release tokens as soon as they are available 2019-12-12 10:29:08 +01:00
Jacob Heun
7c3371bf17
fix: clean up pending dials abort per feedback 2019-12-12 10:29:08 +01:00
Jacob Heun
43b98e64b6
docs: add DialRequest description 2019-12-12 10:29:07 +01:00
Jacob Heun
754fbc2d0b
feat: abort all pending dials on stop 2019-12-12 10:29:07 +01:00
Jacob Heun
c7dcfe5e48
test: add tests for DialRequest 2019-12-12 10:29:06 +01:00
Jacob Heun
53ce404260
chore: update per feedback 2019-12-12 10:29:06 +01:00
Jacob Heun
43a3b85f1a
refactor: cleanup and reorganize 2019-12-12 10:29:06 +01:00
Jacob Heun
e8bf12b68a
chore: update docs
fix: protect against duplicate token releases
2019-12-12 10:29:05 +01:00
Jacob Heun
7d1cb5423f
chore: fix linting 2019-12-12 10:29:05 +01:00
Jacob Heun
c4be5f4aaf
refactor: consolidation multiaddr dial methods 2019-12-12 10:29:05 +01:00
Jacob Heun
a37c5c0144
refactor: clean up dial timeout abort 2019-12-12 10:29:05 +01:00
Jacob Heun
24c603741f
feat: add early token recycling in 2019-12-12 10:29:05 +01:00
Jacob Heun
ea62c52701
refactor: simplify DialRequest logic per feedback 2019-12-12 10:29:04 +01:00
Jacob Heun
f9fe44f6b7
chore: use any-signal module 2019-12-12 10:29:04 +01:00
Jacob Heun
d5405dbb08
refactor: PER_PEER_LIMIT is now MAX_PER_PEER_DIALS 2019-12-12 10:29:04 +01:00
Jacob Heun
571fd3b7d1
chore: apply suggestions from code review
Co-Authored-By: Vasco Santos <vasco.santos@moxy.studio>
Co-Authored-By: Alan Shaw <alan.shaw@protocol.ai>
2019-12-12 10:29:04 +01:00
Jacob Heun
cba2c6d8b2
chore: remove commented code 2019-12-12 10:29:04 +01:00
Jacob Heun
f8540fa3ed
feat: add token based dialer 2019-12-12 10:29:03 +01:00
Jacob Heun
f3eb1f1201
fix: clean up peer discovery flow (#494)
* fix: clean up peer discovery flow

* test(fix): let libp2p start after connecting

* test(fix): dont auto dial in disco tests
2019-12-12 10:29:03 +01:00
Vasco Santos
dbb9e57311
chore: update pubsub implementations (#493) 2019-12-12 10:29:03 +01:00
Vasco Santos
11ed6bd14c
feat: support peer-id instances in peer store operations (#491) 2019-12-12 10:29:02 +01:00
Vasco Santos
fc22c36ba7
refactor: async routing (#489)
* feat: async routing

* chore: put dht extra api commands under content routing

* chore: add default option to createPeerInfo

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

* chore: address review

* chore: rm dlv
2019-12-12 10:29:02 +01:00
Jacob Heun
b518391a47
refactor: circuit relay to async (#477)
* refactor: add dialing over relay support

* chore: fix lint

* fix: dont clear listeners on close

* fix: if dial errors already have codes, just rethrow them

* fix: clear the registrar when libp2p stops

* fix: improve connection maintenance with circuit

* chore: correct feedback

* test: use chai as promised

* test(fix): reset multiaddrs on dial test
2019-12-12 10:29:02 +01:00
Vasco Santos
997ee166b0
feat: discovery modules (#486)
* feat: discovery modules

* chore: address review
2019-12-12 10:29:02 +01:00
dirkmc
acbbc0f84e
fix: replace peerInfo addresses with listen addresses (#485)
* feat: replace peer info addresses with listen addresses

* test: add listening test

* chore: fix linting
2019-12-12 10:29:02 +01:00
Vasco Santos
1ea945ad24
refactor: dht async/await (#480)
* refactor: core async (#478)

* refactor: cleanup core

test: auto dial on startup

* fix: make hangup work properly

* chore: fix lint

* chore: apply suggestions from code review

Co-Authored-By: Vasco Santos <vasco.santos@moxy.studio>

* fix: provide libp2p dialer to the dht

* chore: use dht release
2019-12-12 10:29:01 +01:00
Jacob Heun
c37703dc17
refactor: update secio and tests to use it (#484)
* refactor: use async secio

* test: add secio to most test suites

* chore: update secio version
2019-12-12 10:29:01 +01:00
Jacob Heun
86b275a0d3
refactor: core async (#478)
* refactor: cleanup core

test: auto dial on startup

* fix: make hangup work properly

* chore: fix lint

* chore: apply suggestions from code review

Co-Authored-By: Vasco Santos <vasco.santos@moxy.studio>
2019-12-12 10:29:01 +01:00
Vasco Santos
34d57f8989
refactor: pubsub (#467)
* feat: peer-store v0

* chore: apply suggestions from code review

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

* chore: address review

* refactor: pubsub subsystem

* chore: address review

* chore: use topology interface

* chore: address review

* chore: address review

* chore: simplify tests
2019-12-12 10:29:00 +01:00
Jacob Heun
ced2dbf318
chore: update it-length-prefixed (#476)
fix: decode.fromReader usage
2019-12-12 10:29:00 +01:00
Jacob Heun
44d47087d1
refactor: async identify and identify push (#473)
* chore: add missing dep

* feat: import from identify push branch

https://github.com/libp2p/js-libp2p-identify/tree/feat/identify-push

* feat: add the connection to stream handlers

* refactor: identify to async/await

* chore: fix lint

* test: add identify tests

* refactor: add identify to the dialer flow

* feat: connect identify to the registrar

* fix: resolve review feedback

* fix: perform identify push when our protocols change
2019-12-12 10:29:00 +01:00
Vasco Santos
797d8f0cf1
feat: registrar (#471)
* feat: peer-store v0

* feat: registrar

* chore: apply suggestions from code review

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

* chore: address review

* chore: support multiple conns

* chore: address review

* fix: no remote peer from topology on disconnect
2019-12-12 10:29:00 +01:00
Vasco Santos
f3e276eb79
feat: peer store (#470)
* feat: peer-store v0

* chore: apply suggestions from code review

Co-Authored-By: Jacob Heun <jacobheun@gmail.com>
2019-12-12 10:28:59 +01:00
Jacob Heun
138bb0bbae
refactor: crypto and pnet (#469)
* feat: add initial plaintext 2 module

* refactor: initial refactor of pnet

* chore: fix lint

* fix: update plaintext api usage

* test: use plaintext for test crypto

* chore: update deps

test: update dialer suite scope

* feat: add connection protection to the upgrader

* refactor: cleanup and lint fix

* chore: remove unncessary transforms

* chore: temporarily disable bundlesize

* chore: add missing dep

* fix: use it-handshake to prevent overreading

* chore(fix): PR feedback updates

* chore: apply suggestions from code review

Co-Authored-By: Vasco Santos <vasco.santos@moxy.studio>
2019-12-12 10:28:59 +01:00
Jacob Heun
af364b070b
refactor(async): add dialer and upgrader (#462)
* chore(deps): update connection and multistream

* feat: add basic dial support for addresses and peers

* test: automatically require all node test files

* fix: dont catch and log in the wrong place

* test: add direct spec test

fix: improve dial error consistency

* feat: add dial timeouts and concurrency

Queue timeouts will result in aborts of the dials

* chore: fix linting

* test: verify dialer defaults

* feat: add initial upgrader

* fix: add more test coverage and fix bugs

* feat: libp2p creates the upgrader

* feat: hook up handle to the upgrader

* feat: hook up the dialer to libp2p

test: add node dialer libp2p tests

* feat: add connection listeners to upgrader

* feat: emit connect and disconnect events

* chore: use libp2p-interfaces

* fix: address review feedback

* fix: correct import

* refactor: dedupe connection creation code
2019-12-12 10:28:59 +01:00