Skip to content

Commit 2ae3466

Browse files
committed
Re-format all imports
Nightly `rustfmt` allows to auto-group imports on the module level. While we're not quite convinced to switch to the nightly channel for this yet (mostly because not all contributors would have the right nightly version installed on their machines), we here make use of `cargo +nightly fmt` with some addtional import grouping options as a one-off. This cleans up our imports for the whole crate and gets us to a consistent state everywhere.
1 parent 8e03ddc commit 2ae3466

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

47 files changed

+518
-656
lines changed

rustfmt.toml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,3 +10,5 @@ match_block_trailing_comma = true
1010
# UNSTABLE: format_macro_matchers = true
1111
# UNSTABLE: format_strings = true
1212
# UNSTABLE: group_imports = "StdExternalCrate"
13+
# UNSTABLE: reorder_imports = true
14+
# UNSTABLE: imports_granularity = "Module"

src/balance.rs

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -5,17 +5,14 @@
55
// http://opensource.org/licenses/MIT>, at your option. You may not use this file except in
66
// accordance with one or both of these licenses.
77

8-
use lightning::chain::channelmonitor::Balance as LdkBalance;
9-
use lightning::chain::channelmonitor::BalanceSource;
8+
use bitcoin::secp256k1::PublicKey;
9+
use bitcoin::{Amount, BlockHash, Txid};
10+
use lightning::chain::channelmonitor::{Balance as LdkBalance, BalanceSource};
1011
use lightning::ln::types::ChannelId;
1112
use lightning::sign::SpendableOutputDescriptor;
1213
use lightning::util::sweep::{OutputSpendStatus, TrackedSpendableOutput};
13-
1414
use lightning_types::payment::{PaymentHash, PaymentPreimage};
1515

16-
use bitcoin::secp256k1::PublicKey;
17-
use bitcoin::{Amount, BlockHash, Txid};
18-
1916
/// Details of the known available balances returned by [`Node::list_balances`].
2017
///
2118
/// [`Node::list_balances`]: crate::Node::list_balances

src/builder.rs

Lines changed: 35 additions & 43 deletions
Original file line numberDiff line numberDiff line change
@@ -5,13 +5,47 @@
55
// http://opensource.org/licenses/MIT>, at your option. You may not use this file except in
66
// accordance with one or both of these licenses.
77

8+
use std::collections::HashMap;
9+
use std::convert::TryInto;
10+
use std::default::Default;
11+
use std::path::PathBuf;
12+
use std::sync::atomic::AtomicBool;
13+
use std::sync::{Arc, Mutex, Once, RwLock};
14+
use std::time::SystemTime;
15+
use std::{fmt, fs};
16+
17+
use bdk_wallet::template::Bip84;
18+
use bdk_wallet::{KeychainKind, Wallet as BdkWallet};
19+
use bip39::Mnemonic;
20+
use bitcoin::bip32::{ChildNumber, Xpriv};
21+
use bitcoin::secp256k1::PublicKey;
22+
use bitcoin::{BlockHash, Network};
23+
use lightning::chain::{chainmonitor, BestBlock, Watch};
24+
use lightning::io::Cursor;
25+
use lightning::ln::channelmanager::{self, ChainParameters, ChannelManagerReadArgs};
26+
use lightning::ln::msgs::{RoutingMessageHandler, SocketAddress};
27+
use lightning::ln::peer_handler::{IgnoringMessageHandler, MessageHandler};
28+
use lightning::routing::gossip::NodeAlias;
29+
use lightning::routing::router::DefaultRouter;
30+
use lightning::routing::scoring::{
31+
ProbabilisticScorer, ProbabilisticScoringDecayParameters, ProbabilisticScoringFeeParameters,
32+
};
33+
use lightning::sign::{EntropySource, NodeSigner};
34+
use lightning::util::persist::{
35+
read_channel_monitors, CHANNEL_MANAGER_PERSISTENCE_KEY,
36+
CHANNEL_MANAGER_PERSISTENCE_PRIMARY_NAMESPACE, CHANNEL_MANAGER_PERSISTENCE_SECONDARY_NAMESPACE,
37+
};
38+
use lightning::util::ser::ReadableArgs;
39+
use lightning::util::sweep::OutputSweeper;
40+
use lightning_persister::fs_store::FilesystemStore;
41+
use vss_client::headers::{FixedHeaders, LnurlAuthToJwtProvider, VssHeaderProvider};
42+
843
use crate::chain::ChainSource;
944
use crate::config::{
1045
default_user_config, may_announce_channel, AnnounceError, AsyncPaymentsRole,
1146
BitcoindRestClientConfig, Config, ElectrumSyncConfig, EsploraSyncConfig,
1247
DEFAULT_ESPLORA_SERVER_URL, DEFAULT_LOG_FILENAME, DEFAULT_LOG_LEVEL, WALLET_KEYS_SEED_LEN,
1348
};
14-
1549
use crate::connection::ConnectionManager;
1650
use crate::event::EventQueue;
1751
use crate::fee_estimator::OnchainFeeEstimator;
@@ -39,48 +73,6 @@ use crate::wallet::persist::KVStoreWalletPersister;
3973
use crate::wallet::Wallet;
4074
use crate::{Node, NodeMetrics};
4175

