@@ -131,9 +131,10 @@ impl Clone for RedisNode {
131131/// identify the true block producer of any given block. This is done by iterating over each epochs
132132/// and finding the highest epoch with a quorum of blocks produced.
133133pub struct RedisLeaderLeaseAdapter {
134+ /// list of all redis nodes to connect to
134135 redis_nodes : Vec < RedisNode > ,
136+ /// number of nodes for which a lock needs to be held to consider the producer legitimate
135137 quorum : usize ,
136- quorum_disruption_budget : u32 ,
137138 lease_key : String ,
138139 epoch_key : String ,
139140 block_stream_key : String ,
@@ -154,7 +155,6 @@ impl Clone for RedisLeaderLeaseAdapter {
154155 Self {
155156 redis_nodes : self . redis_nodes . clone ( ) ,
156157 quorum : self . quorum ,
157- quorum_disruption_budget : self . quorum_disruption_budget ,
158158 lease_key : self . lease_key . clone ( ) ,
159159 epoch_key : self . epoch_key . clone ( ) ,
160160 block_stream_key : self . block_stream_key . clone ( ) ,
@@ -200,6 +200,7 @@ impl RedisLeaderLeaseAdapter {
200200 pub fn new (
201201 redis_urls : Vec < String > ,
202202 lease_key : String ,
203+ quorum_disruption_budget : u32 ,
203204 lease_ttl : Duration ,
204205 node_timeout : Duration ,
205206 retry_delay : Duration ,
@@ -221,7 +222,6 @@ impl RedisLeaderLeaseAdapter {
221222 "At least one redis url is required for leader lock"
222223 ) ) ;
223224 }
224- let quorum_disruption_budget = 0u32 ;
225225 let quorum = Self :: calculate_quorum ( redis_nodes. len ( ) , quorum_disruption_budget) ;
226226 let lease_ttl_millis = u64:: try_from ( lease_ttl. as_millis ( ) ) ?;
227227 let retry_delay_millis = u64:: try_from ( retry_delay. as_millis ( ) ) ?;
@@ -238,7 +238,6 @@ impl RedisLeaderLeaseAdapter {
238238 Ok ( Self {
239239 redis_nodes,
240240 quorum,
241- quorum_disruption_budget,
242241 lease_key,
243242 epoch_key,
244243 block_stream_key,
@@ -255,16 +254,6 @@ impl RedisLeaderLeaseAdapter {
255254 } )
256255 }
257256
258- pub fn with_quorum_disruption_budget (
259- mut self ,
260- quorum_disruption_budget : u32 ,
261- ) -> Self {
262- self . quorum_disruption_budget = quorum_disruption_budget;
263- self . quorum =
264- Self :: calculate_quorum ( self . redis_nodes . len ( ) , quorum_disruption_budget) ;
265- self
266- }
267-
268257 async fn multiplexed_connection (
269258 & self ,
270259 redis_node : & RedisNode ,
@@ -1431,6 +1420,7 @@ mod tests {
14311420 let adapter = RedisLeaderLeaseAdapter :: new (
14321421 vec ! [ redis. redis_url( ) ] ,
14331422 lease_key,
1423+ 0 ,
14341424 Duration :: from_secs ( 2 ) ,
14351425 Duration :: from_millis ( 100 ) ,
14361426 Duration :: from_millis ( 50 ) ,
@@ -1485,6 +1475,7 @@ mod tests {
14851475 let adapter = RedisLeaderLeaseAdapter :: new (
14861476 vec ! [ redis. redis_url( ) ] ,
14871477 lease_key,
1478+ 0 ,
14881479 Duration :: from_secs ( 2 ) ,
14891480 Duration :: from_millis ( 100 ) ,
14901481 Duration :: from_millis ( 50 ) ,
@@ -1727,6 +1718,7 @@ mod tests {
17271718 redis_c. redis_url( ) ,
17281719 ] ,
17291720 lease_key,
1721+ 0 ,
17301722 Duration :: from_secs ( 2 ) ,
17311723 Duration :: from_millis ( 100 ) ,
17321724 Duration :: from_millis ( 50 ) ,
@@ -1884,6 +1876,7 @@ mod tests {
18841876 let adapter = RedisLeaderLeaseAdapter :: new (
18851877 redis_urls. clone ( ) ,
18861878 lease_key. clone ( ) ,
1879+ 0 ,
18871880 Duration :: from_millis ( 500 ) ,
18881881 Duration :: from_millis ( 100 ) ,
18891882 Duration :: from_millis ( 50 ) ,
@@ -1932,6 +1925,7 @@ mod tests {
19321925 let first_adapter = RedisLeaderLeaseAdapter :: new (
19331926 redis_urls. clone ( ) ,
19341927 lease_key. clone ( ) ,
1928+ 0 ,
19351929 Duration :: from_millis ( 300 ) ,
19361930 Duration :: from_millis ( 100 ) ,
19371931 Duration :: from_millis ( 50 ) ,
@@ -1943,6 +1937,7 @@ mod tests {
19431937 let second_adapter = RedisLeaderLeaseAdapter :: new (
19441938 redis_urls. clone ( ) ,
19451939 lease_key. clone ( ) ,
1940+ 0 ,
19461941 Duration :: from_millis ( 300 ) ,
19471942 Duration :: from_millis ( 100 ) ,
19481943 Duration :: from_millis ( 50 ) ,
@@ -2102,6 +2097,7 @@ mod tests {
21022097 let adapter = RedisLeaderLeaseAdapter :: new (
21032098 redis_urls. clone ( ) ,
21042099 lease_key. clone ( ) ,
2100+ 0 ,
21052101 Duration :: from_millis ( 700 ) ,
21062102 Duration :: from_millis ( 100 ) ,
21072103 Duration :: from_millis ( 50 ) ,
@@ -2205,6 +2201,7 @@ mod tests {
22052201 let adapter = RedisLeaderLeaseAdapter :: new (
22062202 vec ! [ redis. redis_url( ) ] ,
22072203 lease_key,
2204+ 0 ,
22082205 Duration :: from_secs ( 2 ) ,
22092206 Duration :: from_millis ( 100 ) ,
22102207 Duration :: from_millis ( 50 ) ,
@@ -2245,6 +2242,7 @@ mod tests {
22452242 let adapter = RedisLeaderLeaseAdapter :: new (
22462243 vec ! [ redis. redis_url( ) ] ,
22472244 lease_key,
2245+ 0 ,
22482246 Duration :: from_secs ( 2 ) ,
22492247 Duration :: from_millis ( 100 ) ,
22502248 Duration :: from_millis ( 50 ) ,
@@ -2306,6 +2304,7 @@ mod tests {
23062304 let adapter = RedisLeaderLeaseAdapter :: new (
23072305 vec ! [ redis. redis_url( ) ] ,
23082306 lease_key,
2307+ 0 ,
23092308 Duration :: from_secs ( 2 ) ,
23102309 Duration :: from_millis ( 100 ) ,
23112310 Duration :: from_millis ( 50 ) ,
@@ -2573,6 +2572,7 @@ mod tests {
25732572 RedisLeaderLeaseAdapter :: new (
25742573 redis_urls,
25752574 lease_key,
2575+ 0 ,
25762576 Duration :: from_secs ( 2 ) ,
25772577 Duration :: from_millis ( 100 ) ,
25782578 Duration :: from_millis ( 50 ) ,
0 commit comments