Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Separate Peer into InetPeer (for remote peer), LocalPeer (for the local peer information, and ImmutablePeer for lists of peers that are obtained or sent via peer sharing mechanisms (tracker, PEx, etc.)
InetPeer is not suitable for using as a Map key because it is mutable, including the remote port. The remote port for incoming connections is not known until the extended handshake is completed.
Many extension modules implemented must store state on a per peer basis - it is required by many extension specifications. However the implementations that use Map<Peer, State> are clumsy. These maps must be cleaned whenever a peer disconnects.
This has been solved by adding an additional state map in the ConnectionState object that takes a state class and returns its instance for the peer.
Also, many modules have a common check they need to do - check whether the module is supported by the remote peer. The state of supported modules is now stored in the Peer object, to eliminate the need for all of the modules to consume the ExtendedHandshake message. Also, removing support for protocols is now supported.
PEx now shares additional information about peers. It shares whether they are seeding, whether they are using encryption, as well as whether our connection to them is outgoing or incoming. uTP and hole punching are still not implemented.