42-
use lightning::chain::{chainmonitor, BestBlock, Watch};
43-
use lightning::io::Cursor;
44-
use lightning::ln::channelmanager::{self, ChainParameters, ChannelManagerReadArgs};
45-
use lightning::ln::msgs::{RoutingMessageHandler, SocketAddress};
46-
use lightning::ln::peer_handler::{IgnoringMessageHandler, MessageHandler};
47-
use lightning::routing::gossip::NodeAlias;
48-
use lightning::routing::router::DefaultRouter;
49-
use lightning::routing::scoring::{
50-
ProbabilisticScorer, ProbabilisticScoringDecayParameters, ProbabilisticScoringFeeParameters,
51-
};
52-
use lightning::sign::{EntropySource, NodeSigner};
53-
54-
use lightning::util::persist::{
55-
read_channel_monitors, CHANNEL_MANAGER_PERSISTENCE_KEY,
56-
CHANNEL_MANAGER_PERSISTENCE_PRIMARY_NAMESPACE, CHANNEL_MANAGER_PERSISTENCE_SECONDARY_NAMESPACE,
57-
};
58-
use lightning::util::ser::ReadableArgs;
59-
use lightning::util::sweep::OutputSweeper;
60-
61-
use lightning_persister::fs_store::FilesystemStore;
62-
63-
use bdk_wallet::template::Bip84;
64-
use bdk_wallet::KeychainKind;
65-
use bdk_wallet::Wallet as BdkWallet;
66-
67-
use bip39::Mnemonic;
68-
69-
use bitcoin::secp256k1::PublicKey;
70-
use bitcoin::{BlockHash, Network};
71-
72-
use bitcoin::bip32::{ChildNumber, Xpriv};
73-
use std::collections::HashMap;
74-
use std::convert::TryInto;
75-
use std::default::Default;
76-
use std::fmt;
77-
use std::fs;
78-
use std::path::PathBuf;
79-
use std::sync::atomic::AtomicBool;
80-
use std::sync::{Arc, Mutex, Once, RwLock};
81-
use std::time::SystemTime;
82-
use vss_client::headers::{FixedHeaders, LnurlAuthToJwtProvider, VssHeaderProvider};
83-
8476
const VSS_HARDENED_CHILD_INDEX: u32 = 877;
8577
const VSS_LNURL_AUTH_HARDENED_CHILD_INDEX: u32 = 138;
8678
const LSPS_HARDENED_CHILD_INDEX: u32 = 577;

src/chain/bitcoind.rs

Lines changed: 24 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -5,45 +5,41 @@
55
// http://opensource.org/licenses/MIT>, at your option. You may not use this file except in
66
// accordance with one or both of these licenses.
77

8-
use super::{periodically_archive_fully_resolved_monitors, WalletSyncStatus};
9-
10-
use crate::config::{
11-
BitcoindRestClientConfig, Config, FEE_RATE_CACHE_UPDATE_TIMEOUT_SECS, TX_BROADCAST_TIMEOUT_SECS,
12-
};
13-
use crate::fee_estimator::{
14-
apply_post_estimation_adjustments, get_all_conf_targets, get_num_block_defaults_for_target,
15-
ConfirmationTarget, OnchainFeeEstimator,
16-
};
17-
use crate::io::utils::write_node_metrics;
18-
use crate::logger::{log_bytes, log_error, log_info, log_trace, LdkLogger, Logger};
19-
use crate::types::{ChainMonitor, ChannelManager, DynStore, Sweeper, Wallet};
20-
use crate::{Error, NodeMetrics};
8+
use std::collections::{HashMap, VecDeque};
9+
use std::sync::atomic::{AtomicU64, Ordering};
10+
use std::sync::{Arc, Mutex, RwLock};
11+
use std::time::{Duration, Instant, SystemTime, UNIX_EPOCH};
2112

