This is an automated email from the ASF dual-hosted git repository.
toulmean pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/incubator-tuweni.git
The following commit(s) were added to refs/heads/main by this push:
new 4f6019b Pick the eth subprotocol that was negotiated
new ac6db86 Merge pull request #248 from atoulme/eth_connection
4f6019b is described below
commit 4f6019b915ebf327c7bc431554dc6f74a1878e93
Author: Antoine Toulme <[email protected]>
AuthorDate: Thu May 27 22:40:57 2021 -0700
Pick the eth subprotocol that was negotiated
---
.../src/main/kotlin/org/apache/tuweni/devp2p/eth/EthHandler.kt | 9 +++++++--
.../src/main/kotlin/org/apache/tuweni/devp2p/eth/EthHandler66.kt | 9 +++++++--
.../main/kotlin/org/apache/tuweni/devp2p/eth/EthHelloHandler.kt | 9 +++++++--
3 files changed, 21 insertions(+), 6 deletions(-)
diff --git
a/devp2p-eth/src/main/kotlin/org/apache/tuweni/devp2p/eth/EthHandler.kt
b/devp2p-eth/src/main/kotlin/org/apache/tuweni/devp2p/eth/EthHandler.kt
index d989fe7..9ea50bb 100644
--- a/devp2p-eth/src/main/kotlin/org/apache/tuweni/devp2p/eth/EthHandler.kt
+++ b/devp2p-eth/src/main/kotlin/org/apache/tuweni/devp2p/eth/EthHandler.kt
@@ -213,10 +213,15 @@ internal class EthHandler(
override fun handleNewPeerConnection(connection: WireConnection):
AsyncCompletion {
val newPeer = PeerInfo()
pendingStatus[connection.uri()] = newPeer
+ val ethSubProtocol = connection.agreedSubprotocols().firstOrNull() {
it.name() == EthSubprotocol.ETH65.name() }
+ if (ethSubProtocol == null) {
+ newPeer.cancel()
+ return newPeer.ready
+ }
service.send(
- EthSubprotocol.ETH64, MessageType.Status.code, connection,
+ ethSubProtocol, MessageType.Status.code, connection,
StatusMessage(
- EthSubprotocol.ETH65.version(),
+ ethSubProtocol.version(),
blockchainInfo.networkID(), blockchainInfo.totalDifficulty(),
blockchainInfo.bestHash(), blockchainInfo.genesisHash(),
blockchainInfo.getLatestForkHash(),
blockchainInfo.getLatestFork()
diff --git
a/devp2p-eth/src/main/kotlin/org/apache/tuweni/devp2p/eth/EthHandler66.kt
b/devp2p-eth/src/main/kotlin/org/apache/tuweni/devp2p/eth/EthHandler66.kt
index f340d7f..14280c2 100644
--- a/devp2p-eth/src/main/kotlin/org/apache/tuweni/devp2p/eth/EthHandler66.kt
+++ b/devp2p-eth/src/main/kotlin/org/apache/tuweni/devp2p/eth/EthHandler66.kt
@@ -245,13 +245,18 @@ internal class EthHandler66(
override fun handleNewPeerConnection(connection: WireConnection):
AsyncCompletion {
val newPeer = PeerInfo()
pendingStatus[connection.uri()] = newPeer
+ val ethSubProtocol = connection.agreedSubprotocols().firstOrNull() {
it.name() == EthSubprotocol.ETH65.name() }
+ if (ethSubProtocol == null) {
+ newPeer.cancel()
+ return newPeer.ready
+ }
service.send(
- EthSubprotocol.ETH66, MessageType.Status.code, connection,
+ ethSubProtocol, MessageType.Status.code, connection,
RLP.encodeList {
it.writeValue(UInt64.random().toBytes())
it.writeRLP(
StatusMessage(
- EthSubprotocol.ETH66.version(),
+ ethSubProtocol.version(),
blockchainInfo.networkID(), blockchainInfo.totalDifficulty(),
blockchainInfo.bestHash(), blockchainInfo.genesisHash(),
blockchainInfo.getLatestForkHash(),
blockchainInfo.getLatestFork()
diff --git
a/devp2p-eth/src/main/kotlin/org/apache/tuweni/devp2p/eth/EthHelloHandler.kt
b/devp2p-eth/src/main/kotlin/org/apache/tuweni/devp2p/eth/EthHelloHandler.kt
index 02b1e68..b3090e5 100644
--- a/devp2p-eth/src/main/kotlin/org/apache/tuweni/devp2p/eth/EthHelloHandler.kt
+++ b/devp2p-eth/src/main/kotlin/org/apache/tuweni/devp2p/eth/EthHelloHandler.kt
@@ -68,10 +68,15 @@ internal class EthHelloHandler(
override fun handleNewPeerConnection(connection: WireConnection):
AsyncCompletion {
val newPeer = PeerInfo()
pendingStatus[connection.uri()] = newPeer
+ val ethSubProtocol = connection.agreedSubprotocols().firstOrNull() {
it.name() == EthSubprotocol.ETH65.name() }
+ if (ethSubProtocol == null) {
+ newPeer.cancel()
+ return newPeer.ready
+ }
service.send(
- EthSubprotocol.ETH64, MessageType.Status.code, connection,
+ ethSubProtocol, MessageType.Status.code, connection,
StatusMessage(
- EthSubprotocol.ETH64.version(),
+ ethSubProtocol.version(),
blockchainInfo.networkID(), blockchainInfo.totalDifficulty(),
blockchainInfo.bestHash(), blockchainInfo.genesisHash(),
blockchainInfo.getLatestForkHash(),
blockchainInfo.getLatestFork()
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]