Skip to content

Commit

Permalink
move fatal check into snapshot request handler
Browse files Browse the repository at this point in the history
  • Loading branch information
brooksprumo committed Aug 31, 2021
1 parent 2bda2ae commit e8c1aad
Showing 1 changed file with 4 additions and 6 deletions.
10 changes: 4 additions & 6 deletions runtime/src/accounts_background_service.rs
Original file line number Diff line number Diff line change
Expand Up @@ -212,7 +212,7 @@ impl SnapshotRequestHandler {
e,
);

if e.is_fatal() {
if Self::is_snapshot_error_fatal(&e) {
return Err(e);
}
}
Expand Down Expand Up @@ -246,18 +246,16 @@ impl SnapshotRequestHandler {
Ok(snapshot_root_bank.block_height())
})
}
}

impl SnapshotError {
/// Check if a SnapshotError should be treated as 'fatal' by AccountsBackgroundService, and
/// Check if a SnapshotError should be treated as 'fatal' by SnapshotRequestHandler, and
/// `handle_snapshot_requests()` in particular. Fatal errors will cause the node to shutdown.
/// Non-fatal errors are logged and then swallowed.
///
/// All `SnapshotError`s are enumerated, and there is **NO** default case. This way, if
/// a new error is added to SnapshotError, a conscious decision must be made on how it should
/// be handled.
fn is_fatal(&self) -> bool {
match self {
fn is_snapshot_error_fatal(err: &SnapshotError) -> bool {
match err {
SnapshotError::Io(..) => true,
SnapshotError::Serialize(..) => true,
SnapshotError::ArchiveGenerationFailure(..) => true,
Expand Down

0 comments on commit e8c1aad

Please sign in to comment.