|
|
|
@ -71,8 +71,6 @@ public class EthProtocolManager implements ProtocolManager, MinedBlockObserver { |
|
|
|
|
private final Blockchain blockchain; |
|
|
|
|
private final BlockBroadcaster blockBroadcaster; |
|
|
|
|
private final List<PeerValidator> peerValidators; |
|
|
|
|
// The max size of messages (in bytes)
|
|
|
|
|
private final int maxMessageSize; |
|
|
|
|
private final Optional<MergePeerFilter> mergePeerFilter; |
|
|
|
|
|
|
|
|
|
public EthProtocolManager( |
|
|
|
@ -93,7 +91,6 @@ public class EthProtocolManager implements ProtocolManager, MinedBlockObserver { |
|
|
|
|
this.peerValidators = peerValidators; |
|
|
|
|
this.scheduler = scheduler; |
|
|
|
|
this.blockchain = blockchain; |
|
|
|
|
this.maxMessageSize = ethereumWireProtocolConfiguration.getMaxMessageSize(); |
|
|
|
|
this.mergePeerFilter = mergePeerFilter; |
|
|
|
|
this.shutdown = new CountDownLatch(1); |
|
|
|
|
this.genesisHash = blockchain.getBlockHashByNumber(0L).orElse(Hash.ZERO); |
|
|
|
@ -250,17 +247,6 @@ public class EthProtocolManager implements ProtocolManager, MinedBlockObserver { |
|
|
|
|
return; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
if (messageData.getSize() > maxMessageSize) { |
|
|
|
|
LOG.warn( |
|
|
|
|
"Received message (code: {}) exceeding size limit of {} bytes: {} bytes. Disconnecting from {}", |
|
|
|
|
Integer.toString(code, 16), |
|
|
|
|
maxMessageSize, |
|
|
|
|
messageData.getSize(), |
|
|
|
|
ethPeer); |
|
|
|
|
ethPeer.disconnect(DisconnectReason.SUBPROTOCOL_TRIGGERED); |
|
|
|
|
return; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
// Handle STATUS processing
|
|
|
|
|
if (code == EthPV62.STATUS) { |
|
|
|
|
handleStatusMessage(ethPeer, messageData); |
|
|
|
@ -391,7 +377,7 @@ public class EthProtocolManager implements ProtocolManager, MinedBlockObserver { |
|
|
|
|
status.genesisHash()); |
|
|
|
|
peer.disconnect(DisconnectReason.SUBPROTOCOL_TRIGGERED); |
|
|
|
|
} else if (mergePeerFilter.isPresent()) { |
|
|
|
|
boolean disconnected = mergePeerFilter.get().disconnectIfPoW(status, peer); |
|
|
|
|
final boolean disconnected = mergePeerFilter.get().disconnectIfPoW(status, peer); |
|
|
|
|
if (disconnected) { |
|
|
|
|
handleDisconnect(peer.getConnection(), DisconnectReason.SUBPROTOCOL_TRIGGERED, false); |
|
|
|
|
} |
|
|
|
@ -422,7 +408,7 @@ public class EthProtocolManager implements ProtocolManager, MinedBlockObserver { |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
public List<Bytes> getForkIdAsBytesList() { |
|
|
|
|
ForkId chainHeadForkId = forkIdManager.getForkIdForChainHead(); |
|
|
|
|
final ForkId chainHeadForkId = forkIdManager.getForkIdForChainHead(); |
|
|
|
|
return chainHeadForkId == null |
|
|
|
|
? Collections.emptyList() |
|
|
|
|
: chainHeadForkId.getForkIdAsBytesList(); |
|
|
|
|