@@ -436,19 +436,13 @@ pub struct PruneConfig {
436436pub struct DecodingContext < ' a , PT : PubKey > {
437437 validator_set : Option < & ' a ValidatorSet < PT > > ,
438438 unix_ts_now : UnixTimestamp ,
439- current_epoch : Epoch ,
440439}
441440
442441impl < ' a , PT : PubKey > DecodingContext < ' a , PT > {
443- pub fn new (
444- validator_set : Option < & ' a ValidatorSet < PT > > ,
445- unix_ts_now : UnixTimestamp ,
446- current_epoch : Epoch ,
447- ) -> Self {
442+ pub fn new ( validator_set : Option < & ' a ValidatorSet < PT > > , unix_ts_now : UnixTimestamp ) -> Self {
448443 Self {
449444 validator_set,
450445 unix_ts_now,
451- current_epoch,
452446 }
453447 }
454448}
@@ -806,15 +800,11 @@ impl<PT: PubKey> AuthorIndex<PT> {
806800 . prune_config
807801 . max_unix_ts_ms_delta
808802 . and_then ( |delta| context. unix_ts_now . checked_sub ( delta) ) ;
809- let epoch_threshold: Option < Epoch > = self
810- . prune_config
811- . max_epoch_delta
812- . and_then ( |delta| context. current_epoch . checked_sub ( delta) ) ;
813803
814804 let mut evicted_keys = PrunedKeys :: empty ( ) ;
815805
816806 // we first try only pruning expired keys
817- let expired_keys = author_index. prune_expired ( unix_ts_threshold, epoch_threshold ) ;
807+ let expired_keys = author_index. prune_expired ( unix_ts_threshold) ;
818808 evicted_keys. extend ( expired_keys) ;
819809
820810 // if still over quota, compact the cache to fit under quota
@@ -847,18 +837,14 @@ impl<PT: PubKey> AuthorIndex<PT> {
847837 . prune_config
848838 . max_unix_ts_ms_delta
849839 . and_then ( |delta| context. unix_ts_now . checked_sub ( delta) ) ;
850- let epoch_threshold: Option < Epoch > = self
851- . prune_config
852- . max_epoch_delta
853- . and_then ( |delta| context. current_epoch . checked_sub ( delta) ) ;
854840
855841 let mut authors_to_drop = vec ! [ ] ;
856842 let mut total_slots = 0 ;
857843
858844 let mut pruned_keys = PrunedKeys :: empty ( ) ;
859845 for ( author, author_index) in & mut self . per_author_index {
860846 total_slots += author_index. len ( ) ;
861- pruned_keys. extend ( author_index. prune_expired ( unix_ts_threshold, epoch_threshold ) ) ;
847+ pruned_keys. extend ( author_index. prune_expired ( unix_ts_threshold) ) ;
862848
863849 if author_index. is_empty ( ) {
864850 authors_to_drop. push ( * author) ;
@@ -1053,11 +1039,7 @@ impl PerAuthorIndex {
10531039 }
10541040
10551041 // Remove expired entries.
1056- pub fn prune_expired (
1057- & mut self ,
1058- unix_ts_threshold : Option < UnixTimestamp > ,
1059- epoch_threshold : Option < Epoch > ,
1060- ) -> PrunedKeys {
1042+ pub fn prune_expired ( & mut self , unix_ts_threshold : Option < UnixTimestamp > ) -> PrunedKeys {
10611043 let mut evicted_keys = PrunedKeys :: empty ( ) ;
10621044 // first, we prune all expired keys
10631045 if let Some ( threshold) = unix_ts_threshold {
@@ -1551,7 +1533,7 @@ mod test {
15511533 use rand:: seq:: SliceRandom as _;
15521534
15531535 use super :: * ;
1554- use crate :: util:: BroadcastMode ;
1536+ use crate :: { udp :: GroupId , util:: BroadcastMode } ;
15551537 type PT = monad_crypto:: NopPubKey ;
15561538
15571539 const EPOCH : Epoch = Epoch ( 1 ) ;
@@ -1620,7 +1602,7 @@ mod test {
16201602 // these fields are never touched in this module
16211603 recipient_hash : HexBytes ( [ 0 ; 20 ] ) ,
16221604 message : Bytes :: new ( ) ,
1623- group_id : EPOCH . 0 ,
1605+ group_id : GroupId :: Primary ( EPOCH ) ,
16241606 unix_ts_ms,
16251607 } ;
16261608 messages. push ( message) ;
@@ -1633,7 +1615,7 @@ mod test {
16331615 let app_message = Bytes :: from ( vec ! [ 1u8 ; APP_MESSAGE_LEN ] ) ;
16341616 let author = node_id ( 0 ) ;
16351617 let symbols = make_symbols ( & app_message, author, UNIX_TS_MS ) ;
1636- let context = DecodingContext :: new ( None , UNIX_TS_MS , EPOCH ) ;
1618+ let context = DecodingContext :: new ( None , UNIX_TS_MS ) ;
16371619
16381620 for n in 0 ..MIN_DECODABLE_SYMBOLS {
16391621 let mut cache = make_cache ( 10 , 10 , 10 ) ;
@@ -1710,7 +1692,7 @@ mod test {
17101692 // single slot per tier is enough
17111693 let mut cache = make_cache ( 1 , 1 , 1 ) ;
17121694
1713- let context = DecodingContext :: new ( Some ( & validator_set) , UNIX_TS_MS , EPOCH ) ;
1695+ let context = DecodingContext :: new ( Some ( & validator_set) , UNIX_TS_MS ) ;
17141696 let res = try_decode_all ( & mut cache, & context, all_symbols. iter ( ) )
17151697 . expect ( "Decoding should succeed" ) ;
17161698
@@ -1723,7 +1705,7 @@ mod test {
17231705 let app_message = Bytes :: from ( vec ! [ 1u8 ; APP_MESSAGE_LEN ] ) ;
17241706 let author = node_id ( 0 ) ;
17251707 let symbols = make_symbols ( & app_message, author, UNIX_TS_MS ) ;
1726- let context = DecodingContext :: new ( None , UNIX_TS_MS , EPOCH ) ;
1708+ let context = DecodingContext :: new ( None , UNIX_TS_MS ) ;
17271709 let mut cache = make_cache ( 10 , 10 , 10 ) ;
17281710
17291711 // Decode a message completely.
@@ -1746,7 +1728,7 @@ mod test {
17461728 let app_message = Bytes :: from ( vec ! [ 1u8 ; APP_MESSAGE_LEN ] ) ;
17471729 let author = node_id ( 0 ) ;
17481730 let symbols = make_symbols ( & app_message, author, old_ts) ;
1749- let context = DecodingContext :: new ( None , old_ts, EPOCH ) ;
1731+ let context = DecodingContext :: new ( None , old_ts) ;
17501732
17511733 // Insert an old message.
17521734 let _ = cache. try_decode ( & symbols[ 0 ] , & context) ;
@@ -1757,7 +1739,7 @@ mod test {
17571739 let new_app_message = Bytes :: from ( vec ! [ 2u8 ; APP_MESSAGE_LEN ] ) ;
17581740 let new_author = node_id ( i) ;
17591741 let new_symbols = make_symbols ( & new_app_message, new_author, UNIX_TS_MS ) ;
1760- let new_context = DecodingContext :: new ( None , UNIX_TS_MS , EPOCH ) ;
1742+ let new_context = DecodingContext :: new ( None , UNIX_TS_MS ) ;
17611743 let _ = cache. try_decode ( & new_symbols[ 0 ] , & new_context) ;
17621744 assert ! ( cache. consistency_breaches( ) . is_empty( ) ) ;
17631745 }
@@ -1801,7 +1783,7 @@ mod test {
18011783 config. validator_tier . min_slots_per_validator = Some ( 2 ) ;
18021784
18031785 let mut cache = DecoderCache :: new ( config) ;
1804- let context = DecodingContext :: new ( Some ( & validator_set) , UNIX_TS_MS , EPOCH ) ;
1786+ let context = DecodingContext :: new ( Some ( & validator_set) , UNIX_TS_MS ) ;
18051787 let res = try_decode_all ( & mut cache, & context, all_symbols_part_1. iter ( ) )
18061788 . expect ( "Decoding should succeed" ) ;
18071789 assert ! ( cache. consistency_breaches( ) . is_empty( ) ) ;
@@ -1883,7 +1865,7 @@ mod test {
18831865 }
18841866
18851867 let mut cache = DecoderCache :: new ( config) ;
1886- let context = DecodingContext :: new ( Some ( & validator_set) , UNIX_TS_MS , EPOCH ) ;
1868+ let context = DecodingContext :: new ( Some ( & validator_set) , UNIX_TS_MS ) ;
18871869 let res = try_decode_all ( & mut cache, & context, all_symbols_part_1. iter ( ) )
18881870 . expect ( "Decoding should succeed" ) ;
18891871 assert ! ( cache. consistency_breaches( ) . is_empty( ) ) ;
@@ -1930,7 +1912,7 @@ mod test {
19301912 config. p2p_tier . min_slots_per_author = 2 ; // each author gets at least 2 slots
19311913
19321914 let mut cache = DecoderCache :: new ( config) ;
1933- let context = DecodingContext :: new ( None , UNIX_TS_MS , EPOCH ) ;
1915+ let context = DecodingContext :: new ( None , UNIX_TS_MS ) ;
19341916 let res = try_decode_all ( & mut cache, & context, all_symbols_part_1. iter ( ) )
19351917 . expect ( "Decoding should succeed" ) ;
19361918 assert ! ( cache. consistency_breaches( ) . is_empty( ) ) ;
@@ -1996,7 +1978,7 @@ mod test {
19961978 }
19971979
19981980 let mut cache = DecoderCache :: new ( config) ;
1999- let context = DecodingContext :: new ( None , UNIX_TS_MS , EPOCH ) ;
1981+ let context = DecodingContext :: new ( None , UNIX_TS_MS ) ;
20001982 let res = try_decode_all ( & mut cache, & context, all_symbols_part_1. iter ( ) )
20011983 . expect ( "Decoding should succeed" ) ;
20021984 assert ! ( cache. consistency_breaches( ) . is_empty( ) ) ;
@@ -2022,7 +2004,7 @@ mod test {
20222004 let app_message = Bytes :: from ( vec ! [ 1u8 ; APP_MESSAGE_LEN ] ) ;
20232005 let author = node_id ( 0 ) ;
20242006 let symbols = make_symbols ( & app_message, author, UNIX_TS_MS ) ;
2025- let context = DecodingContext :: new ( None , UNIX_TS_MS , EPOCH ) ;
2007+ let context = DecodingContext :: new ( None , UNIX_TS_MS ) ;
20262008
20272009 // Insert a valid symbol first.
20282010 let _ = cache. try_decode ( & symbols[ 0 ] , & context) ;
@@ -2056,7 +2038,7 @@ mod test {
20562038 config. p2p_tier . min_slots_per_author = 2 ;
20572039
20582040 let mut cache = DecoderCache :: new ( config) ;
2059- let context = DecodingContext :: new ( None , UNIX_TS_MS , EPOCH ) ;
2041+ let context = DecodingContext :: new ( None , UNIX_TS_MS ) ;
20602042
20612043 // Fill the cache.
20622044 let app_message0 = Bytes :: from ( vec ! [ 0u8 ; APP_MESSAGE_LEN ] ) ;
@@ -2095,7 +2077,7 @@ mod test {
20952077 config. p2p_tier . min_slots_per_author = 5 ;
20962078
20972079 let mut cache = DecoderCache :: new ( config) ;
2098- let context = DecodingContext :: new ( None , UNIX_TS_MS , EPOCH ) ;
2080+ let context = DecodingContext :: new ( None , UNIX_TS_MS ) ;
20992081
21002082 // take a single symbol for a given message
21012083 let partial_symbol = |msg : u8 , ts : UnixTimestamp | {
0 commit comments