Skip to content
This repository has been archived by the owner on Jan 22, 2025. It is now read-only.

Commit

Permalink
update dep for indexmap
Browse files Browse the repository at this point in the history
  • Loading branch information
pgarg66 committed Oct 7, 2023
1 parent 5f3d349 commit e96bd73
Show file tree
Hide file tree
Showing 5 changed files with 33 additions and 11 deletions.
4 changes: 3 additions & 1 deletion Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 2 additions & 0 deletions cargo-registry/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -15,12 +15,14 @@ flate2 = { workspace = true }
git2 = { workspace = true }
hyper = { workspace = true, features = ["full"] }
hyper-staticfile = { workspace = true }
log = { workspace = true }
serde = { workspace = true, features = ["derive"] }
serde_json = { workspace = true }
solana-clap-utils = { workspace = true }
solana-cli = { workspace = true }
solana-cli-config = { workspace = true }
solana-cli-output = { workspace = true }
solana-logger = { workspace = true }
solana-remote-wallet = { workspace = true, features = ["default"] }
solana-rpc-client = { workspace = true, features = ["default"] }
solana-rpc-client-api = { workspace = true }
Expand Down
1 change: 0 additions & 1 deletion cargo-registry/src/dummy_git_index.rs
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,6 @@ impl DummyGitIndex {
let config_path = root_dir.join("config.json");
let config_written = if let Ok(config) = fs::read_to_string(&config_path) {
if config != expected_config {
println!("Expected config {}, found {}", expected_config, config);
fs::write(config_path, expected_config).expect("Failed to update config");
true
} else {
Expand Down
26 changes: 19 additions & 7 deletions cargo-registry/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ use {
Method, Server,
},
hyper_staticfile::Static,
log::*,
std::{
net::{IpAddr, Ipv4Addr, SocketAddr},
path::PathBuf,
Expand Down Expand Up @@ -42,13 +43,23 @@ impl CargoRegistryService {
request: hyper::Request<hyper::Body>,
client: Arc<Client>,
) -> hyper::Response<hyper::Body> {
info!("Handling request to publish the crate");
let bytes = body::to_bytes(request.into_body()).await;
let bytes = bytes.expect("failed to received data");

let _result =
tokio::task::spawn_blocking(move || Publisher::publish_crate(bytes, client)).await;

Self::success_response()
if let Ok(bytes) = bytes {
let result =
tokio::task::spawn_blocking(move || Publisher::publish_crate(bytes, client)).await;

if result.is_ok() {
info!("Published the crate successfully. {:?}", result);
Self::success_response()
} else {
error!("Failed to publish the crate. {:?}", result);
Self::error_response()
}
} else {
error!("Failed to receive the data from the request");
Self::error_response()
}
}

fn get_crate_name_and_version(path: &str) -> Option<(&str, &str, &str)> {
Expand Down Expand Up @@ -204,6 +215,7 @@ impl CargoRegistryService {

#[tokio::main]
async fn main() {
solana_logger::setup_with_default("solana=info");
let client = Arc::new(Client::new().expect("Failed to get RPC Client instance"));
let port = client.port;

Expand All @@ -220,7 +232,7 @@ async fn main() {
DummyGitIndex::create_or_update_git_repo(PathBuf::from("/tmp/dummy-git"), &addr);

let server = Server::bind(&addr).serve(registry_service);
println!("Server running on http://{}", addr);
info!("Server running on on http://{}", addr);

let _ = server.await;
}
11 changes: 9 additions & 2 deletions cargo-registry/src/publisher.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ use {
crate::client::{Client, ClientConfig},
flate2::read::GzDecoder,
hyper::body::Bytes,
log::*,
serde::{Deserialize, Serialize},
serde_json::from_slice,
solana_cli::program_v4::{process_deploy_program, read_and_verify_elf},
Expand Down Expand Up @@ -126,7 +127,7 @@ impl Publisher {
let program_path = Self::make_path(&tempdir, &meta_data, format!("out/{}.so", lib_name))
.into_os_string()
.into_string()
.map_err(|_| format!("Failed to get program file path"))?;
.map_err(|_| "Failed to get program file path")?;

let program_data = read_and_verify_elf(program_path.as_ref())
.map_err(|e| format!("failed to read the program: {}", e))?;
Expand All @@ -138,6 +139,8 @@ impl Publisher {
))
.map_err(|e| format!("Failed to get keypair from the file: {}", e))?;

info!("Deploying program at {:?}", program_keypair.pubkey());

process_deploy_program(
client.rpc_client.clone(),
&config.0,
Expand All @@ -146,8 +149,12 @@ impl Publisher {
&program_keypair.pubkey(),
Some(&program_keypair),
)
.map_err(|e| format!("Failed to deploy the program: {}", e))?;
.map_err(|e| {
error!("Failed to deploy the program: {}", e);
format!("Failed to deploy the program: {}", e)
})?;

info!("Successfully deployed the program");
Ok(())
}
}

0 comments on commit e96bd73

Please sign in to comment.