@@ -249,8 +249,6 @@ public Thread newThread(Runnable r) {
249249 }
250250 });
251251
252- private HashMap <Sha256Hash , Long > badAdvObj = new HashMap <>(); //TODO:need auto erase oldest obj
253-
254252 //blocks we requested but not received
255253
256254 private Cache <BlockId , Long > syncBlockIdWeRequested = CacheBuilder .newBuilder ()
@@ -619,17 +617,15 @@ private synchronized void logNodeStatus() {
619617 + "unSyncNum: %d\n "
620618 + "blockWaitToProc: %d\n "
621619 + "blockJustReceived: %d\n "
622- + "syncBlockIdWeRequested: %d\n "
623- + "badAdvObj: %d\n " ,
620+ + "syncBlockIdWeRequested: %d\n " ,
624621 del .getHeadBlockId ().getNum (),
625622 advObjToSpread .size (),
626623 advObjToFetch .size (),
627624 advObjWeRequested .size (),
628625 getUnSyncNum (),
629626 blockWaitToProc .size (),
630627 blockJustReceived .size (),
631- syncBlockIdWeRequested .size (),
632- badAdvObj .size ()
628+ syncBlockIdWeRequested .size ()
633629 ));
634630
635631 logger .info (sb .toString ());
@@ -706,17 +702,15 @@ private void onHandleInventoryMessage(PeerConnection peer, InventoryMessage msg)
706702
707703 peer .getAdvObjSpreadToUs ().put (id , System .currentTimeMillis ());
708704 if (!requested [0 ]) {
709- if (!badAdvObj .containsKey (id )) {
710- PriorItem targetPriorItem = this .advObjToFetch .get (id );
705+ PriorItem targetPriorItem = this .advObjToFetch .get (id );
711706
712- if (targetPriorItem != null ) {
713- //another peer tell this trx to us, refresh its time.
714- targetPriorItem .refreshTime ();
715- } else {
716- fetchWaterLine .increase ();
717- this .advObjToFetch .put (id , new PriorItem (new Item (id , msg .getInventoryType ()),
718- fetchSequenceCounter .incrementAndGet ()));
719- }
707+ if (targetPriorItem != null ) {
708+ //another peer tell this trx to us, refresh its time.
709+ targetPriorItem .refreshTime ();
710+ } else {
711+ fetchWaterLine .increase ();
712+ this .advObjToFetch .put (id , new PriorItem (new Item (id , msg .getInventoryType ()),
713+ fetchSequenceCounter .incrementAndGet ()));
720714 }
721715 }
722716 }
@@ -798,7 +792,6 @@ private void processAdvBlock(PeerConnection peer, BlockCapsule block) {
798792 } catch (BadBlockException e ) {
799793 logger .error ("We get a bad block {}, from {}, reason is {} " ,
800794 block .getBlockId ().getString (), peer .getNode ().getHost (), e .getMessage ());
801- badAdvObj .put (block .getBlockId (), System .currentTimeMillis ());
802795 disconnectPeer (peer , ReasonCode .BAD_BLOCK );
803796 } catch (UnLinkedBlockException e ) {
804797 logger .error ("We get a unlinked block {}, from {}, head is {}" ,
@@ -808,7 +801,6 @@ private void processAdvBlock(PeerConnection peer, BlockCapsule block) {
808801 } catch (NonCommonBlockException e ) {
809802 logger .error ("We get a block {} that do not have the most recent common ancestor with the main chain, from {}, reason is {} " ,
810803 block .getBlockId ().getString (), peer .getNode ().getHost (), e .getMessage ());
811- badAdvObj .put (block .getBlockId (), System .currentTimeMillis ());
812804 disconnectPeer (peer , ReasonCode .FORKED );
813805 } catch (InterruptedException e ) {
814806 Thread .currentThread ().interrupt ();
@@ -835,7 +827,6 @@ private boolean processSyncBlock(BlockCapsule block) {
835827 } catch (BadBlockException e ) {
836828 logger .error ("We get a bad block {}, reason is {} " , block .getBlockId ().getString (),
837829 e .getMessage ());
838- badAdvObj .put (block .getBlockId (), System .currentTimeMillis ());
839830 reason = ReasonCode .BAD_BLOCK ;
840831 } catch (UnLinkedBlockException e ) {
841832 logger .error ("We get a unlinked block {}, head is {}" , block .getBlockId ().getString (),
@@ -901,7 +892,6 @@ private void onHandleTransactionMessage(PeerConnection peer, TransactionMessage
901892 logger .error (e .getMessage ());
902893 banTraitorPeer (peer , ReasonCode .BAD_PROTOCOL );
903894 } catch (BadTransactionException e ) {
904- badAdvObj .put (trxMsg .getMessageId (), System .currentTimeMillis ());
905895 banTraitorPeer (peer , ReasonCode .BAD_TX );
906896 }
907897 }
0 commit comments