Commit Graph

34 Commits

Author SHA1 Message Date
Matt Joiner 214fe6b93c
Use webrtc local addr for webrtc conn peer priority
WebRTC conns are providing the correct IP for peer priority calculations, so use that instead of trying to guess (which doesn't work if there are no regular conn listeners attached to the Client.

(cherry picked from commit e86bb5fee3958dc90a3d012469b1352005d6c9ad)
2022-07-12 15:52:03 +10:00
Matt Joiner 12279621e4
Check that incoming peer request chunk lengths don't exceed the upload rate limiter burst size
Should fix #759.
2022-06-25 23:16:58 +10:00
Matt Joiner 9a9c7dee00
Add and use typed roaring bitmap 2022-05-09 12:05:50 +10:00
Matt Joiner 83a8284d6a Add tests for preferred network direction 2022-01-12 15:01:33 +11:00
Matt Joiner 1bae62fd22 Dynamic outbound max requests
This might be one solution to https://github.com/anacrolix/torrent/issues/698.
2021-12-24 08:55:57 +11:00
Matt Joiner 506ff8d037 Use relative availabilities to determine piece request order
Most overhead comes from peers that connect that have everything, and we just increment every single piece's availability. There may be some unresolved determinism with torrents that share the same ordering.
2021-12-23 14:00:00 +11:00
Matt Joiner 74c70d852a Add TestHaveAllThenBitfield
The result of a misguided attempt to reduce piece peer availability increment and decrement overhead for have all/full-bitfield and conn closes.
2021-12-23 14:00:00 +11:00
Matt Joiner e7ee568c52 Fix BenchmarkConnectionMainReadLoop
Broken by piece request order changes.
2021-12-16 14:00:19 +11:00
Yaroslav Kolomiiets 4a06517856 PEX: fluid event log 2021-12-12 00:27:28 +11:00
Matt Joiner c6ee03f449 gofumpt 2021-11-08 14:47:01 +11:00
Matt Joiner eb2fc6dbef Fix panic in benchmark 2021-10-27 13:57:19 +11:00
Matt Joiner 529aaa9b1f Use roaring bitmap for pending pieces
Also makes a significant optimization for peerHasWantedPieces possible.
2021-10-19 14:08:56 +11:00
Matt Joiner 846167c63e Fix mainReadLoop benchmark 2021-09-30 12:01:34 +10:00
Matt Joiner 63b3d2d211 Track dirty chunks in a single bitmap on Torrent 2021-09-20 18:52:54 +10:00
Matt Joiner 1d2d1a9cde Store peer requests in a bitmap 2021-09-19 15:16:37 +10:00
YenForYang 29638d9e5d
Create default constructor for Client (#567)
Allow for certain values to always be properly initialized on construction -- namely the maps for now. I'm currently working on a change that requires a baseline constructor; this change would make the use of `chansync.BroadcastCond` and `chansync.SetOnce` obsolete -- i.e. one can have channel members without worrying about proper initialization/destruction of a `chan struct{}`.

As for why `makeClient` returns a value instead of a pointer: returning a value gives us more options -- you can always take a pointer from a value later on cheaply, and have things moved to the heap if they weren't already. The same can't be said about getting a value back from a pointer. GC also could potentially have less work to do. Plus I personally find ownership to be an important concept (semi-borrowed from rust) -- use of values make ownership clear.
2021-09-14 23:01:20 +10:00
YenForYang a8db640c62
Drop bradfitz/iter dependency (#605)
* Drop bradfitz/iter dependency

`range iter.N` looks nice and doesn't allocate, but unfortunately using a `range` expression blocks a function from being inlined wherever it's used (for now). It's not that we need inlining in all cases, but I do think a C-style for loop looks just as nice and is probably clearer to the majority. There also aren't any clear disadvantages to changing (unless you just happen to dislike the look of C)

* Update misc_test.go

* Update rlreader_test.go

* Update torrent_test.go

* Update bench_test.go

* Update client_test.go

* Update iplist_test.go

* Update mse_test.go

* Update peerconn_test.go

* Update peerconn.go

* Update order_test.go

* Update decoder_test.go

* Update main.go

* Update bench-piece-mark-complete.go

* Update main.go

* Update torrent.go

* Update iplist_test.go

* Update main.go
2021-09-14 13:46:50 +10:00
Matt Joiner 24ceed61da Break out peerConnWriter 2021-06-07 13:01:40 +10:00
Matt Joiner 5f8471e21b Rework storage.TorrentImpl to support shared capacity key 2021-06-07 13:01:39 +10:00
Matt Joiner 7f7c59d52e Replace internal/tmproot with Testing.TB.TempDir 2021-02-22 14:30:09 +11:00
Matt Joiner 456a2f7c5d Expose more callbacks and Request and ChunkSpec 2021-01-28 14:23:22 +11:00
Matt Joiner b5215ea7e8 Expose Peer.Network to replace Peer.RemoteAddr.Network 2021-01-25 15:49:48 +11:00
Matt Joiner 9f9953be52 Don't expose Peer network through RemoteAddr 2021-01-25 15:49:48 +11:00
Matt Joiner 27108bd2f7 Export Peer 2021-01-25 15:49:48 +11:00
Matt Joiner 9d0ea15044 Expose peer.RemoteAddr 2020-07-15 16:16:14 +10:00
Matt Joiner 02adc3f2ee Break peer out from PeerConn 2020-05-30 10:14:20 +10:00
Matt Joiner 4eee1ba261 Fix benchmark failing due to mainReadLoop returning io.EOF 2020-05-03 19:31:20 +10:00
Matt Joiner 12e377e3fe Count expected received chunks instead of flagging them
This can be racy. In the TestReceiveChunkStorageFailure, when we have a storage write failure, we request the chunk again, but the peer has sometimes already sent it, and we return from the connection read loop with unexpected chunk after receiving it twice.
2020-04-23 12:34:43 +10:00
Matt Joiner c27e3f8de3 Merge branch 'webtorrent' 2020-04-15 17:26:46 +10:00
Yaroslav Kolomiiets 2b2c480706 PEX: add periodic deltas 2020-04-15 17:24:44 +10:00
Yaroslav Kolomiiets 634edd2875 Share current connections with peers over PEX (anacrolix#341) 2020-04-15 17:24:44 +10:00
Matt Joiner f45dac1e38 Use offer_id for webrtc conn string 2020-04-13 14:04:34 +10:00
Matt Joiner ddddc63924 Expose PeerConn.PeerPieces
Fixes #375.
2020-02-21 11:51:24 +11:00
Matt Joiner dff436f102 Rename connection->PeerConn and fix exports 2020-02-21 11:07:50 +11:00