mirror of
https://github.com/fluencelabs/rust-libp2p
synced 2025-06-28 09:11:34 +00:00
Report which key exactly was not found. (#1171)
This commit is contained in:
@ -972,9 +972,10 @@ where
|
|||||||
self.queued_events.push(event);
|
self.queued_events.push(event);
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
QueryInfoInner::GetValue { key: _, results, .. } => {
|
QueryInfoInner::GetValue { key, results, .. } => {
|
||||||
let result = match results.len() {
|
let result = match results.len() {
|
||||||
0 => GetValueResult::NotFound{
|
0 => GetValueResult::NotFound{
|
||||||
|
key,
|
||||||
closest_peers: closer_peers.collect()
|
closest_peers: closer_peers.collect()
|
||||||
},
|
},
|
||||||
_ => GetValueResult::Found{ results },
|
_ => GetValueResult::Found{ results },
|
||||||
@ -1023,7 +1024,10 @@ pub enum GetValueResult {
|
|||||||
/// The results received from peers. Always contains non-zero number of results.
|
/// The results received from peers. Always contains non-zero number of results.
|
||||||
Found { results: Vec<Record> },
|
Found { results: Vec<Record> },
|
||||||
/// The record wasn't found.
|
/// The record wasn't found.
|
||||||
NotFound { closest_peers: Vec<PeerId> }
|
NotFound {
|
||||||
|
key: Multihash,
|
||||||
|
closest_peers: Vec<PeerId>
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/// The result of a `PUT_VALUE` query.
|
/// The result of a `PUT_VALUE` query.
|
||||||
|
@ -252,7 +252,8 @@ fn get_value_not_found() {
|
|||||||
loop {
|
loop {
|
||||||
match swarm.poll().unwrap() {
|
match swarm.poll().unwrap() {
|
||||||
Async::Ready(Some(KademliaOut::GetValueResult(result))) => {
|
Async::Ready(Some(KademliaOut::GetValueResult(result))) => {
|
||||||
if let GetValueResult::NotFound { closest_peers} = result {
|
if let GetValueResult::NotFound { key, closest_peers } = result {
|
||||||
|
assert_eq!(key, target_key);
|
||||||
assert_eq!(closest_peers.len(), 2);
|
assert_eq!(closest_peers.len(), 2);
|
||||||
assert!(closest_peers.contains(&swarm_ids[1]));
|
assert!(closest_peers.contains(&swarm_ids[1]));
|
||||||
assert!(closest_peers.contains(&swarm_ids[2]));
|
assert!(closest_peers.contains(&swarm_ids[2]));
|
||||||
|
Reference in New Issue
Block a user