mirror of
https://github.com/comit-network/xmr-btc-swap.git
synced 2024-10-01 01:45:40 -04:00
Sort seller list inside of list_sellers
By sorting the list inside we have a more deterministic output that makes processing in JSON easier.
This commit is contained in:
parent
c275e33a6c
commit
6abf83f4ad
@ -285,7 +285,7 @@ async fn main() -> Result<()> {
|
|||||||
.context("Failed to read in seed file")?;
|
.context("Failed to read in seed file")?;
|
||||||
let identity = seed.derive_libp2p_identity();
|
let identity = seed.derive_libp2p_identity();
|
||||||
|
|
||||||
let mut sellers = list_sellers(
|
let sellers = list_sellers(
|
||||||
rendezvous_node_peer_id,
|
rendezvous_node_peer_id,
|
||||||
rendezvous_point,
|
rendezvous_point,
|
||||||
namespace,
|
namespace,
|
||||||
@ -293,7 +293,6 @@ async fn main() -> Result<()> {
|
|||||||
identity,
|
identity,
|
||||||
)
|
)
|
||||||
.await?;
|
.await?;
|
||||||
sellers.sort();
|
|
||||||
|
|
||||||
if json {
|
if json {
|
||||||
for seller in sellers {
|
for seller in sellers {
|
||||||
|
@ -15,6 +15,12 @@ use std::collections::hash_map::Entry;
|
|||||||
use std::collections::HashMap;
|
use std::collections::HashMap;
|
||||||
use std::time::Duration;
|
use std::time::Duration;
|
||||||
|
|
||||||
|
/// Returns sorted list of sellers, with [Online](Status::Online) listed first.
|
||||||
|
///
|
||||||
|
/// First uses the rendezvous node to discover peers in the given namespace,
|
||||||
|
/// then fetches a quote from each peer that was discovered. If fetching a quote
|
||||||
|
/// from a discovered peer fails the seller's status will be
|
||||||
|
/// [Unreachable](Status::Unreachable).
|
||||||
pub async fn list_sellers(
|
pub async fn list_sellers(
|
||||||
rendezvous_node_peer_id: PeerId,
|
rendezvous_node_peer_id: PeerId,
|
||||||
rendezvous_node_addr: Multiaddr,
|
rendezvous_node_addr: Multiaddr,
|
||||||
@ -289,7 +295,10 @@ impl EventLoop {
|
|||||||
.collect::<Result<Vec<_>, _>>();
|
.collect::<Result<Vec<_>, _>>();
|
||||||
|
|
||||||
match all_quotes_fetched {
|
match all_quotes_fetched {
|
||||||
Ok(sellers) => break sellers,
|
Ok(mut sellers) => {
|
||||||
|
sellers.sort();
|
||||||
|
break sellers;
|
||||||
|
}
|
||||||
Err(StillPending {}) => continue,
|
Err(StillPending {}) => continue,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user