Skip to content

Commit

Permalink
Simplify the flow of execution of light-base/sync/relay (#1383)
Browse files Browse the repository at this point in the history
* Inline `process_foreground_messages`

* No longer have this weird `response_outcome`variable

* Inline `inject_network_event`

* Integrate the network state update within the WakeUpReason

* Inline the request results match block

* Inline `start_next_request`

* Get the desired request ahead of time to fix compilation

* Add TODO
  • Loading branch information
tomaka committed Nov 22, 2023
1 parent 5569728 commit 798e6b2
Show file tree
Hide file tree
Showing 2 changed files with 620 additions and 597 deletions.
2 changes: 2 additions & 0 deletions lib/src/sync/all.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1878,13 +1878,15 @@ pub enum DesiredRequest {

impl DesiredRequest {
/// Caps the number of blocks to request to `max`.
// TODO: consider removing due to the many types of requests
pub fn num_blocks_clamp(&mut self, max: NonZeroU64) {
if let DesiredRequest::BlocksRequest { num_blocks, .. } = self {
*num_blocks = NonZeroU64::new(cmp::min(num_blocks.get(), max.get())).unwrap();
}
}

/// Caps the number of blocks to request to `max`.
// TODO: consider removing due to the many types of requests
pub fn with_num_blocks_clamp(mut self, max: NonZeroU64) -> Self {
self.num_blocks_clamp(max);
self
Expand Down
Loading

0 comments on commit 798e6b2

Please sign in to comment.