install: Drop unneeded sha2 dependency (#7108)
* Poll for updates slower * Drop sha2 dependency
This commit is contained in:
1
Cargo.lock
generated
1
Cargo.lock
generated
@ -3507,7 +3507,6 @@ dependencies = [
|
|||||||
"serde 1.0.102 (registry+https://github.com/rust-lang/crates.io-index)",
|
"serde 1.0.102 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||||
"serde_derive 1.0.102 (registry+https://github.com/rust-lang/crates.io-index)",
|
"serde_derive 1.0.102 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||||
"serde_yaml 0.8.11 (registry+https://github.com/rust-lang/crates.io-index)",
|
"serde_yaml 0.8.11 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||||
"sha2 0.8.0 (registry+https://github.com/rust-lang/crates.io-index)",
|
|
||||||
"solana-clap-utils 0.21.0",
|
"solana-clap-utils 0.21.0",
|
||||||
"solana-client 0.21.0",
|
"solana-client 0.21.0",
|
||||||
"solana-config-program 0.21.0",
|
"solana-config-program 0.21.0",
|
||||||
|
@ -26,7 +26,6 @@ reqwest = { version = "0.9.22", default-features = false, features = ["rustls-tl
|
|||||||
serde = "1.0.102"
|
serde = "1.0.102"
|
||||||
serde_derive = "1.0.102"
|
serde_derive = "1.0.102"
|
||||||
serde_yaml = "0.8.11"
|
serde_yaml = "0.8.11"
|
||||||
sha2 = "0.8.0"
|
|
||||||
solana-clap-utils = { path = "../clap-utils", version = "0.21.0" }
|
solana-clap-utils = { path = "../clap-utils", version = "0.21.0" }
|
||||||
solana-client = { path = "../client", version = "0.21.0" }
|
solana-client = { path = "../client", version = "0.21.0" }
|
||||||
solana-config-program = { path = "../programs/config", version = "0.21.0" }
|
solana-config-program = { path = "../programs/config", version = "0.21.0" }
|
||||||
|
@ -1,22 +1,27 @@
|
|||||||
use crate::config::{Config, ExplicitRelease};
|
use crate::{
|
||||||
use crate::stop_process::stop_process;
|
config::{Config, ExplicitRelease},
|
||||||
use crate::update_manifest::{SignedUpdateManifest, UpdateManifest};
|
stop_process::stop_process,
|
||||||
|
update_manifest::{SignedUpdateManifest, UpdateManifest},
|
||||||
|
};
|
||||||
use chrono::{Local, TimeZone};
|
use chrono::{Local, TimeZone};
|
||||||
use console::{style, Emoji};
|
use console::{style, Emoji};
|
||||||
use indicatif::{ProgressBar, ProgressStyle};
|
use indicatif::{ProgressBar, ProgressStyle};
|
||||||
use sha2::{Digest, Sha256};
|
|
||||||
use solana_client::rpc_client::RpcClient;
|
use solana_client::rpc_client::RpcClient;
|
||||||
use solana_config_program::{config_instruction, get_config_data};
|
use solana_config_program::{config_instruction, get_config_data};
|
||||||
use solana_sdk::message::Message;
|
use solana_sdk::{
|
||||||
use solana_sdk::pubkey::Pubkey;
|
hash::{Hash, Hasher},
|
||||||
use solana_sdk::signature::{read_keypair_file, Keypair, KeypairUtil, Signable};
|
message::Message,
|
||||||
use solana_sdk::transaction::Transaction;
|
pubkey::Pubkey,
|
||||||
use std::fs::{self, File};
|
signature::{read_keypair_file, Keypair, KeypairUtil, Signable},
|
||||||
use std::io::{self, BufReader, Read};
|
transaction::Transaction,
|
||||||
use std::path::{Path, PathBuf};
|
};
|
||||||
use std::sync::mpsc;
|
use std::{
|
||||||
use std::time::SystemTime;
|
fs::{self, File},
|
||||||
use std::time::{Duration, Instant};
|
io::{self, BufReader, Read},
|
||||||
|
path::{Path, PathBuf},
|
||||||
|
sync::mpsc,
|
||||||
|
time::{Duration, Instant, SystemTime},
|
||||||
|
};
|
||||||
use tempdir::TempDir;
|
use tempdir::TempDir;
|
||||||
use url::Url;
|
use url::Url;
|
||||||
|
|
||||||
@ -51,12 +56,12 @@ fn println_name_value(name: &str, value: &str) {
|
|||||||
///
|
///
|
||||||
fn download_to_temp_archive(
|
fn download_to_temp_archive(
|
||||||
url: &str,
|
url: &str,
|
||||||
expected_sha256: Option<&str>,
|
expected_sha256: Option<&Hash>,
|
||||||
) -> Result<(TempDir, PathBuf, String), Box<dyn std::error::Error>> {
|
) -> Result<(TempDir, PathBuf, Hash), Box<dyn std::error::Error>> {
|
||||||
fn sha256_file_digest<P: AsRef<Path>>(path: P) -> Result<String, Box<dyn std::error::Error>> {
|
fn sha256_file_digest<P: AsRef<Path>>(path: P) -> Result<Hash, Box<dyn std::error::Error>> {
|
||||||
let input = File::open(path)?;
|
let input = File::open(path)?;
|
||||||
let mut reader = BufReader::new(input);
|
let mut reader = BufReader::new(input);
|
||||||
let mut hasher = Sha256::new();
|
let mut hasher = Hasher::default();
|
||||||
|
|
||||||
let mut buffer = [0; 1024];
|
let mut buffer = [0; 1024];
|
||||||
loop {
|
loop {
|
||||||
@ -64,9 +69,9 @@ fn download_to_temp_archive(
|
|||||||
if count == 0 {
|
if count == 0 {
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
hasher.input(&buffer[..count]);
|
hasher.hash(&buffer[..count]);
|
||||||
}
|
}
|
||||||
Ok(bs58::encode(hasher.result()).into_string())
|
Ok(hasher.result())
|
||||||
}
|
}
|
||||||
|
|
||||||
let url = Url::parse(url).map_err(|err| format!("Unable to parse {}: {}", url, err))?;
|
let url = Url::parse(url).map_err(|err| format!("Unable to parse {}: {}", url, err))?;
|
||||||
@ -788,7 +793,7 @@ pub fn update(config_file: &str) -> Result<bool, String> {
|
|||||||
return Err("Unable to update to an older version".to_string());
|
return Err("Unable to update to an older version".to_string());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
let release_dir = config.release_dir(&update_manifest.download_sha256);
|
let release_dir = config.release_dir(&update_manifest.download_sha256.to_string());
|
||||||
let (_temp_dir, temp_archive, _temp_archive_sha256) = download_to_temp_archive(
|
let (_temp_dir, temp_archive, _temp_archive_sha256) = download_to_temp_archive(
|
||||||
&update_manifest.download_url,
|
&update_manifest.download_url,
|
||||||
Some(&update_manifest.download_sha256),
|
Some(&update_manifest.download_sha256),
|
||||||
|
@ -33,7 +33,7 @@ impl Config {
|
|||||||
json_rpc_url: json_rpc_url.to_string(),
|
json_rpc_url: json_rpc_url.to_string(),
|
||||||
update_manifest_pubkey: *update_manifest_pubkey,
|
update_manifest_pubkey: *update_manifest_pubkey,
|
||||||
current_update_manifest: None,
|
current_update_manifest: None,
|
||||||
update_poll_secs: 60, // check for updates once a minute
|
update_poll_secs: 60 * 60, // check for updates once an hour
|
||||||
explicit_release,
|
explicit_release,
|
||||||
releases_dir: PathBuf::from(data_dir).join("releases"),
|
releases_dir: PathBuf::from(data_dir).join("releases"),
|
||||||
active_release_dir: PathBuf::from(data_dir).join("active_release"),
|
active_release_dir: PathBuf::from(data_dir).join("active_release"),
|
||||||
|
@ -1,17 +1,18 @@
|
|||||||
use serde_derive::{Deserialize, Serialize};
|
use serde_derive::{Deserialize, Serialize};
|
||||||
use solana_config_program::ConfigState;
|
use solana_config_program::ConfigState;
|
||||||
use solana_sdk::pubkey::Pubkey;
|
use solana_sdk::{
|
||||||
use solana_sdk::signature::{Signable, Signature};
|
hash::Hash,
|
||||||
use std::borrow::Cow;
|
pubkey::Pubkey,
|
||||||
use std::error;
|
signature::{Signable, Signature},
|
||||||
use std::io;
|
};
|
||||||
|
use std::{borrow::Cow, error, io};
|
||||||
|
|
||||||
/// Information required to download and apply a given update
|
/// Information required to download and apply a given update
|
||||||
#[derive(Serialize, Deserialize, Default, Debug, PartialEq)]
|
#[derive(Serialize, Deserialize, Default, Debug, PartialEq)]
|
||||||
pub struct UpdateManifest {
|
pub struct UpdateManifest {
|
||||||
pub timestamp_secs: u64, // When the release was deployed in seconds since UNIX EPOCH
|
pub timestamp_secs: u64, // When the release was deployed in seconds since UNIX EPOCH
|
||||||
pub download_url: String, // Download URL to the release tar.bz2
|
pub download_url: String, // Download URL to the release tar.bz2
|
||||||
pub download_sha256: String, // SHA256 digest of the release tar.bz2 file
|
pub download_sha256: Hash, // SHA256 digest of the release tar.bz2 file
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Userdata of an Update Manifest program Account.
|
/// Userdata of an Update Manifest program Account.
|
||||||
|
Reference in New Issue
Block a user