Skip to content

Commit c14d42e

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

File tree

1 file changed

+6
-5
lines changed

1 file changed

+6
-5
lines changed

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

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

211211
private BlockId getBlockIdByNum(long num) throws P2pException {
212-
BlockId head = tronNetDelegate.getHeadBlockId();
213-
if (num > head.getNum()) {
214-
return tronNetDelegate.getKhaosDbHeadBlockId();
215-
} else if (num == head.getNum()) {
216-
return head;
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;
217218
}
218219
return tronNetDelegate.getBlockIdByNum(num);
219220
}

0 commit comments

Comments
 (0)