13+
use base64::prelude::BASE64_STANDARD;
14+
use base64::Engine;
15+
use bitcoin::{BlockHash, FeeRate, Network, Transaction, Txid};
2216
use lightning::chain::chaininterface::ConfirmationTarget as LdkConfirmationTarget;
2317
use lightning::chain::Listen;
2418
use lightning::util::ser::Writeable;
25-
2619
use lightning_block_sync::gossip::UtxoSource;
2720
use lightning_block_sync::http::{HttpEndpoint, JsonResponse};
2821
use lightning_block_sync::init::{synchronize_listeners, validate_best_block_header};
2922
use lightning_block_sync::poll::{ChainPoller, ChainTip, ValidatedBlockHeader};
3023
use lightning_block_sync::rest::RestClient;
3124
use lightning_block_sync::rpc::{RpcClient, RpcError};
3225
use lightning_block_sync::{
33-
AsyncBlockSourceResult, BlockData, BlockHeaderData, BlockSource, Cache,
26+
AsyncBlockSourceResult, BlockData, BlockHeaderData, BlockSource, BlockSourceErrorKind, Cache,
27+
SpvClient,
3428
};
35-
use lightning_block_sync::{BlockSourceErrorKind, SpvClient};
36-
3729
use serde::Serialize;
3830

39-
use base64::prelude::BASE64_STANDARD;
40-
use base64::Engine;
41-
use bitcoin::{BlockHash, FeeRate, Network, Transaction, Txid};
42-
43-
use std::collections::{HashMap, VecDeque};
44-
use std::sync::atomic::{AtomicU64, Ordering};
45-
use std::sync::{Arc, Mutex, RwLock};
46-
use std::time::{Duration, Instant, SystemTime, UNIX_EPOCH};
31+
use super::{periodically_archive_fully_resolved_monitors, WalletSyncStatus};
32+
use crate::config::{
33+
BitcoindRestClientConfig, Config, FEE_RATE_CACHE_UPDATE_TIMEOUT_SECS, TX_BROADCAST_TIMEOUT_SECS,
34+
};
35+
use crate::fee_estimator::{
36+
apply_post_estimation_adjustments, get_all_conf_targets, get_num_block_defaults_for_target,
37+
ConfirmationTarget, OnchainFeeEstimator,
38+
};
39+
use crate::io::utils::write_node_metrics;
40+
use crate::logger::{log_bytes, log_error, log_info, log_trace, LdkLogger, Logger};
41+
use crate::types::{ChainMonitor, ChannelManager, DynStore, Sweeper, Wallet};
42+
use crate::{Error, NodeMetrics};
4743

4844
const CHAIN_POLLING_INTERVAL_SECS: u64 = 2;
4945

