File tree Expand file tree Collapse file tree
framework/src/main/java/org/tron/core/net Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -293,6 +293,14 @@ public static boolean needToLog(Message msg) {
293293 return true ;
294294 }
295295
296+ public synchronized boolean checkAndPutAdvInvRequest (Item key , Long value ) {
297+ if (advInvRequest .containsKey (key )) {
298+ return false ;
299+ }
300+ advInvRequest .put (key , value );
301+ return true ;
302+ }
303+
296304 @ Override
297305 public boolean equals (Object o ) {
298306 if (!(o instanceof PeerConnection )) {
Original file line number Diff line number Diff line change @@ -281,8 +281,9 @@ private void consumerInvToFetch() {
281281 && invSender .getSize (peer ) < MAX_TRX_FETCH_PER_PEER )
282282 .sorted (Comparator .comparingInt (peer -> invSender .getSize (peer )))
283283 .findFirst ().ifPresent (peer -> {
284- invSender .add (item , peer );
285- peer .getAdvInvRequest ().put (item , now );
284+ if (peer .checkAndPutAdvInvRequest (item , now )) {
285+ invSender .add (item , peer );
286+ }
286287 invToFetch .remove (item );
287288 });
288289 });
Original file line number Diff line number Diff line change @@ -117,8 +117,8 @@ private void fetchBlockProcess(FetchBlockInfo fetchBlock) {
117117
118118 if (optionalPeerConnection .isPresent ()) {
119119 optionalPeerConnection .ifPresent (firstPeer -> {
120- if (shouldFetchBlock (firstPeer , fetchBlock )) {
121- firstPeer .getAdvInvRequest (). put ( item , System .currentTimeMillis ());
120+ if (shouldFetchBlock (firstPeer , fetchBlock )
121+ && firstPeer .checkAndPutAdvInvRequest ( item , System .currentTimeMillis ())) {
122122 firstPeer .sendMessage (new FetchInvDataMessage (Collections .singletonList (item .getHash ()),
123123 item .getType ()));
124124 this .fetchBlockInfo = null ;
You can’t perform that action at this time.
0 commit comments