Skip to content

Commit

Permalink
perf(su): new database impl partially complete
Browse files Browse the repository at this point in the history
  • Loading branch information
VinceJuliano committed Oct 15, 2024
1 parent 8c19a17 commit c3e67ec
Show file tree
Hide file tree
Showing 13 changed files with 552 additions and 496 deletions.
2 changes: 2 additions & 0 deletions servers/su/.gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -4,3 +4,5 @@
.env.router
.wallet.json
.schedulers.json
sufiles/
suindex/
16 changes: 9 additions & 7 deletions servers/su/src/domain/clients/gateway.rs
Original file line number Diff line number Diff line change
Expand Up @@ -132,9 +132,9 @@ impl Gateway for ArweaveGateway {
async fn check_head(&self, tx_id: String) -> Result<bool, String> {
let config = AoConfig::new(Some("su".to_string())).expect("Failed to read configuration");
let arweave_urls = config.arweave_url_list;

let client = Client::new();

for arweave_url in arweave_urls {
let url = match Url::parse(&arweave_url) {
Ok(u) => u,
Expand All @@ -143,31 +143,33 @@ impl Gateway for ArweaveGateway {
continue; // Skip this URL and try the next one
}
};

let response = client
.head(
url.join(&format!("{}", tx_id))
.map_err(|e| GatewayErrorType::CheckHeadError(e.to_string()))?,
)
.send()
.await;

match response {
Ok(res) if res.status().is_success() => {
return Ok(true); // Return success if the request was successful
}
Ok(_) => {
eprintln!("Request failed with non-success status for URL: {}", arweave_url);
eprintln!(
"Request failed with non-success status for URL: {}",
arweave_url
);
}
Err(e) => {
eprintln!("Error requesting URL {}: {}", arweave_url, e);
}
}
}

Ok(false) // If none of the URLs worked, return false
}


async fn network_info(&self) -> Result<NetworkInfo, String> {
// bind these with let so they dont drop until returning
Expand Down
3 changes: 3 additions & 0 deletions servers/su/src/domain/clients/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,9 @@ pub mod uploader;
// database layer
pub mod store;

// local database layer
pub mod local_store;

// arweave gateway
pub mod gateway;

Expand Down
Loading

0 comments on commit c3e67ec

Please sign in to comment.