Skip to content
This repository has been archived by the owner on Nov 15, 2023. It is now read-only.

Commit

Permalink
address some more grumbles
Browse files Browse the repository at this point in the history
  • Loading branch information
rphmeier committed Jun 1, 2020
1 parent 2a079cc commit 4adc554
Showing 1 changed file with 14 additions and 16 deletions.
30 changes: 14 additions & 16 deletions runtime/parachains/src/paras.rs
Original file line number Diff line number Diff line change
Expand Up @@ -61,24 +61,24 @@ pub struct ReplacementTimes<N> {
#[derive(Default, Encode, Decode)]
#[cfg_attr(test, derive(Debug, Clone, PartialEq))]
pub struct ParaPastCodeMeta<N> {
// Block numbers where the code was expected to be replaced and where the code
// was actually replaced, respectively. The first is used to do accurate lookups
// of historic code in historic contexts, whereas the second is used to do
// pruning on an accurate timeframe. These can be used as indices
// into the `PastCode` map along with the `ParaId` to fetch the code itself.
/// Block numbers where the code was expected to be replaced and where the code
/// was actually replaced, respectively. The first is used to do accurate lookups
/// of historic code in historic contexts, whereas the second is used to do
/// pruning on an accurate timeframe. These can be used as indices
/// into the `PastCode` map along with the `ParaId` to fetch the code itself.
upgrade_times: Vec<ReplacementTimes<N>>,
// This tracks the highest pruned code-replacement, if any. This is the `expected_at` value,
// not the `activated_at` value.
/// Tracks the highest pruned code-replacement, if any. This is the `expected_at` value,
/// not the `activated_at` value.
last_pruned: Option<N>,
}

#[cfg_attr(test, derive(Debug, PartialEq))]
enum UseCodeAt<N> {
// Use the current code.
/// Use the current code.
Current,
// Use the code that was replaced at the given block number.
// This is an inclusive endpoint - a parablock in the context of a relay-chain block on this fork
// with number N should use the code that is replaced at N.
/// Use the code that was replaced at the given block number.
/// This is an inclusive endpoint - a parablock in the context of a relay-chain block on this fork
/// with number N should use the code that is replaced at N.
ReplacedAt(N),
}

Expand Down Expand Up @@ -293,11 +293,8 @@ impl<T: Trait> Module<T> {
};

if genesis_data.parachain {
match parachains.binary_search(&upcoming_para) {
Ok(_i) => {}
Err(i) => {
parachains.insert(i, upcoming_para);
}
if let Err(i) = parachains.binary_search(&upcoming_para) {
parachains.insert(i, upcoming_para);
}
}

Expand Down Expand Up @@ -462,6 +459,7 @@ impl<T: Trait> Module<T> {
let prior_code = CurrentCode::get(&id).unwrap_or_default();
CurrentCode::insert(&id, &new_code);

// `now` is only used for registering pruning as part of `fn note_past_code`
let now = <system::Module<T>>::block_number();

let weight = Self::note_past_code(
Expand Down

0 comments on commit 4adc554

Please sign in to comment.