Skip to content

Commit 6466458

Browse files
committed
init commit of set_block_both_have2
1 parent f092d0e commit 6466458

2 files changed

Lines changed: 9 additions & 1 deletion

File tree

framework/src/main/java/org/tron/core/net/messagehandler/BlockMsgHandler.java

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -151,6 +151,13 @@ private void processBlock(PeerConnection peer, BlockCapsule block) throws P2pExc
151151
try {
152152
tronNetDelegate.processBlock(block, false);
153153
witnessProductBlockService.validWitnessProductTwoBlock(block);
154+
155+
Item item = new Item(blockId, InventoryType.BLOCK);
156+
tronNetDelegate.getActivePeer().forEach(p -> {
157+
if (p.getAdvInvReceive().getIfPresent(item) != null) {
158+
p.setBlockBothHave(blockId);
159+
}
160+
});
154161
} catch (Exception e) {
155162
logger.warn("Process adv block {} from peer {} failed. reason: {}",
156163
blockId, peer.getInetAddress(), e.getMessage());

framework/src/main/java/org/tron/core/net/peer/PeerConnection.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -225,7 +225,8 @@ public String log() {
225225
channel.getInetSocketAddress(),
226226
(now - channel.getStartTime()) / Constant.ONE_THOUSAND,
227227
channel.getAvgLatency(),
228-
fastForwardBlock != null ? fastForwardBlock.getNum() : blockBothHave.getNum(),
228+
fastForwardBlock != null ? fastForwardBlock.getNum() : String.format("%d [%ds]",
229+
blockBothHave.getNum(), (System.currentTimeMillis() - blockBothHaveUpdateTime) / 1000),
229230
isNeedSyncFromPeer(),
230231
isNeedSyncFromUs(),
231232
syncBlockToFetch.size(),

0 commit comments

Comments
 (0)