Skip to content

Commit

Permalink
refactor: info endpoint and general refactor
Browse files Browse the repository at this point in the history
  • Loading branch information
hopeyen committed Feb 12, 2024
1 parent f091ab6 commit a2e53a3
Show file tree
Hide file tree
Showing 10 changed files with 32 additions and 652 deletions.
132 changes: 19 additions & 113 deletions Cargo.lock

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

5 changes: 2 additions & 3 deletions file-exchange/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -66,9 +66,8 @@ tracing-subscriber = { version = "0.3", features = [
criterion = { version = "0.5", features = ["async_futures"] }
wiremock = "0.5.19"
lazy_static = "1.4.0"
indexer-common = { package = "indexer-common", git = "https://github.com/graphprotocol/indexer-rs", branch = "hope/operator-info-endpoint" }
thegraph = { git = "https://github.com/edgeandnode/toolshed", rev = "796c23da750d48ccf4b6d8841ac164cb5c42655d" }
graphql-http = { git = "https://github.com/edgeandnode/toolshed", rev = "796c23da750d48ccf4b6d8841ac164cb5c42655d", features = [
thegraph = { git = "https://github.com/edgeandnode/toolshed", tag = "thegraph-v0.5.0" }
graphql-http = { git = "https://github.com/edgeandnode/toolshed", tag = "graphql-http-v0.2.1", features = [
"http-reqwest",
] }

Expand Down
27 changes: 4 additions & 23 deletions file-exchange/src/discover/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -202,13 +202,10 @@ impl Finder {
));
}

match operator_response.text().await {
Ok(operator) => {
tracing::debug!(operator, "operator");
Ok(operator)
}
match operator_response.json::<Operator>().await {
Ok(operator) => Ok(operator.public_key),
Err(e) => {
tracing::error!("Operator response parse error for {}", operator_url);
tracing::error!("Operator response parse error {e} for {}", operator_url);
Err(Error::Request(e))
}
}
Expand Down Expand Up @@ -237,14 +234,6 @@ impl Finder {
.json::<serde_json::Value>()
.await
.map_err(|e| Error::DataUnavilable(e.to_string()))?;
// let data = if let Some(data) = res["data"].as_str() {
// let array = serde_json::from_str::<Vec<String>>(data)
// .expect("Failed to parse data field as an array");
// array
// } else {
// eprintln!("The 'data' field is not a string");
// return Err(Error::DataUnavilable("data field is not a vec of strings".to_string()))
// };
let data = res_json["data"]
.as_str()
.ok_or(Error::DataUnavilable(
Expand All @@ -257,14 +246,6 @@ impl Finder {

tracing::debug!(status = tracing::field::debug(&data), "Status reponse");

// let files = match data {
// Ok(files) => files,
// Err(e) => {
// tracing::error!("Status response parse error for {}", status_url);
// return Err(Error::Request(e));
// }
// };

data
}

Expand All @@ -288,7 +269,7 @@ pub async fn unavailable_files(file_map: &FileAvailbilityMap) -> Vec<String> {
}

//TODO: directly access the field instead
#[derive(Serialize, Deserialize)]
#[derive(Debug, Serialize, Deserialize)]
pub struct Operator {
#[serde(alias = "publicKey")]
pub public_key: String,
Expand Down
1 change: 0 additions & 1 deletion file-exchange/tests/discovery.rs
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,6 @@ mod tests {
&[server_0.to_string(), server_1.to_string()],
)
.await;
println!("endpoiunt: {:#?}", endpoints);
assert!(endpoints.len() == 1);
assert!(endpoints.first().unwrap().0 == "0xead22a75679608952db6e85537fbfdca02dae9cb");
assert!(endpoints.first().unwrap().1 == server_0);
Expand Down
53 changes: 0 additions & 53 deletions file-exchange/tests/setup.rs

This file was deleted.

Loading

0 comments on commit a2e53a3

Please sign in to comment.