-
Notifications
You must be signed in to change notification settings - Fork 2.8k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Replace task run()
return result with custom enum
#2429
Open
MitchTurner
wants to merge
20
commits into
master
Choose a base branch
from
chore/introduce-task-result-enum
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
20 commits
Select commit
Hold shift + click to select a range
f0ac16d
WIP: Replace result with custom enum
MitchTurner 48d752b
Finish converting
MitchTurner 0e8720a
Update CHANGELOG
MitchTurner d1c5a2a
Fix spelling--unrelated to branch purpose
MitchTurner 894d8de
Remove redundant returns
MitchTurner 81e1a90
Update crates/services/p2p/src/service.rs
MitchTurner b091adf
Revert file back to master
MitchTurner 3b3b9cd
Merge branch 'master' into chore/introduce-task-result-enum
MitchTurner 4648b49
Fix new compilation errors from master merge
MitchTurner 78c2940
Add helper to v0 code
MitchTurner 81c9d22
Cleanup noisy code
MitchTurner 8495bc9
Remove `should_continue` method
MitchTurner 268bd1c
Merge branch 'master' into chore/introduce-task-result-enum
MitchTurner 3538282
Cover missing error case, reformat expression
MitchTurner f8e9649
Rename function and type
MitchTurner 63b45b3
Add missed rename
MitchTurner 747030c
Merge branch 'master' into chore/introduce-task-result-enum
MitchTurner cea56f7
Merge branch 'master' into chore/introduce-task-result-enum
xgreenx 9481e5c
Merge branch 'master' into chore/introduce-task-result-enum
MitchTurner 948dfb8
Make minor touch-ups
MitchTurner File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -11,6 +11,7 @@ use fuel_core_services::{ | |
RunnableService, | ||
RunnableTask, | ||
StateWatcher, | ||
TaskNextAction, | ||
}; | ||
use fuel_core_types::{ | ||
blockchain::header::BlockHeader, | ||
|
@@ -137,10 +138,7 @@ impl RunnableService for SyncTask { | |
|
||
#[async_trait::async_trait] | ||
impl RunnableTask for SyncTask { | ||
#[tracing::instrument(level = "debug", skip_all, err, ret)] | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Had to remove this from a couple locations since the |
||
async fn run(&mut self, watcher: &mut StateWatcher) -> anyhow::Result<bool> { | ||
let mut should_continue = true; | ||
|
||
async fn run(&mut self, watcher: &mut StateWatcher) -> TaskNextAction { | ||
let tick: BoxFuture<tokio::time::Instant> = if let Some(timer) = &mut self.timer { | ||
Box::pin(timer.tick()) | ||
} else { | ||
|
@@ -150,7 +148,7 @@ impl RunnableTask for SyncTask { | |
tokio::select! { | ||
biased; | ||
_ = watcher.while_started() => { | ||
should_continue = false; | ||
TaskNextAction::Stop | ||
} | ||
Some(latest_peer_count) = self.peer_connections_stream.next() => { | ||
let sufficient_peers = latest_peer_count >= self.min_connected_reserved_peers; | ||
|
@@ -172,6 +170,7 @@ impl RunnableTask for SyncTask { | |
} | ||
_ => {}, | ||
} | ||
TaskNextAction::Continue | ||
} | ||
Some(block_info) = self.block_stream.next() => { | ||
let new_block_height = block_info.block_header.height(); | ||
|
@@ -205,6 +204,7 @@ impl RunnableTask for SyncTask { | |
} | ||
_ => {} | ||
} | ||
TaskNextAction::Continue | ||
} | ||
_ = tick => { | ||
if let InnerSyncState::SufficientPeers(block_header) = &self.inner_state { | ||
|
@@ -215,10 +215,9 @@ impl RunnableTask for SyncTask { | |
}; | ||
self.update_sync_state(SyncState::Synced(Arc::new(block_header))); | ||
} | ||
TaskNextAction::Continue | ||
} | ||
} | ||
|
||
Ok(should_continue) | ||
} | ||
|
||
async fn shutdown(self) -> anyhow::Result<()> { | ||
|
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This change introduces a non-trivial amount of noise with the removal of the
?
operators.AFAICT, there isn't a way to implement
Try
for arbitrary types in Rust which is a real bummer.