Skip to content

Commit

Permalink
feat(worker): make hot config file optional
Browse files Browse the repository at this point in the history
  • Loading branch information
0x5459 committed May 6, 2023
1 parent 64f0598 commit 828757b
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 2 deletions.
14 changes: 13 additions & 1 deletion venus-worker/src/sealing/config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,20 @@ pub struct Config {
}

impl Config {
pub(crate) fn new(config: Sealing, plan: Option<String>, hot_config_path: impl Into<PathBuf>) -> Result<Self> {
pub(crate) fn new(config: Sealing, plan: Option<String>, hot_config_path: Option<impl Into<PathBuf>>) -> Result<Self> {
let default_config = SealingWithPlan { plan, sealing: config };

let hot_config_path = match hot_config_path {
Some(hot_config_path) => hot_config_path.into(),
None => {
// If hot_config_path is Option::None (for example, wdpost planner does not require hot config file),
// it means there is no hot config file.
// We point the hot config file to a non-existent file or a meaningless file (such as "/tmp/xxx")
// to avoid loading the hot config file
PathBuf::from("/tmp/non-existent-file")
}
};

let hot_config = HotConfig::new(default_config, merge_config, hot_config_path).context("new HotConfig")?;
let config = hot_config.config();
tracing::info!(config = ?config, "sealing thread config");
Expand Down
2 changes: 1 addition & 1 deletion venus-worker/src/sealing/sealing_thread/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ impl SealingThread {

Ok((
Self {
config: Config::new(sealing_config, plan, location.hot_config_path())?,
config: Config::new(sealing_config, plan, Some(location.hot_config_path()))?,
store,
ctrl_ctx,
idx,
Expand Down

0 comments on commit 828757b

Please sign in to comment.