fn next_upgrade(dir: PathBuf, current_version: ProtocolVersion) -> Option<NextUpgrade> {
    let next_version = match next_installed_version(&dir, &current_version) {
        Ok(version) => version,
        Err(error) => {
            warn!(dir=%dir.display(), %error, "failed to get a valid version from subdirs");
            return None;
        }
    };

    if next_version <= current_version {
        return None;
    }

    let subdir = dir.join(dir_name_from_version(&next_version));
    let upgrade_point = match UpgradePoint::from_chainspec_path(&subdir) {
        Ok(upgrade_point) => upgrade_point,
        Err(error) => {
            debug!(subdir=%subdir.display(), %error, "failed to load upgrade point");
            return None;
        }
    };

    if upgrade_point.protocol_config.version != next_version {
        warn!(
            upgrade_point_version=%upgrade_point.protocol_config.version,
            subdir_version=%next_version,
            "next chainspec installed to wrong subdir"
        );
        return None;
    }

    Some(NextUpgrade::from(upgrade_point.protocol_config))
}
/// Uses `next_installed_version()` to find the next versioned subdir.  If it exists, reads the
/// UpgradePoint file from there and returns its version and activation point.  Returns `None` if
/// there is no greater version available, or if any step errors.
Uses `next_installed_version()` to find the next versioned subdir.  If it exists, reads the
UpgradePoint file from there and returns its version and activation point.  Returns `None` if
there is no greater version available, or if any step errors.
Uses ` next_installed_version () ` to find the next versioned subdir . If it exists reads the UpgradePoint file from there and returns its version and activation point . Returns ` None ` if there is no greater version available or if any step errors .
fn next_upgrade(dir: PathBuf, current_version: ProtocolVersion) -> Option<NextUpgrade> {
    let next_version = match next_installed_version(&dir, &current_version) {
        Ok(version) => version,
        Err(error) => {
            warn!(dir=%dir.display(), %error, "failed to get a valid version from subdirs");
            return None;
        }
    };
    if next_version <= current_version {
        return None;
    }
    let subdir = dir.join(dir_name_from_version(&next_version));
    let upgrade_point = match UpgradePoint::from_chainspec_path(&subdir) {
        Ok(upgrade_point) => upgrade_point,
        Err(error) => {
            debug!(subdir=%subdir.display(), %error, "failed to load upgrade point");
            return None;
        }
    };
    if upgrade_point.protocol_config.version != next_version {
        warn!(
            upgrade_point_version=%upgrade_point.protocol_config.version,
            subdir_version=%next_version,
            "next chainspec installed to wrong subdir"
        );
        return None;
    }
    Some(NextUpgrade::from(upgrade_point.protocol_config))
}
fn next_upgrade ( dir : PathBuf , current_version : ProtocolVersion ) -> Option < NextUpgrade > { let next_version = match next_installed_version ( & dir , & current_version ) { Ok ( version ) => version , Err ( error ) => { warn ! ( dir dir display ( ) error " " ) ; return None ; } } ; if next_version <= current_version { return None ; } let subdir = dir . join ( dir_name_from_version ( & next_version ) ) ; let upgrade_point = match UpgradePoint :: from_chainspec_path ( & subdir ) { Ok ( upgrade_point ) => upgrade_point , Err ( error ) => { debug ! ( subdir subdir display ( ) error " " ) ; return None ; } } ; if upgrade_point . protocol_config . version != next_version { warn ! ( upgrade_point_version upgrade_point protocol_config version subdir_version next_version " " ) ; return None ; } Some ( NextUpgrade :: from ( upgrade_point . protocol_config ) ) }
Uses `next_installed_version()` to find the next versioned subdir.
Uses ` next_installed_version () ` to find the next versioned subdir .
dir
PathBuf
current_version
ProtocolVersion
dir
PathBuf
current_version
ProtocolVersion