Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove total from result for portal_historyFindNodes #703

Merged
merged 1 commit into from
May 1, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 1 addition & 7 deletions ethportal-api/src/types/portal.rs
Original file line number Diff line number Diff line change
Expand Up @@ -25,13 +25,7 @@ pub struct PongInfo {
pub data_radius: DataRadius,
}

/// Response for FindNodes endpoint
#[derive(Clone, Debug, PartialEq, Eq, Serialize, Deserialize)]
#[serde(rename_all = "camelCase")]
pub struct FindNodesInfo {
pub total: u8,
pub enrs: Vec<Enr>,
}
pub type FindNodesInfo = Vec<Enr>;

/// Response for FindContent endpoint
#[derive(Clone, Debug, PartialEq, Eq, Serialize, Deserialize)]
Expand Down
6 changes: 2 additions & 4 deletions ethportal-peertest/src/scenarios/basic.rs
Original file line number Diff line number Diff line change
Expand Up @@ -58,8 +58,7 @@ pub async fn test_history_find_nodes(target: &Client, peertest: &Peertest) {
.find_nodes(peertest.bootnode.enr.clone(), vec![256])
.await
.unwrap();
assert_eq!(result.total, 1);
assert!(result.enrs.contains(&peertest.nodes[0].enr));
assert!(result.contains(&peertest.nodes[0].enr));
}

pub async fn test_history_find_nodes_zero_distance(target: &Client, peertest: &Peertest) {
Expand All @@ -68,8 +67,7 @@ pub async fn test_history_find_nodes_zero_distance(target: &Client, peertest: &P
.find_nodes(peertest.bootnode.enr.clone(), vec![0])
.await
.unwrap();
assert_eq!(result.total, 1);
assert!(result.enrs.contains(&peertest.bootnode.enr));
assert!(result.contains(&peertest.bootnode.enr));
}

pub async fn test_history_store(target: &Client) {
Expand Down
13 changes: 5 additions & 8 deletions trin-history/src/jsonrpc.rs
Original file line number Diff line number Diff line change
Expand Up @@ -217,14 +217,11 @@ async fn find_nodes(
) -> Result<Value, String> {
let overlay = network.read().await.overlay.clone();
match overlay.send_find_nodes(enr, distances).await {
Ok(nodes) => Ok(json!(FindNodesInfo {
total: nodes.total,
enrs: nodes
.enrs
.into_iter()
.map(|enr| enr.into())
.collect::<Vec<Enr>>(),
})),
Ok(nodes) => Ok(json!(nodes
.enrs
.into_iter()
.map(|enr| enr.into())
.collect::<FindNodesInfo>())),
Err(msg) => Err(format!("FindNodes request timeout: {msg:?}")),
}
}
Expand Down