@@ -117,7 +117,7 @@ public void syncNext(PeerConnection peer) {
117117 peer .setSyncChainRequested (new Pair <>(chainSummary , System .currentTimeMillis ()));
118118 peer .sendMessage (new SyncBlockChainMessage (chainSummary ));
119119 } catch (Exception e ) {
120- logger .warn ("Peer {} sync failed, reason: {}" , peer .getInetAddress (), e . getMessage () );
120+ logger .error ("Peer {} sync failed, reason: {}" , peer .getInetAddress (), e );
121121 peer .disconnect (ReasonCode .SYNC_FAIL );
122122 }
123123 }
@@ -191,7 +191,7 @@ private LinkedList<BlockId> getBlockChainSummary(PeerConnection peer) throws P2p
191191
192192 while (low <= realHigh ) {
193193 if (low <= highNoFork ) {
194- summary .offer (tronNetDelegate . getBlockIdByNum (low ));
194+ summary .offer (getBlockIdByNum (low ));
195195 } else if (low <= high ) {
196196 summary .offer (forkList .get ((int ) (low - highNoFork - 1 )));
197197 } else {
@@ -203,6 +203,14 @@ private LinkedList<BlockId> getBlockChainSummary(PeerConnection peer) throws P2p
203203 return summary ;
204204 }
205205
206+ private BlockId getBlockIdByNum (long num ) throws P2pException {
207+ BlockId head = tronNetDelegate .getHeadBlockId ();
208+ if (num == head .getNum ()) {
209+ return head ;
210+ }
211+ return tronNetDelegate .getBlockIdByNum (num );
212+ }
213+
206214 private void startFetchSyncBlock () {
207215 HashMap <PeerConnection , List <BlockId >> send = new HashMap <>();
208216 tronNetDelegate .getActivePeer ().stream ()
0 commit comments