Skip to content

Commit

Permalink
fix(worker): fix sealing Event::Setate
Browse files Browse the repository at this point in the history
  • Loading branch information
0x5459 committed Aug 4, 2023
1 parent 63c494b commit cae991a
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 8 deletions.
12 changes: 8 additions & 4 deletions damocles-worker/src/sealing/sealing_thread/planner/common.rs
Original file line number Diff line number Diff line change
Expand Up @@ -187,7 +187,7 @@ where
let prev = self.job.sector.state;

if let Some(evt) = event {
match evt {
match &evt {
Event::Idle | Event::Retry => {
tracing::debug!(
prev = ?self.job.sector.state,
Expand All @@ -200,9 +200,13 @@ where
.wait_or_interrupted(self.job.sealing_ctrl.config().recover_interval)?;
}

_ => {
let state = self.planner.plan(&evt, &self.job.sector.state).crit()?;
self.planner.apply(evt, state, &mut self.job).context("event apply").crit()?;
other => {
let next = if let Event::SetState(s) = other {
*s
} else {
self.planner.plan(other, &self.job.sector.state).crit()?
};
self.planner.apply(evt, next, &mut self.job).context("event apply").crit()?;
self.job.sector.sync().context("sync sector").crit()?;
}
};
Expand Down
13 changes: 9 additions & 4 deletions damocles-worker/src/sealing/sealing_thread/planner/wdpost.rs
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,7 @@ impl Sealer for WdPostSealer {
}

if let Some(evt) = event.take() {
match evt {
match &evt {
WdPostEvent::Idle | WdPostEvent::Retry => {
let recover_interval = self.job.sealing_ctrl.config().recover_interval;
tracing::debug!(
Expand All @@ -120,9 +120,14 @@ impl Sealer for WdPostSealer {
self.job.sealing_ctrl.wait_or_interrupted(recover_interval)?;
}

_ => {
let state = self.planner.plan(&evt, &self.job.state).crit()?;
self.planner.apply(evt, state, &mut self.job).context("event apply").crit()?;
other => {
let next = if let WdPostEvent::SetState(s) = other {
*s
} else {
self.planner.plan(other, &self.job.state).crit()?
};

self.planner.apply(evt, next, &mut self.job).context("event apply").crit()?;
}
};
};
Expand Down

0 comments on commit cae991a

Please sign in to comment.