Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -78,11 +78,9 @@ public void processDisconnect(Channel channel, ReasonCode reason){
return;
}
switch (reason){
case FORKED:
case BAD_PROTOCOL:
case BAD_BLOCK:
case INCOMPATIBLE_CHAIN:
case INCOMPATIBLE_PROTOCOL:
case BAD_TX:
badPeers.put(channel.getInetAddress(), reason);
break;
default:
Expand Down
2 changes: 1 addition & 1 deletion src/main/java/org/tron/core/config/args/Args.java
Original file line number Diff line number Diff line change
Expand Up @@ -716,7 +716,7 @@ private static void logConfig(){
logger.info("Discover enable: {}", args.isNodeDiscoveryEnable());
logger.info("Active node size: {}", args.getActiveNodes().size());
logger.info("Passive node size: {}", args.getPassiveNodes().size());
logger.info("Seed node size: {}", args.getSeedNodes().size());
logger.info("Seed node size: {}", args.getSeedNode().getIpList().size());
logger.info("Max connection: {}", args.getNodeMaxActiveNodes());
logger.info("Max connection with same IP: {}", args.getNodeMaxActiveNodesWithSameIp());
logger.info("************************ Backup config ************************");
Expand Down
30 changes: 10 additions & 20 deletions src/main/java/org/tron/core/net/node/NodeImpl.java
Original file line number Diff line number Diff line change
Expand Up @@ -249,8 +249,6 @@ public Thread newThread(Runnable r) {
}
});

private HashMap<Sha256Hash, Long> badAdvObj = new HashMap<>(); //TODO:need auto erase oldest obj

//blocks we requested but not received

private Cache<BlockId, Long> syncBlockIdWeRequested = CacheBuilder.newBuilder()
Expand Down Expand Up @@ -619,17 +617,15 @@ private synchronized void logNodeStatus() {
+ "unSyncNum: %d\n"
+ "blockWaitToProc: %d\n"
+ "blockJustReceived: %d\n"
+ "syncBlockIdWeRequested: %d\n"
+ "badAdvObj: %d\n",
+ "syncBlockIdWeRequested: %d\n",
del.getHeadBlockId().getNum(),
advObjToSpread.size(),
advObjToFetch.size(),
advObjWeRequested.size(),
getUnSyncNum(),
blockWaitToProc.size(),
blockJustReceived.size(),
syncBlockIdWeRequested.size(),
badAdvObj.size()
syncBlockIdWeRequested.size()
));

logger.info(sb.toString());
Expand Down Expand Up @@ -706,17 +702,15 @@ private void onHandleInventoryMessage(PeerConnection peer, InventoryMessage msg)

peer.getAdvObjSpreadToUs().put(id, System.currentTimeMillis());
if (!requested[0]) {
if (!badAdvObj.containsKey(id)) {
PriorItem targetPriorItem = this.advObjToFetch.get(id);
PriorItem targetPriorItem = this.advObjToFetch.get(id);

if (targetPriorItem != null) {
//another peer tell this trx to us, refresh its time.
targetPriorItem.refreshTime();
} else {
fetchWaterLine.increase();
this.advObjToFetch.put(id, new PriorItem(new Item(id, msg.getInventoryType()),
fetchSequenceCounter.incrementAndGet()));
}
if (targetPriorItem != null) {
//another peer tell this trx to us, refresh its time.
targetPriorItem.refreshTime();
} else {
fetchWaterLine.increase();
this.advObjToFetch.put(id, new PriorItem(new Item(id, msg.getInventoryType()),
fetchSequenceCounter.incrementAndGet()));
}
}
}
Expand Down Expand Up @@ -798,7 +792,6 @@ private void processAdvBlock(PeerConnection peer, BlockCapsule block) {
} catch (BadBlockException e) {
logger.error("We get a bad block {}, from {}, reason is {} ",
block.getBlockId().getString(), peer.getNode().getHost(), e.getMessage());
badAdvObj.put(block.getBlockId(), System.currentTimeMillis());
disconnectPeer(peer, ReasonCode.BAD_BLOCK);
} catch (UnLinkedBlockException e) {
logger.error("We get a unlinked block {}, from {}, head is {}",
Expand All @@ -808,7 +801,6 @@ private void processAdvBlock(PeerConnection peer, BlockCapsule block) {
} catch (NonCommonBlockException e) {
logger.error("We get a block {} that do not have the most recent common ancestor with the main chain, from {}, reason is {} ",
block.getBlockId().getString(), peer.getNode().getHost(), e.getMessage());
badAdvObj.put(block.getBlockId(), System.currentTimeMillis());
disconnectPeer(peer, ReasonCode.FORKED);
} catch (InterruptedException e) {
Thread.currentThread().interrupt();
Expand All @@ -835,7 +827,6 @@ private boolean processSyncBlock(BlockCapsule block) {
} catch (BadBlockException e) {
logger.error("We get a bad block {}, reason is {} ", block.getBlockId().getString(),
e.getMessage());
badAdvObj.put(block.getBlockId(), System.currentTimeMillis());
reason = ReasonCode.BAD_BLOCK;
} catch (UnLinkedBlockException e) {
logger.error("We get a unlinked block {}, head is {}", block.getBlockId().getString(),
Expand Down Expand Up @@ -901,7 +892,6 @@ private void onHandleTransactionMessage(PeerConnection peer, TransactionMessage
logger.error(e.getMessage());
banTraitorPeer(peer, ReasonCode.BAD_PROTOCOL);
} catch (BadTransactionException e) {
badAdvObj.put(trxMsg.getMessageId(), System.currentTimeMillis());
banTraitorPeer(peer, ReasonCode.BAD_TX);
}
}
Expand Down