@@ -1417,7 +1413,9 @@ mod tests {
14171413
use bitcoin::hashes::Hash;
14181414
use bitcoin::{FeeRate, OutPoint, ScriptBuf, Transaction, TxIn, TxOut, Txid, Witness};
14191415
use lightning_block_sync::http::JsonResponse;
1420-
use proptest::{arbitrary::any, collection::vec, prop_assert_eq, prop_compose, proptest};
1416+
use proptest::arbitrary::any;
1417+
use proptest::collection::vec;
1418+
use proptest::{prop_assert_eq, prop_compose, proptest};
14211419
use serde_json::json;
14221420

14231421
use crate::chain::bitcoind::{

src/chain/electrum.rs

Lines changed: 18 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,25 @@
55
// http://opensource.org/licenses/MIT>, at your option. You may not use this file except in
66
// accordance with one or both of these licenses.
77

8-
use super::{periodically_archive_fully_resolved_monitors, WalletSyncStatus};
8+
use std::collections::HashMap;
9+
use std::sync::{Arc, Mutex, RwLock};
10+
use std::time::{Duration, Instant, SystemTime, UNIX_EPOCH};
11+
12+
use bdk_chain::bdk_core::spk_client::{
13+
FullScanRequest as BdkFullScanRequest, FullScanResponse as BdkFullScanResponse,
14+
SyncRequest as BdkSyncRequest, SyncResponse as BdkSyncResponse,
15+
};
16+
use bdk_electrum::BdkElectrumClient;
17+
use bdk_wallet::{KeychainKind as BdkKeyChainKind, Update as BdkUpdate};
18+
use bitcoin::{FeeRate, Network, Script, ScriptBuf, Transaction, Txid};
19+
use electrum_client::{
20+
Batch, Client as ElectrumClient, ConfigBuilder as ElectrumConfigBuilder, ElectrumApi,
21+
};
22+
use lightning::chain::{Confirm, Filter, WatchedOutput};
23+
use lightning::util::ser::Writeable;
24+
use lightning_transaction_sync::ElectrumSyncClient;
925

26+
use super::{periodically_archive_fully_resolved_monitors, WalletSyncStatus};
1027
use crate::config::{
1128
Config, ElectrumSyncConfig, BDK_CLIENT_STOP_GAP, BDK_WALLET_SYNC_TIMEOUT_SECS,
1229
FEE_RATE_CACHE_UPDATE_TIMEOUT_SECS, LDK_WALLET_SYNC_TIMEOUT_SECS, TX_BROADCAST_TIMEOUT_SECS,
@@ -22,29 +39,6 @@ use crate::runtime::Runtime;
2239
use crate::types::{ChainMonitor, ChannelManager, DynStore, Sweeper, Wallet};
2340
use crate::NodeMetrics;
2441

25-
use lightning::chain::{Confirm, Filter, WatchedOutput};
26-
use lightning::util::ser::Writeable;
27-
use lightning_transaction_sync::ElectrumSyncClient;
28-
29-
use bdk_chain::bdk_core::spk_client::FullScanRequest as BdkFullScanRequest;
30-
use bdk_chain::bdk_core::spk_client::FullScanResponse as BdkFullScanResponse;
31-
use bdk_chain::bdk_core::spk_client::SyncRequest as BdkSyncRequest;
32-
use bdk_chain::bdk_core::spk_client::SyncResponse as BdkSyncResponse;
33-
use bdk_wallet::KeychainKind as BdkKeyChainKind;
34-
use bdk_wallet::Update as BdkUpdate;
35-
36-
use bdk_electrum::BdkElectrumClient;
37-
38-
use electrum_client::Client as ElectrumClient;
39-
use electrum_client::ConfigBuilder as ElectrumConfigBuilder;
40-
use electrum_client::{Batch, ElectrumApi};
41-
42-
use bitcoin::{FeeRate, Network, Script, ScriptBuf, Transaction, Txid};
43-
44-
use std::collections::HashMap;
45-
use std::sync::{Arc, Mutex, RwLock};
46-
use std::time::{Duration, Instant, SystemTime, UNIX_EPOCH};
47-
4842
const BDK_ELECTRUM_CLIENT_BATCH_SIZE: usize = 5;
4943
const ELECTRUM_CLIENT_NUM_RETRIES: u8 = 3;
5044
const ELECTRUM_CLIENT_TIMEOUT_SECS: u8 = 10;

src/chain/esplora.rs

Lines changed: 11 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,18 @@
55
// http://opensource.org/licenses/MIT>, at your option. You may not use this file except in
66
// accordance with one or both of these licenses.
77

8-
use super::{periodically_archive_fully_resolved_monitors, WalletSyncStatus};
8+
use std::collections::HashMap;
9+
use std::sync::{Arc, Mutex, RwLock};
10+
use std::time::{Duration, Instant, SystemTime, UNIX_EPOCH};
11+
12+
use bdk_esplora::EsploraAsyncExt;
13+
use bitcoin::{FeeRate, Network, Script, Transaction, Txid};
14+
use esplora_client::AsyncClient as EsploraAsyncClient;
15+
use lightning::chain::{Confirm, Filter, WatchedOutput};
16+
use lightning::util::ser::Writeable;
17+
use lightning_transaction_sync::EsploraSyncClient;
918

19+
use super::{periodically_archive_fully_resolved_monitors, WalletSyncStatus};
1020
use crate::config::{
1121
Config, EsploraSyncConfig, BDK_CLIENT_CONCURRENCY, BDK_CLIENT_STOP_GAP,
1222
BDK_WALLET_SYNC_TIMEOUT_SECS, DEFAULT_ESPLORA_CLIENT_TIMEOUT_SECS,
@@ -21,21 +31,6 @@ use crate::logger::{log_bytes, log_error, log_info, log_trace, LdkLogger, Logger
2131
use crate::types::{ChainMonitor, ChannelManager, DynStore, Sweeper, Wallet};
2232
use crate::{Error, NodeMetrics};
2333

24-
use lightning::chain::{Confirm, Filter, WatchedOutput};
25-
use lightning::util::ser::Writeable;
26-
27-
use lightning_transaction_sync::EsploraSyncClient;
28-
29-
use bdk_esplora::EsploraAsyncExt;
30-
31-
use esplora_client::AsyncClient as EsploraAsyncClient;
32-
33-
use bitcoin::{FeeRate, Network, Script, Transaction, Txid};
34-
35-
use std::collections::HashMap;
36-
use std::sync::{Arc, Mutex, RwLock};
37-
use std::time::{Duration, Instant, SystemTime, UNIX_EPOCH};
38-
3934
pub(super) struct EsploraChainSource {
4035
pub(super) sync_config: EsploraSyncConfig,
4136
esplora_client: EsploraAsyncClient,

src/chain/mod.rs

Lines changed: 8 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,14 @@ mod bitcoind;
99
mod electrum;
1010
mod esplora;
1111

12+
use std::collections::HashMap;
13+
use std::sync::{Arc, RwLock};
14+
use std::time::Duration;
15+
16+
use bitcoin::{Script, Txid};
17+
use lightning::chain::Filter;
18+
use lightning_block_sync::gossip::UtxoSource;
19+
1220
use crate::chain::bitcoind::BitcoindChainSource;
1321
use crate::chain::electrum::ElectrumChainSource;
1422
use crate::chain::esplora::EsploraChainSource;
@@ -23,16 +31,6 @@ use crate::runtime::Runtime;
2331
use crate::types::{Broadcaster, ChainMonitor, ChannelManager, DynStore, Sweeper, Wallet};
2432
use crate::{Error, NodeMetrics};
2533

26-
use lightning::chain::Filter;
27-
28-
use lightning_block_sync::gossip::UtxoSource;
29-
30-
use bitcoin::{Script, Txid};
31-
32-
use std::collections::HashMap;
33-
use std::sync::{Arc, RwLock};
34-
use std::time::Duration;
35-
3634
pub(crate) enum WalletSyncStatus {
3735
Completed,
3836
InProgress { subscribers: tokio::sync::broadcast::Sender<Result<(), Error>> },

src/config.rs

Lines changed: 9 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -7,20 +7,19 @@
77

88
//! Objects for configuring the node.
99
10-
use crate::logger::LogLevel;
10+
use std::fmt;
11+
use std::time::Duration;
1112

13+
use bitcoin::secp256k1::PublicKey;
14+
use bitcoin::Network;
1215
use lightning::ln::msgs::SocketAddress;
1316
use lightning::routing::gossip::NodeAlias;
1417
use lightning::routing::router::RouteParametersConfig;
15-
use lightning::util::config::ChannelConfig as LdkChannelConfig;
16-
use lightning::util::config::MaxDustHTLCExposure as LdkMaxDustHTLCExposure;
17-
use lightning::util::config::UserConfig;
18+
use lightning::util::config::{
19+
ChannelConfig as LdkChannelConfig, MaxDustHTLCExposure as LdkMaxDustHTLCExposure, UserConfig,
20+
};
1821

19-
use bitcoin::secp256k1::PublicKey;
20-
use bitcoin::Network;
21-
22-
use std::fmt;
23-
use std::time::Duration;
22+
use crate::logger::LogLevel;
2423

2524
// Config defaults
2625
const DEFAULT_NETWORK: Network = Network::Bitcoin;
@@ -551,11 +550,7 @@ pub enum AsyncPaymentsRole {
551550
mod tests {
552551
use std::str::FromStr;
553552

554-
use super::may_announce_channel;
555-
use super::AnnounceError;
556-
use super::Config;
557-
use super::NodeAlias;
558-
use super::SocketAddress;
553+
use super::{may_announce_channel, AnnounceError, Config, NodeAlias, SocketAddress};
559554

560555
#[test]
561556
fn node_announce_channel() {

0 commit comments

Comments
 (0)