-
Notifications
You must be signed in to change notification settings - Fork 49
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
A0-4260: Only support full sync mode (#1688)
# Description We don't really support other sync modes than `Full` for our node anyway, so this changes the config and warns the user on startup. ## Type of change - Bug fix (non-breaking change which fixes an issue) - New feature (non-breaking change which adds functionality) # Checklist: - I have created new documentation
- Loading branch information
Showing
5 changed files
with
67 additions
and
7 deletions.
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
use crate::Cli; | ||
|
||
mod pruning; | ||
mod sync; | ||
|
||
use pruning::PruningConfigValidator; | ||
use sync::SyncConfigValidator; | ||
|
||
/// Validate and modify the configuration to make it conform to our assumptions. | ||
pub struct Validator { | ||
pruning: PruningConfigValidator, | ||
sync: SyncConfigValidator, | ||
} | ||
|
||
impl Validator { | ||
/// Modifies the settings. | ||
pub fn process(cli: &mut Cli) -> Self { | ||
Validator { | ||
pruning: PruningConfigValidator::process(cli), | ||
sync: SyncConfigValidator::process(cli), | ||
} | ||
} | ||
|
||
/// Warns the user about the modified settings. | ||
pub fn report(self) { | ||
let Validator { pruning, sync } = self; | ||
pruning.report(); | ||
sync.report(); | ||
} | ||
} |
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 |
---|---|---|
@@ -0,0 +1,31 @@ | ||
use log::warn; | ||
use sc_cli::arg_enums::SyncMode; | ||
|
||
use crate::Cli; | ||
|
||
/// Modifies the sync config to ensure only full sync is used. | ||
pub struct SyncConfigValidator { | ||
overwritten: Option<SyncMode>, | ||
} | ||
|
||
impl SyncConfigValidator { | ||
/// Modifies the settings. | ||
pub fn process(cli: &mut Cli) -> Self { | ||
let overwritten = match cli.run.network_params.sync { | ||
SyncMode::Full => None, | ||
mode => Some(mode), | ||
}; | ||
cli.run.network_params.sync = SyncMode::Full; | ||
SyncConfigValidator { overwritten } | ||
} | ||
|
||
/// Warns the user if they attempted to use a sync setting other than full. | ||
pub fn report(self) { | ||
if let Some(mode) = self.overwritten { | ||
warn!( | ||
"Only full sync mode is supported, ignoring request for {:?} mode.", | ||
mode | ||
); | ||
} | ||
} | ||
} |
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