- Returns early when there is no Heartwood activation height when creating or updating HistoryTree
- Skips call to `check::legacy_chain()` when no NU5 activation height is set (it would return immediately anyway) - Replaces `.map()` with `.filter_map()` in `NetworkUpgrade::target_spacings()` - Removes outdated TODO
This commit is contained in:
parent
21e838a09a
commit
52ff68f4c8
|
@ -428,9 +428,11 @@ impl HistoryTree {
|
|||
sapling_root: &sapling::tree::Root,
|
||||
orchard_root: &orchard::tree::Root,
|
||||
) -> Result<Self, HistoryTreeError> {
|
||||
let heartwood_height = NetworkUpgrade::Heartwood
|
||||
.activation_height(network)
|
||||
.expect("Heartwood height is known");
|
||||
let Some(heartwood_height) = NetworkUpgrade::Heartwood.activation_height(network) else {
|
||||
// Return early if there is no Heartwood activation height.
|
||||
return Ok(HistoryTree(None));
|
||||
};
|
||||
|
||||
match block
|
||||
.coinbase_height()
|
||||
.expect("must have height")
|
||||
|
|
|
@ -402,14 +402,10 @@ impl NetworkUpgrade {
|
|||
),
|
||||
]
|
||||
.into_iter()
|
||||
.map(move |(upgrade, spacing_seconds)| {
|
||||
let activation_height = upgrade
|
||||
.activation_height(network)
|
||||
.expect("missing activation height for target spacing change");
|
||||
|
||||
.filter_map(move |(upgrade, spacing_seconds)| {
|
||||
let activation_height = upgrade.activation_height(network)?;
|
||||
let target_spacing = Duration::seconds(spacing_seconds);
|
||||
|
||||
(activation_height, target_spacing)
|
||||
Some((activation_height, target_spacing))
|
||||
})
|
||||
}
|
||||
|
||||
|
|
|
@ -356,7 +356,6 @@ pub fn coinbase_expiry_height(
|
|||
) -> Result<(), TransactionError> {
|
||||
let expiry_height = coinbase.expiry_height();
|
||||
|
||||
// TODO: replace `if let` with `expect` after NU5 mainnet activation
|
||||
if let Some(nu5_activation_height) = NetworkUpgrade::Nu5.activation_height(network) {
|
||||
// # Consensus
|
||||
//
|
||||
|
|
|
@ -422,11 +422,10 @@ impl StateService {
|
|||
tracing::info!("starting legacy chain check");
|
||||
let timer = CodeTimer::start();
|
||||
|
||||
if let Some(tip) = state.best_tip() {
|
||||
let nu5_activation_height = NetworkUpgrade::Nu5
|
||||
.activation_height(network)
|
||||
.expect("NU5 activation height is set");
|
||||
|
||||
if let (Some(tip), Some(nu5_activation_height)) = (
|
||||
state.best_tip(),
|
||||
NetworkUpgrade::Nu5.activation_height(network),
|
||||
) {
|
||||
if let Err(error) = check::legacy_chain(
|
||||
nu5_activation_height,
|
||||
any_ancestor_blocks(
|
||||
|
|
Loading…
Reference in New Issue