1111import org .tron .consensus .pbft .PbftManager ;
1212import org .tron .consensus .pbft .message .PbftBaseMessage ;
1313import org .tron .consensus .pbft .message .PbftMessage ;
14+ import org .tron .core .config .args .Args ;
1415import org .tron .core .exception .P2pException ;
16+ import org .tron .core .net .TronNetDelegate ;
1517import org .tron .core .net .TronNetService ;
1618import org .tron .core .net .peer .PeerConnection ;
19+ import org .tron .protos .Protocol .PBFTMessage .DataType ;
1720
1821@ Component
1922public class PbftMsgHandler {
@@ -26,10 +29,24 @@ public class PbftMsgHandler {
2629 @ Autowired
2730 private PbftManager pbftManager ;
2831
32+ @ Autowired
33+ private TronNetDelegate tronNetDelegate ;
34+
2935 public void processMessage (PeerConnection peer , PbftMessage msg ) throws Exception {
3036 if (Param .getInstance ().getPbftInterface ().isSyncing ()) {
3137 return ;
3238 }
39+ if (msg .getDataType ().equals (DataType .BLOCK )
40+ && tronNetDelegate .getHeadBlockId ().getNum () - msg .getNumber ()
41+ > Args .getInstance ().getPBFTExpireNum ()) {
42+ return ;
43+ }
44+ long currentEpoch = tronNetDelegate .getNextMaintenanceTime ();
45+ long expireEpoch = 2 * tronNetDelegate .getMaintenanceTimeInterval ();
46+ if (msg .getDataType ().equals (DataType .SRL )
47+ && currentEpoch - msg .getEpoch () > expireEpoch ) {
48+ return ;
49+ }
3350 msg .analyzeSignature ();
3451 String key = buildKey (msg );
3552 Lock lock = striped .get (key );
0 commit comments