Skip to content

Commit cb3df71

Browse files
committed
fix(net):optimize getBlockIdByNum in SyncService
1 parent c14d42e commit cb3df71

File tree

1 file changed

+7
-6
lines changed

1 file changed

+7
-6
lines changed

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

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -209,12 +209,13 @@ private LinkedList<BlockId> getBlockChainSummary(PeerConnection peer) throws P2p
209209
}
210210

211211
private BlockId getBlockIdByNum(long num) throws P2pException {
212-
BlockId head1 = tronNetDelegate.getKhaosDbHeadBlockId();
213-
BlockId head2 = tronNetDelegate.getHeadBlockId();
214-
if (num == head1.getNum()) {
215-
return head1;
216-
} else if (num == head2.getNum()) {
217-
return head2;
212+
BlockId head = tronNetDelegate.getKhaosDbHeadBlockId();
213+
if (num == head.getNum()) {
214+
return head;
215+
}
216+
head = tronNetDelegate.getHeadBlockId();
217+
if (num == head.getNum()) {
218+
return head;
218219
}
219220
return tronNetDelegate.getBlockIdByNum(num);
220221
}

0 commit comments

Comments
 (0)