- Adding peers to peer pool on incoming connection
- Exclude bootnodes from nodes to connect to
- Check if peer is already connected to before adding to peer pool
- Check if peer is still connected to before removing from peer pool
Enable by compiling with -d:p2pdump. A chronicles log file named
p2p_messages.json will be created in the working directory. This
file will be consumed by the upcoming Chronicles Tail GUI (more
details will be provided on the wiki of this repo).
Other changes:
* Removes the use of package_visible_types (only partially so far)
* Simplifies the new Snappy code a little bit
This also restores the old module structure of having separate
`peer_pool` and `rlpx` modules. This is made possible by the
new Nim package `package_visible_types` (please refer to its
README for an explanation).
Also introduces more error handling in the low-level RLPx routines.
All detected errors will result in immediate disconnection of the
corresponding peer, which may be detected in the protocols though
the `onPeerDisconnected` event handler.
In the next commit, I'm going to squash all the changes in the LES.
This commit just sets the directory tree to its final state, so the
diffs in the follow up commits are easier to review.
Please note that eth.nim was renamed to eth_protocol.nim, because
it's not advisable to have a module name that shares the name of
a protocol identifier (this creates hard to figure out ambiguity
errors)
* Perform per-protocol handshakes after connecting
* Initialize the per-protocol Peer and Network states properly
* Add an `EthereumNode` object that can be configured with specific
capabilities and connected to a specific network.
This was done because a cycle was formed between the structures
of the three modules:
- A Peer holds a reference to its Network
- The Network holds a reference to its PeerPool
- The PeerPool keeps a table of connected Peers
I could have resolved the issue by introducing a new types module,
but it would have required all of the currently private fields to
become public (due to lack of package-level visibility in Nim).
Instead I decided to merge the modules because they were relatively
small anyway. Please note that the former `P2PServer` type is now
called `NetworkConnection`. There are slight changes in the APIs
that will be carried out in Nimbus when merging this.
* Make all handlers async
* Added a new `requestResponse` construct that allows you to wait
for the results of a particular request
* Introduced an optional `NetworkState` type for the protocol
* The semantics of `nextMsg` has changed. See the notes in the README