Babe epoch newtype (#1596)

Removal of verbatim duplication of BABE's `Epoch` struct in the client.

I think is better to have one single definition and wrap the primitive
`Epoch` in a newtype (required because we need to implement the `Epoch`
trait).
This commit is contained in:
Davide Galassi
2023-09-17 22:06:19 +02:00
committed by GitHub
parent d787269cdf
commit c7dbfc21b6
6 changed files with 45 additions and 51 deletions
@@ -62,10 +62,11 @@ impl EpochT for EpochV0 {
}
}
// Implement From<EpochV0> for Epoch
impl EpochV0 {
/// Migrate the sturct to current epoch version.
pub fn migrate(self, config: &BabeConfiguration) -> Epoch {
Epoch {
sp_consensus_babe::Epoch {
epoch_index: self.epoch_index,
start_slot: self.start_slot,
duration: self.duration,
@@ -73,5 +74,6 @@ impl EpochV0 {
randomness: self.randomness,
config: BabeEpochConfiguration { c: config.c, allowed_slots: config.allowed_slots },
}
.into()
}
}