From 089fa8a76a8dac38413318b2efe31770933649c0 Mon Sep 17 00:00:00 2001 From: zeusoo001 Date: Sun, 28 Apr 2024 16:59:27 +0800 Subject: [PATCH] fix(net): solve the problem of concurrent access to fetchBlockInfo object --- .../tron/core/net/service/fetchblock/FetchBlockService.java | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/framework/src/main/java/org/tron/core/net/service/fetchblock/FetchBlockService.java b/framework/src/main/java/org/tron/core/net/service/fetchblock/FetchBlockService.java index 889f6f6e13..bda2646abb 100644 --- a/framework/src/main/java/org/tron/core/net/service/fetchblock/FetchBlockService.java +++ b/framework/src/main/java/org/tron/core/net/service/fetchblock/FetchBlockService.java @@ -71,9 +71,10 @@ public void fetchBlock(List sha256HashList, PeerConnection peer) { sha256HashList.stream().filter(sha256Hash -> new BlockCapsule.BlockId(sha256Hash).getNum() == chainBaseManager.getHeadBlockNum() + 1) .findFirst().ifPresent(sha256Hash -> { - fetchBlockInfo = new FetchBlockInfo(sha256Hash, peer, System.currentTimeMillis()); + long now = System.currentTimeMillis(); + fetchBlockInfo = new FetchBlockInfo(sha256Hash, peer, now); logger.info("Set fetchBlockInfo, block: {}, peer: {}, time: {}", sha256Hash, - fetchBlockInfo.getPeer().getInetAddress(), fetchBlockInfo.getTime()); + peer.getInetAddress(), now); }); }