Skip to content

Commit 4c670f9

Browse files
authored
Merge pull request #5831 from zeusoo001/f-sove-access-problem-fetch
fix(net): solve the problem of concurrent access to fetchBlockInfo object
2 parents 76df76c + 089fa8a commit 4c670f9

File tree

1 file changed

+3
-2
lines changed

1 file changed

+3
-2
lines changed

framework/src/main/java/org/tron/core/net/service/fetchblock/FetchBlockService.java

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -71,9 +71,10 @@ public void fetchBlock(List<Sha256Hash> sha256HashList, PeerConnection peer) {
7171
sha256HashList.stream().filter(sha256Hash -> new BlockCapsule.BlockId(sha256Hash).getNum()
7272
== chainBaseManager.getHeadBlockNum() + 1)
7373
.findFirst().ifPresent(sha256Hash -> {
74-
fetchBlockInfo = new FetchBlockInfo(sha256Hash, peer, System.currentTimeMillis());
74+
long now = System.currentTimeMillis();
75+
fetchBlockInfo = new FetchBlockInfo(sha256Hash, peer, now);
7576
logger.info("Set fetchBlockInfo, block: {}, peer: {}, time: {}", sha256Hash,
76-
fetchBlockInfo.getPeer().getInetAddress(), fetchBlockInfo.getTime());
77+
peer.getInetAddress(), now);
7778
});
7879
}
7980

0 commit comments

Comments
 (0)