Skip to content

Commit b3c33b5

Browse files
committed
rename OutboundQueryCompleted to OutboundQueryProgressed
refs libp2p/rust-libp2p#2712
1 parent 2fa1b2b commit b3c33b5

File tree

1 file changed

+25
-20
lines changed

1 file changed

+25
-20
lines changed

client/network/src/discovery.rs

+25-20
Original file line numberDiff line numberDiff line change
@@ -58,8 +58,8 @@ use libp2p::{
5858
self,
5959
store::{MemoryStore, RecordStore},
6060
},
61-
GetClosestPeersError, Kademlia, KademliaBucketInserts, KademliaConfig, KademliaEvent,
62-
QueryId, QueryResult, Quorum, Record,
61+
GetClosestPeersError, GetRecordOk, Kademlia, KademliaBucketInserts, KademliaConfig,
62+
KademliaEvent, QueryId, QueryResult, Quorum, Record,
6363
},
6464
mdns::{async_io::Behaviour as Mdns, Config as MdnsConfig, Event as MdnsEvent},
6565
multiaddr::Protocol,
@@ -366,7 +366,7 @@ impl DiscoveryBehaviour {
366366
/// A corresponding `ValueFound` or `ValueNotFound` event will later be generated.
367367
pub fn get_value(&mut self, key: record::Key) {
368368
if let Some(k) = self.kademlia.as_mut() {
369-
k.get_record(key.clone(), Quorum::One);
369+
k.get_record(key.clone());
370370
}
371371
}
372372

@@ -642,6 +642,7 @@ impl NetworkBehaviour for DiscoveryBehaviour {
642642
}
643643
}
644644

645+
let records = Vec::new();
645646
while let Poll::Ready(ev) = self.kademlia.poll(cx, params) {
646647
match ev {
647648
NetworkBehaviourAction::GenerateEvent(ev) => match ev {
@@ -661,7 +662,7 @@ impl NetworkBehaviour for DiscoveryBehaviour {
661662
KademliaEvent::InboundRequest { .. } => {
662663
// We are not interested in this event at the moment.
663664
},
664-
KademliaEvent::OutboundQueryCompleted {
665+
KademliaEvent::OutboundQueryProgressed {
665666
result: QueryResult::GetClosestPeers(res),
666667
..
667668
} => match res {
@@ -686,24 +687,28 @@ impl NetworkBehaviour for DiscoveryBehaviour {
686687
}
687688
},
688689
},
689-
KademliaEvent::OutboundQueryCompleted {
690+
KademliaEvent::OutboundQueryProgressed {
690691
result: QueryResult::GetRecord(res),
691692
stats,
693+
step,
692694
..
693695
} => {
694696
let ev = match res {
695-
Ok(ok) => {
696-
let results = ok
697-
.records
698-
.into_iter()
699-
.map(|r| (r.record.key, r.record.value))
700-
.collect();
701-
702-
DiscoveryOut::ValueFound(
703-
results,
704-
stats.duration().unwrap_or_default(),
705-
)
706-
},
697+
Ok(ok) =>
698+
if let GetRecordOk::FoundRecord(r) = ok {
699+
DiscoveryOut::ValueFound(
700+
vec![(r.record.key, r.record.value)],
701+
stats.duration().unwrap_or_default(),
702+
)
703+
} else {
704+
debug!(
705+
target: "sub-libp2p",
706+
"Libp2p => Query progressed to {:?} step (last: {:?})",
707+
step.count,
708+
step.last,
709+
);
710+
continue
711+
},
707712
Err(e @ libp2p::kad::GetRecordError::NotFound { .. }) => {
708713
trace!(
709714
target: "sub-libp2p",
@@ -729,7 +734,7 @@ impl NetworkBehaviour for DiscoveryBehaviour {
729734
};
730735
return Poll::Ready(NetworkBehaviourAction::GenerateEvent(ev))
731736
},
732-
KademliaEvent::OutboundQueryCompleted {
737+
KademliaEvent::OutboundQueryProgressed {
733738
result: QueryResult::PutRecord(res),
734739
stats,
735740
..
@@ -751,7 +756,7 @@ impl NetworkBehaviour for DiscoveryBehaviour {
751756
};
752757
return Poll::Ready(NetworkBehaviourAction::GenerateEvent(ev))
753758
},
754-
KademliaEvent::OutboundQueryCompleted {
759+
KademliaEvent::OutboundQueryProgressed {
755760
result: QueryResult::RepublishRecord(res),
756761
..
757762
} => match res {
@@ -767,7 +772,7 @@ impl NetworkBehaviour for DiscoveryBehaviour {
767772
),
768773
},
769774
// We never start any other type of query.
770-
KademliaEvent::OutboundQueryCompleted { result: e, .. } => {
775+
KademliaEvent::OutboundQueryProgressed { result: e, .. } => {
771776
warn!(target: "sub-libp2p", "Libp2p => Unhandled Kademlia event: {:?}", e)
772777
},
773778
},

0 commit comments

Comments
 (0)