|
|
@ -15,6 +15,7 @@ package tech.pegasys.pantheon.ethereum.p2p.netty; |
|
|
|
import static com.google.common.base.Preconditions.checkState; |
|
|
|
import static com.google.common.base.Preconditions.checkState; |
|
|
|
|
|
|
|
|
|
|
|
import tech.pegasys.pantheon.crypto.SECP256K1; |
|
|
|
import tech.pegasys.pantheon.crypto.SECP256K1; |
|
|
|
|
|
|
|
import tech.pegasys.pantheon.crypto.SECP256K1.KeyPair; |
|
|
|
import tech.pegasys.pantheon.ethereum.chain.BlockAddedEvent; |
|
|
|
import tech.pegasys.pantheon.ethereum.chain.BlockAddedEvent; |
|
|
|
import tech.pegasys.pantheon.ethereum.chain.Blockchain; |
|
|
|
import tech.pegasys.pantheon.ethereum.chain.Blockchain; |
|
|
|
import tech.pegasys.pantheon.ethereum.p2p.PeerNotPermittedException; |
|
|
|
import tech.pegasys.pantheon.ethereum.p2p.PeerNotPermittedException; |
|
|
@ -28,7 +29,6 @@ import tech.pegasys.pantheon.ethereum.p2p.discovery.PeerDiscoveryAgent; |
|
|
|
import tech.pegasys.pantheon.ethereum.p2p.discovery.PeerDiscoveryEvent.PeerBondedEvent; |
|
|
|
import tech.pegasys.pantheon.ethereum.p2p.discovery.PeerDiscoveryEvent.PeerBondedEvent; |
|
|
|
import tech.pegasys.pantheon.ethereum.p2p.discovery.PeerDiscoveryEvent.PeerDroppedEvent; |
|
|
|
import tech.pegasys.pantheon.ethereum.p2p.discovery.PeerDiscoveryEvent.PeerDroppedEvent; |
|
|
|
import tech.pegasys.pantheon.ethereum.p2p.discovery.VertxPeerDiscoveryAgent; |
|
|
|
import tech.pegasys.pantheon.ethereum.p2p.discovery.VertxPeerDiscoveryAgent; |
|
|
|
import tech.pegasys.pantheon.ethereum.p2p.discovery.internal.PeerRequirement; |
|
|
|
|
|
|
|
import tech.pegasys.pantheon.ethereum.p2p.peers.Endpoint; |
|
|
|
import tech.pegasys.pantheon.ethereum.p2p.peers.Endpoint; |
|
|
|
import tech.pegasys.pantheon.ethereum.p2p.peers.Peer; |
|
|
|
import tech.pegasys.pantheon.ethereum.p2p.peers.Peer; |
|
|
|
import tech.pegasys.pantheon.ethereum.p2p.peers.PeerBlacklist; |
|
|
|
import tech.pegasys.pantheon.ethereum.p2p.peers.PeerBlacklist; |
|
|
@ -173,10 +173,9 @@ public class NettyP2PNetwork implements P2PNetwork { |
|
|
|
|
|
|
|
|
|
|
|
public NettyP2PNetwork( |
|
|
|
public NettyP2PNetwork( |
|
|
|
final Vertx vertx, |
|
|
|
final Vertx vertx, |
|
|
|
final SECP256K1.KeyPair keyPair, |
|
|
|
final KeyPair keyPair, |
|
|
|
final NetworkingConfiguration config, |
|
|
|
final NetworkingConfiguration config, |
|
|
|
final List<Capability> supportedCapabilities, |
|
|
|
final List<Capability> supportedCapabilities, |
|
|
|
final PeerRequirement peerRequirement, |
|
|
|
|
|
|
|
final PeerBlacklist peerBlacklist, |
|
|
|
final PeerBlacklist peerBlacklist, |
|
|
|
final MetricsSystem metricsSystem, |
|
|
|
final MetricsSystem metricsSystem, |
|
|
|
final Optional<NodeLocalConfigPermissioningController> nodeWhitelistController, |
|
|
|
final Optional<NodeLocalConfigPermissioningController> nodeWhitelistController, |
|
|
@ -186,7 +185,6 @@ public class NettyP2PNetwork implements P2PNetwork { |
|
|
|
keyPair, |
|
|
|
keyPair, |
|
|
|
config, |
|
|
|
config, |
|
|
|
supportedCapabilities, |
|
|
|
supportedCapabilities, |
|
|
|
peerRequirement, |
|
|
|
|
|
|
|
peerBlacklist, |
|
|
|
peerBlacklist, |
|
|
|
metricsSystem, |
|
|
|
metricsSystem, |
|
|
|
nodeWhitelistController, |
|
|
|
nodeWhitelistController, |
|
|
@ -206,7 +204,6 @@ public class NettyP2PNetwork implements P2PNetwork { |
|
|
|
* @param config The network configuration to use. |
|
|
|
* @param config The network configuration to use. |
|
|
|
* @param supportedCapabilities The wire protocol capabilities to advertise to connected peers. |
|
|
|
* @param supportedCapabilities The wire protocol capabilities to advertise to connected peers. |
|
|
|
* @param peerBlacklist The peers with which this node will not connect |
|
|
|
* @param peerBlacklist The peers with which this node will not connect |
|
|
|
* @param peerRequirement Queried to determine if enough peers are currently connected. |
|
|
|
|
|
|
|
* @param metricsSystem The metrics system to capture metrics with. |
|
|
|
* @param metricsSystem The metrics system to capture metrics with. |
|
|
|
* @param nodeLocalConfigPermissioningController local file config for permissioning |
|
|
|
* @param nodeLocalConfigPermissioningController local file config for permissioning |
|
|
|
* @param nodePermissioningController Controls node permissioning. |
|
|
|
* @param nodePermissioningController Controls node permissioning. |
|
|
@ -217,13 +214,13 @@ public class NettyP2PNetwork implements P2PNetwork { |
|
|
|
final SECP256K1.KeyPair keyPair, |
|
|
|
final SECP256K1.KeyPair keyPair, |
|
|
|
final NetworkingConfiguration config, |
|
|
|
final NetworkingConfiguration config, |
|
|
|
final List<Capability> supportedCapabilities, |
|
|
|
final List<Capability> supportedCapabilities, |
|
|
|
final PeerRequirement peerRequirement, |
|
|
|
|
|
|
|
final PeerBlacklist peerBlacklist, |
|
|
|
final PeerBlacklist peerBlacklist, |
|
|
|
final MetricsSystem metricsSystem, |
|
|
|
final MetricsSystem metricsSystem, |
|
|
|
final Optional<NodeLocalConfigPermissioningController> nodeLocalConfigPermissioningController, |
|
|
|
final Optional<NodeLocalConfigPermissioningController> nodeLocalConfigPermissioningController, |
|
|
|
final Optional<NodePermissioningController> nodePermissioningController, |
|
|
|
final Optional<NodePermissioningController> nodePermissioningController, |
|
|
|
final Blockchain blockchain) { |
|
|
|
final Blockchain blockchain) { |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
maxPeers = config.getRlpx().getMaxPeers(); |
|
|
|
connections = new PeerConnectionRegistry(metricsSystem); |
|
|
|
connections = new PeerConnectionRegistry(metricsSystem); |
|
|
|
this.peerBlacklist = peerBlacklist; |
|
|
|
this.peerBlacklist = peerBlacklist; |
|
|
|
this.peerMaintainConnectionList = new HashSet<>(); |
|
|
|
this.peerMaintainConnectionList = new HashSet<>(); |
|
|
@ -232,7 +229,7 @@ public class NettyP2PNetwork implements P2PNetwork { |
|
|
|
vertx, |
|
|
|
vertx, |
|
|
|
keyPair, |
|
|
|
keyPair, |
|
|
|
config.getDiscovery(), |
|
|
|
config.getDiscovery(), |
|
|
|
peerRequirement, |
|
|
|
() -> connections.size() >= maxPeers, |
|
|
|
peerBlacklist, |
|
|
|
peerBlacklist, |
|
|
|
nodeLocalConfigPermissioningController, |
|
|
|
nodeLocalConfigPermissioningController, |
|
|
|
nodePermissioningController); |
|
|
|
nodePermissioningController); |
|
|
@ -262,7 +259,6 @@ public class NettyP2PNetwork implements P2PNetwork { |
|
|
|
subscribeDisconnect(peerBlacklist); |
|
|
|
subscribeDisconnect(peerBlacklist); |
|
|
|
subscribeDisconnect(connections); |
|
|
|
subscribeDisconnect(connections); |
|
|
|
|
|
|
|
|
|
|
|
maxPeers = config.getRlpx().getMaxPeers(); |
|
|
|
|
|
|
|
this.keyPair = keyPair; |
|
|
|
this.keyPair = keyPair; |
|
|
|
this.subProtocols = config.getSupportedProtocols(); |
|
|
|
this.subProtocols = config.getSupportedProtocols(); |
|
|
|
|
|
|
|
|
|
|
|