Commit Graph

96 Commits

Author SHA1 Message Date
fbb1b3668a RT connectivity changes 2020-03-10 14:51:28 -07:00
7ada018b2a Upgrade DHT version (#479)
* upgraded the protocol id to version 2 (i.e. /kad/2.0.0) and made it so v2 peers running in server mode respond to queries from v1 peers. Note: v2 peers will only send queries using the v2 protocol, will only add v2 peers to their routing tables, and will only tell v1 peers about v2 peers.
* to run a forked network we now use network specific protocol prefixes instead of manually setting protocol IDs. Use the ProtocolPrefix option instead of the Protocols option.
* emit errors during initialization if the user misuses the default protocol prefix by setting parameters inconsistent with the default protocol's network specification
* since the Client option has been deprecated it's been removed from the dht's options. While deprecated it is still available in the dht options package. Setting `Client(false)` now puts the node into ModeAuto.
2020-03-10 16:22:41 -04:00
c24a52fc7c Enable switching DHT between client and server modes (#469)
* created Mode(ModeOpt) option for choosing between auto/client/server modes
* Auto mode internally switches the DHT between client and server modes based on the EvtLocalReachabilityChanged event emitted on the event bus (e.g. by AutoNAT)
* routing table management of peers that switch between client and server mode while we are connected to them (i.e. are in auto mode)
* removed Client(bool) option, becoming a DHT client is specified using Mode(ModeClient) instead
2020-03-06 14:56:03 -05:00
5d313b134c Utilize identify events to add peers to the routing table (#472)
* feat: consume identify events to evaluate routing table addition
* fix: routing table no longer gets an update just because new messages have arrived or been sent
* fix: add already connected peers into the routing table before listening to events

Co-authored-by: Raúl Kripalani <raul.kripalani@gmail.com>
Co-authored-by: Aarsh Shah <aarshkshah1992@gmail.com>
2020-03-04 22:26:30 -08:00
dbb3d2c0a2 Merge pull request #462 from libp2p/fix/observe-context-in-message-sender
fix: obey the context when sending messages to peers
2020-03-04 22:10:51 -08:00
faa56381cb net: address PR comments regarding metrics 2020-03-02 13:11:56 +01:00
979ed6ab6c metrics: also record message/request event on error
... otherwise any kinde of error ratio is meaningless.
2020-02-27 16:24:46 +01:00
fe2d21acf9 immediate buffer release instead of defering 2020-02-27 15:52:40 +01:00
0b029388bd fix: obey the context when sending messages to peers
Related to #453 but not a fix. This will cause us to actually return early when
we start blocking on sending to some peers, but it won't really _unblock_ those
peers. For that, we need to write with a context.
2020-02-22 16:34:56 -05:00
3f8b219554 feat: reduce stream idle timeout to 1m
It's currently 10 minutes. This change will kill all inbound DHT streams that
haven't been used in 1 minute.

We keep streams around to avoid the cost of setting up new streams (the
multistream overhead, mostly). However, each one of these takes at least one
goroutine and some other state.

Ideally, this will let us run multiple DHTs side-by-side without keeping one
stream per peer per DHT open.
2020-01-23 09:04:13 -08:00
3d68f5bf1f metrics: fix memory leak
fixes #389

Credit goes to @sidenaio for finding this.
2019-09-04 16:06:10 -07:00
855b46d37e Address review comments
Update msgio to latest version
Use max size in msgio readers
Fix error handling in reads
2019-06-18 08:52:46 -04:00
f0593aa9f9 Replace delimited reader in message sender 2019-06-17 18:36:27 -04:00
feee52a32b Replace delimited reader with msgio VarintReader 2019-06-17 18:13:12 -04:00
31765355df migrate to consolidated types. (#344) 2019-05-26 23:33:15 +01:00
b55fad1580 kill idle streams after 10 minutes 2019-05-24 01:15:27 -07:00
5bf9cf5e1a drop the go-context dependency
This was causing us to build up a bunch of background goroutines. Technically,
we should be resetting all these streams when the DHT stops. However, we don't
actually unregister stream handlers from the host so, really, nothing will
actually stop till the host stops. When it does, it'll kill all the streams
anyways.
2019-05-24 01:13:52 -07:00
c8cce79033 fix: reduce memory used by buffered writers
Allocate them as-needed and use a pool.

Work towards #322.
2019-05-07 18:00:58 -07:00
cf9bd9b649 Add opencensus basic metrics (#317)
Add initial set of metrics exposed via OpenCensus.
2019-04-15 13:18:47 +10:00
6eafd65baa thread context to prep (#286)
We usually _explicitly_ call connect before calling `prep` but we may disconnect
somewhere in-between. We _don't_ want to get stuck here dialing if the context
has been canceled.
2019-03-07 18:53:16 +11:00
4d5f60195f Rework handleNewStream (#267) 2019-02-19 13:38:03 +11:00
120a585ebf Revert "Test go mod in travis and use major versioning in import paths (#236)"
This reverts commit 7e68ac3c60.
2019-02-12 14:12:53 +00:00
7e68ac3c60 Test go mod in travis and use major versioning in import paths (#236) 2019-02-12 17:38:06 +11:00
8b37385468 Rename log to logger 2019-02-03 13:14:35 +11:00
da02d4a7d5 also use the buffered writer for handling new messages 2018-08-05 16:43:15 +07:00
6d6ed07850 buffer writes when sending protobufs
The protobuf writer performs multiple small writes when writing a
message. We need to buffer these, otherwise we'll send out a packet for
each Write call.
2018-08-05 13:03:29 +07:00
63b47bb368 Merge pull request #166 from libp2p/fix/161
fix dht client bugs
2018-06-26 00:03:58 +00:00
94fc630110 avoid adding dht *clients* to routing tables
fixes #162
2018-06-14 20:14:11 -07:00
1d13eafc97 be more polite about closing streams
When a peer sends use a EOF after they're done sending us messages, we should be
polite and send one back.
2018-06-12 17:13:05 -07:00
16de81932c fully close streams
That is, actually wait for the other end to send us an EOF.
2018-06-04 21:45:40 -07:00
d94deae41d make DHT protocols pluggable 2018-06-01 14:55:16 -07:00
5b673372eb fix comment on invalidate. 2017-09-19 15:42:01 -07:00
4237ef0939 fix memory leak holding onto streams unnecessarily 2017-09-19 12:00:42 -07:00
5bc13bf691 reset streams on error instead of closing. 2017-09-14 10:30:55 -07:00
d3d572b74d Retry queries if a write to the stream fails.
Previously, we'd only retry when a write failed (in case the peer was using
single-use streams). However, in the new world of half-open streams, writes
still succeed on remote-closed streams so this isn't sufficient. Instead, we
need to retry on read failure as well.

Note: this was technically broken before because a peer could write on a stream
before receiving the close message causing the write to succeed but the
subsequent read to fail.
2017-09-14 10:30:52 -07:00
286dd24fd2 update stream muxer 2017-09-14 09:41:26 -07:00
6894f33507 update dependencies after package extraction funtime 2016-10-05 12:34:28 -07:00
e00b3ca0a4 use stdlib context and clean up deps 2016-09-30 10:24:03 -07:00
d09b2e73d0 add back patch with protocol updates 2016-09-23 02:45:58 -07:00
9b3d1b5661 Bump deps, revert protobuf 2016-09-03 20:35:59 +01:00
30d43d22e0 Fix dependencies 2016-09-02 20:21:23 +01:00
5f3e63aa46 Undo gx rewrites and add gx package.json 2016-08-21 17:18:58 +01:00
95553964a2 update go-libp2p
License: MIT
Signed-off-by: Jeromy <why@ipfs.io>
2016-07-04 12:27:26 -07:00
22af8d1151 Update go-log in whole dependency tree (#2898)
* Update golog in go-ipfs

License: MIT
Signed-off-by: Jakub Sztandera <kubuxu@protonmail.ch>

* Update go-libp2p for go-log

License: MIT
Signed-off-by: Jakub Sztandera <kubuxu@protonmail.ch>

* Update go-libp2p-secio for go-log

License: MIT
Signed-off-by: Jakub Sztandera <kubuxu@protonmail.ch>

* Update go-libp2p-crypto for go-log

License: MIT
Signed-off-by: Jakub Sztandera <kubuxu@protonmail.ch>

* Update go-libp2p-peer for go-log

License: MIT
Signed-off-by: Jakub Sztandera <kubuxu@protonmail.ch>

* Import peersore, it wasn't imported

License: MIT
Signed-off-by: Jakub Sztandera <kubuxu@protonmail.ch>

* Update peerstore

License: MIT
Signed-off-by: Jakub Sztandera <kubuxu@protonmail.ch>

* Update peer

License: MIT
Signed-off-by: Jakub Sztandera <kubuxu@protonmail.ch>

* Update secio

License: MIT
Signed-off-by: Jakub Sztandera <kubuxu@protonmail.ch>

* Update go-libp2p

License: MIT
Signed-off-by: Jakub Sztandera <kubuxu@protonmail.ch>
2016-06-24 09:38:07 -07:00
c29e3e29fd implement some simple dht request read timeouts
License: MIT
Signed-off-by: Jeromy <why@ipfs.io>
2016-06-17 11:01:41 -07:00
3f05aa0579 Merge pull request #2853 from ipfs/feature/decapitalize-Debug
Decapitalized log.Debug messages
2016-06-17 10:26:20 -07:00
47d10d7be6 update go-libp2p to 3.3.4
License: MIT
Signed-off-by: Jeromy <why@ipfs.io>
2016-06-15 13:04:49 -07:00
e7519fa51a Merge pull request #2856 from ipfs/fix/send-msg-race
pass reference to reader instead of using the one on the object
2016-06-15 12:47:01 -07:00
23050f9e30 pass reference to reader instead of using the one on the object
License: MIT
Signed-off-by: Jeromy <why@ipfs.io>
2016-06-15 11:13:35 -07:00
2203d3b1fe Decapitalized log.Debug messages
According to golang standards, these should not be capitalized nor having a trailing period, AFAIK.

License: MIT
Signed-off-by: Richard Littauer <richard.littauer@gmail.com>
2016-06-15 08:56:34 +01:00