Skip to content

Commit 05155f4

Browse files
0.1.34
1 parent 4726c7c commit 05155f4

File tree

1 file changed

+13
-12
lines changed

1 file changed

+13
-12
lines changed

src/lib.rs

Lines changed: 13 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -32,21 +32,21 @@ use chia_wallet_sdk::{
3232
},
3333
};
3434
use conversions::{ConversionError, FromJs, ToJs};
35+
use futures_util::stream::{FuturesUnordered, StreamExt};
3536
use js::{Coin, CoinSpend, CoinState, EveProof, Proof, ServerCoin, SpendBundle};
3637
use napi::bindgen_prelude::*;
3738
use napi::Result;
39+
use rand::seq::SliceRandom;
3840
use std::collections::HashMap;
3941
use std::{net::SocketAddr, sync::Arc};
42+
use tokio::net::lookup_host;
4043
use tokio::sync::mpsc::{unbounded_channel, UnboundedSender};
4144
use tokio::sync::Mutex;
45+
use tokio::time::{timeout, Duration};
4246
use wallet::{
4347
PossibleLaunchersResponse as RustPossibleLaunchersResponse,
4448
SuccessResponse as RustSuccessResponse, SyncStoreResponse as RustSyncStoreResponse,
4549
};
46-
use rand::seq::SliceRandom;
47-
use tokio::net::lookup_host;
48-
use futures_util::stream::{FuturesUnordered, StreamExt};
49-
use tokio::time::{timeout, Duration};
5050

5151
pub use wallet::*;
5252

@@ -60,9 +60,7 @@ const MAINNET_DNS_INTRODUCERS: &[&str] = &[
6060
"seeder.dexie.space",
6161
"chia.hoffmang.com",
6262
];
63-
const TESTNET11_DNS_INTRODUCERS: &[&str] = &[
64-
"dns-introducer-testnet11.chia.net",
65-
];
63+
const TESTNET11_DNS_INTRODUCERS: &[&str] = &["dns-introducer-testnet11.chia.net"];
6664
const MAINNET_DEFAULT_PORT: u16 = 8444;
6765
const TESTNET11_DEFAULT_PORT: u16 = 58444;
6866

@@ -1008,7 +1006,9 @@ impl Peer {
10081006
/// @returns {Promise<Peer>} A connected Peer instance.
10091007
pub async fn connect_random(peer_type: PeerType, tls: &Tls) -> napi::Result<Self> {
10101008
if peer_type == PeerType::Simulator {
1011-
return Err(js::err("Random peer connection is not supported for simulator"));
1009+
return Err(js::err(
1010+
"Random peer connection is not supported for simulator",
1011+
));
10121012
}
10131013

10141014
// Introducers and default port per network
@@ -1027,7 +1027,9 @@ impl Peer {
10271027
}
10281028

10291029
if addrs.is_empty() {
1030-
return Err(js::err("Failed to resolve any peer addresses from introducers"));
1030+
return Err(js::err(
1031+
"Failed to resolve any peer addresses from introducers",
1032+
));
10311033
}
10321034

10331035
// Shuffle for randomness so every call has different order
@@ -1046,9 +1048,8 @@ impl Peer {
10461048
let uri = addr.to_string();
10471049
let pt = peer_type.clone();
10481050
// Spawn connection attempt with timeout
1049-
futures.push(async move {
1050-
timeout(CONNECT_TIMEOUT, Peer::new(uri, pt, tls)).await
1051-
});
1051+
futures
1052+
.push(async move { timeout(CONNECT_TIMEOUT, Peer::new(uri, pt, tls)).await });
10521053
}
10531054

10541055
while let Some(result) = futures.next().await {

0 commit comments

Comments
 (0)