Skip to content

Commit

Permalink
Remove ContinueWithTimeout in authority aggregation
Browse files Browse the repository at this point in the history
  • Loading branch information
bingyanglin committed Jan 19, 2025
1 parent 46ed3db commit 440dfa3
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 18 deletions.
12 changes: 2 additions & 10 deletions crates/iota-authority-aggregation/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@ pub type AsyncResult<'a, T, E> = BoxFuture<'a, Result<T, E>>;

pub enum ReduceOutput<R, S> {
Continue(S),
ContinueWithTimeout(S, Duration),
Failed(S),
Success(R),
}
Expand Down Expand Up @@ -69,7 +68,7 @@ where
})
.collect();

let mut current_timeout = initial_timeout;
let current_timeout = initial_timeout;
let mut accumulated_state = initial_state;
// Then, as results become available fold them into the state using FReduce.
while let Ok(Some((authority_name, result))) = timeout(current_timeout, responses.next()).await
Expand All @@ -79,11 +78,6 @@ where
match reduce_result(accumulated_state, authority_name, authority_weight, result).await {
// In the first two cases we are told to continue the iteration.
ReduceOutput::Continue(state) => state,
ReduceOutput::ContinueWithTimeout(state, duration) => {
// Adjust the waiting timeout.
current_timeout = duration;
state
}
ReduceOutput::Failed(state) => {
return Err(state);
}
Expand All @@ -110,9 +104,7 @@ where
/// FReduce returns a result to a ReduceOutput. If the result is Err the
/// function shortcuts and the Err is returned. An Ok ReduceOutput result can be
/// used to shortcut and return the resulting state (ReduceOutput::End),
/// continue the folding as new states arrive (ReduceOutput::Continue),
/// or continue with a timeout maximum waiting time
/// (ReduceOutput::ContinueWithTimeout).
/// continue the folding as new states arrive (ReduceOutput::Continue).
///
/// This function provides a flexible way to communicate with a quorum of
/// authorities, processing and processing their results into a safe overall
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -515,14 +515,7 @@ mod move_tests {
|mut accumulated_state, authority_name, _authority_weight, _result| {
Box::pin(async move {
accumulated_state.insert(authority_name);
if accumulated_state.len() <= 3 {
ReduceOutput::Continue(accumulated_state)
} else {
ReduceOutput::ContinueWithTimeout(
accumulated_state,
Duration::from_millis(10),
)
}
ReduceOutput::Continue(accumulated_state)
})
},
// large delay
Expand Down

0 comments on commit 440dfa3

Please sign in to comment.