|
|
|
@ -23,7 +23,7 @@ import org.hyperledger.besu.ethereum.core.Block; |
|
|
|
|
import org.hyperledger.besu.ethereum.core.Difficulty; |
|
|
|
|
import org.hyperledger.besu.ethereum.eth.EthProtocol; |
|
|
|
|
import org.hyperledger.besu.ethereum.eth.EthProtocolConfiguration; |
|
|
|
|
import org.hyperledger.besu.ethereum.eth.manager.peertask.PeerManager; |
|
|
|
|
import org.hyperledger.besu.ethereum.eth.manager.peertask.PeerSelector; |
|
|
|
|
import org.hyperledger.besu.ethereum.eth.messages.EthPV62; |
|
|
|
|
import org.hyperledger.besu.ethereum.eth.messages.StatusMessage; |
|
|
|
|
import org.hyperledger.besu.ethereum.eth.peervalidation.PeerValidator; |
|
|
|
@ -70,7 +70,7 @@ public class EthProtocolManager implements ProtocolManager, MinedBlockObserver { |
|
|
|
|
|
|
|
|
|
private final Hash genesisHash; |
|
|
|
|
private final ForkIdManager forkIdManager; |
|
|
|
|
private final PeerManager peerManager; |
|
|
|
|
private final PeerSelector peerSelector; |
|
|
|
|
private final BigInteger networkId; |
|
|
|
|
private final EthPeers ethPeers; |
|
|
|
|
private final EthMessages ethMessages; |
|
|
|
@ -95,7 +95,7 @@ public class EthProtocolManager implements ProtocolManager, MinedBlockObserver { |
|
|
|
|
final SynchronizerConfiguration synchronizerConfiguration, |
|
|
|
|
final EthScheduler scheduler, |
|
|
|
|
final ForkIdManager forkIdManager, |
|
|
|
|
final PeerManager peerManager) { |
|
|
|
|
final PeerSelector peerSelector) { |
|
|
|
|
this.networkId = networkId; |
|
|
|
|
this.peerValidators = peerValidators; |
|
|
|
|
this.scheduler = scheduler; |
|
|
|
@ -105,7 +105,7 @@ public class EthProtocolManager implements ProtocolManager, MinedBlockObserver { |
|
|
|
|
this.genesisHash = blockchain.getBlockHashByNumber(0L).orElse(Hash.ZERO); |
|
|
|
|
|
|
|
|
|
this.forkIdManager = forkIdManager; |
|
|
|
|
this.peerManager = peerManager; |
|
|
|
|
this.peerSelector = peerSelector; |
|
|
|
|
|
|
|
|
|
this.ethPeers = ethPeers; |
|
|
|
|
this.ethMessages = ethMessages; |
|
|
|
@ -145,7 +145,7 @@ public class EthProtocolManager implements ProtocolManager, MinedBlockObserver { |
|
|
|
|
final Optional<MergePeerFilter> mergePeerFilter, |
|
|
|
|
final SynchronizerConfiguration synchronizerConfiguration, |
|
|
|
|
final EthScheduler scheduler, |
|
|
|
|
final PeerManager peerManager) { |
|
|
|
|
final PeerSelector peerSelector) { |
|
|
|
|
this( |
|
|
|
|
blockchain, |
|
|
|
|
networkId, |
|
|
|
@ -164,7 +164,7 @@ public class EthProtocolManager implements ProtocolManager, MinedBlockObserver { |
|
|
|
|
Collections.emptyList(), |
|
|
|
|
Collections.emptyList(), |
|
|
|
|
ethereumWireProtocolConfiguration.isLegacyEth64ForkIdEnabled()), |
|
|
|
|
peerManager); |
|
|
|
|
peerSelector); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
public EthContext ethContext() { |
|
|
|
@ -343,7 +343,7 @@ public class EthProtocolManager implements ProtocolManager, MinedBlockObserver { |
|
|
|
|
public void handleNewConnection(final PeerConnection connection) { |
|
|
|
|
ethPeers.registerNewConnection(connection, peerValidators); |
|
|
|
|
final EthPeer peer = ethPeers.peer(connection); |
|
|
|
|
peerManager.addPeer(peer); |
|
|
|
|
peerSelector.addPeer(peer); |
|
|
|
|
final Capability cap = connection.capability(getSupportedProtocol()); |
|
|
|
|
final ForkId latestForkId = |
|
|
|
|
cap.getVersion() >= 64 ? forkIdManager.getForkIdForChainHead() : null; |
|
|
|
@ -375,7 +375,7 @@ public class EthProtocolManager implements ProtocolManager, MinedBlockObserver { |
|
|
|
|
final DisconnectReason reason, |
|
|
|
|
final boolean initiatedByPeer) { |
|
|
|
|
final boolean wasActiveConnection = ethPeers.registerDisconnect(connection); |
|
|
|
|
peerManager.removePeer(connection.getPeer()); |
|
|
|
|
peerSelector.removePeer(connection.getPeer()); |
|
|
|
|
LOG.atDebug() |
|
|
|
|
.setMessage("Disconnect - active Connection? {} - {} - {} - {} {} - {} peers left") |
|
|
|
|
.addArgument(wasActiveConnection) |
|
|
|
|