Skip to content

Commit 284b761

Browse files
authored
Merge pull request #5262 from 317787106/hotfix/block_chain_failed
fix(net): fix the fail generating SyncBlockChain issue
2 parents 54015a0 + 7fe685f commit 284b761

File tree

3 files changed

+9
-1
lines changed

3 files changed

+9
-1
lines changed

chainbase/src/main/java/org/tron/core/ChainBaseManager.java

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -362,6 +362,9 @@ public boolean containBlockInMainChain(BlockId blockId) {
362362
}
363363
}
364364

365+
public BlockCapsule getKhaosDbHead(){
366+
return this.khaosDb.getHead();
367+
}
365368

366369
/**
367370
* Get a BlockCapsule by id.

framework/src/main/java/org/tron/core/net/TronNetDelegate.java

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -146,6 +146,10 @@ public BlockId getHeadBlockId() {
146146
return chainBaseManager.getHeadBlockId();
147147
}
148148

149+
public BlockId getKhaosDbHeadBlockId() {
150+
return chainBaseManager.getKhaosDbHead().getBlockId();
151+
}
152+
149153
public BlockId getSolidBlockId() {
150154
return chainBaseManager.getSolidBlockId();
151155
}

framework/src/main/java/org/tron/core/net/service/sync/SyncService.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -169,7 +169,8 @@ private LinkedList<BlockId> getBlockChainSummary(PeerConnection peer) throws P2p
169169
if (beginBlockId.getNum() == 0) {
170170
highNoFork = high = tronNetDelegate.getHeadBlockId().getNum();
171171
} else {
172-
if (tronNetDelegate.containBlockInMainChain(beginBlockId)) {
172+
if (tronNetDelegate.getKhaosDbHeadBlockId().equals(beginBlockId)
173+
|| tronNetDelegate.containBlockInMainChain(beginBlockId)) {
173174
highNoFork = high = beginBlockId.getNum();
174175
} else {
175176
forkList = tronNetDelegate.getBlockChainHashesOnFork(beginBlockId);

0 commit comments

Comments
 (0)