Skip to content

Align rustfmt.toml with rust-lightning #261

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Feb 23, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 10 additions & 3 deletions rustfmt.toml
Original file line number Diff line number Diff line change
@@ -1,5 +1,12 @@
hard_tabs = true # use tab characters for indentation, spaces for alignment
use_field_init_shorthand = true
max_width = 100
use_small_heuristics = "Max"
fn_params_layout = "Compressed"
hard_tabs = true
use_field_init_shorthand = true
max_width = 100
match_block_trailing_comma = true
# UNSTABLE: format_code_in_doc_comments = true
# UNSTABLE: overflow_delimited_expr = true
# UNSTABLE: comment_width = 100
# UNSTABLE: format_macro_matchers = true
# UNSTABLE: format_strings = true
# UNSTABLE: group_imports = "StdExternalCrate"
34 changes: 17 additions & 17 deletions src/builder.rs
Original file line number Diff line number Diff line change
@@ -134,10 +134,10 @@ impl fmt::Display for BuildError {
Self::InvalidSeedFile => write!(f, "Given seed file is invalid or could not be read."),
Self::InvalidSystemTime => {
write!(f, "System time is invalid. Clocks might have gone back in time.")
}
},
Self::InvalidChannelMonitor => {
write!(f, "Failed to watch a deserialized ChannelMonitor")
}
},
Self::InvalidListeningAddresses => write!(f, "Given listening addresses are invalid."),
Self::ReadFailed => write!(f, "Failed to read from store."),
Self::WriteFailed => write!(f, "Failed to write to store."),
@@ -572,7 +572,7 @@ fn build_with_store_internal<K: KVStore + Sync + Send + 'static>(
Arc::clone(&logger),
));
(blockchain, tx_sync, tx_broadcaster, fee_estimator)
}
},
None => {
// Default to Esplora client.
let server_url = DEFAULT_ESPLORA_SERVER_URL.to_string();
@@ -590,7 +590,7 @@ fn build_with_store_internal<K: KVStore + Sync + Send + 'static>(
Arc::clone(&logger),
));
(blockchain, tx_sync, tx_broadcaster, fee_estimator)
}
},
};

let runtime = Arc::new(RwLock::new(None));
@@ -636,7 +636,7 @@ fn build_with_store_internal<K: KVStore + Sync + Send + 'static>(
} else {
return Err(BuildError::ReadFailed);
}
}
},
};

let scorer = match io::utils::read_scorer(
@@ -656,7 +656,7 @@ fn build_with_store_internal<K: KVStore + Sync + Send + 'static>(
} else {
return Err(BuildError::ReadFailed);
}
}
},
};

let scoring_fee_params = ProbabilisticScoringFeeParameters::default();
@@ -682,7 +682,7 @@ fn build_with_store_internal<K: KVStore + Sync + Send + 'static>(
log_error!(logger, "Failed to read channel monitors: {}", e.to_string());
return Err(BuildError::ReadFailed);
}
}
},
};

// Initialize the ChannelManager
@@ -794,7 +794,7 @@ fn build_with_store_internal<K: KVStore + Sync + Send + 'static>(
BuildError::WriteFailed
})?;
p2p_source
}
},
GossipSourceConfig::RapidGossipSync(rgs_server) => {
let latest_sync_timestamp = io::utils::read_latest_rgs_sync_timestamp(
Arc::clone(&kv_store),
@@ -807,7 +807,7 @@ fn build_with_store_internal<K: KVStore + Sync + Send + 'static>(
Arc::clone(&network_graph),
Arc::clone(&logger),
))
}
},
};

let liquidity_source = liquidity_source_config.as_ref().and_then(|lsc| {
@@ -858,7 +858,7 @@ fn build_with_store_internal<K: KVStore + Sync + Send + 'static>(
},
GossipSync::None => {
unreachable!("We must always have a gossip sync!");
}
},
};

let cur_time = SystemTime::now().duration_since(SystemTime::UNIX_EPOCH).map_err(|e| {
@@ -883,10 +883,10 @@ fn build_with_store_internal<K: KVStore + Sync + Send + 'static>(
let payment_store = match io::utils::read_payments(Arc::clone(&kv_store), Arc::clone(&logger)) {
Ok(payments) => {
Arc::new(PaymentStore::new(payments, Arc::clone(&kv_store), Arc::clone(&logger)))
}
},
Err(_) => {
return Err(BuildError::ReadFailed);
}
},
};

let event_queue = match io::utils::read_event_queue(Arc::clone(&kv_store), Arc::clone(&logger))
@@ -898,7 +898,7 @@ fn build_with_store_internal<K: KVStore + Sync + Send + 'static>(
} else {
return Err(BuildError::ReadFailed);
}
}
},
};

let peer_store = match io::utils::read_peer_info(Arc::clone(&kv_store), Arc::clone(&logger)) {
@@ -909,7 +909,7 @@ fn build_with_store_internal<K: KVStore + Sync + Send + 'static>(
} else {
return Err(BuildError::ReadFailed);
}
}
},
};

let best_block = channel_manager.current_best_block();
@@ -928,7 +928,7 @@ fn build_with_store_internal<K: KVStore + Sync + Send + 'static>(
)),
Err(_) => {
return Err(BuildError::ReadFailed);
}
},
};

let (stop_sender, stop_receiver) = tokio::sync::watch::channel(());
@@ -981,7 +981,7 @@ fn seed_bytes_from_config(
Some(EntropySourceConfig::SeedFile(seed_path)) => {
Ok(io::utils::read_or_generate_seed_file(&seed_path, Arc::clone(&logger))
.map_err(|_| BuildError::InvalidSeedFile)?)
}
},
Some(EntropySourceConfig::Bip39Mnemonic { mnemonic, passphrase }) => match passphrase {
Some(passphrase) => Ok(mnemonic.to_seed(passphrase)),
None => Ok(mnemonic.to_seed("")),
@@ -991,6 +991,6 @@ fn seed_bytes_from_config(
let seed_path = format!("{}/keys_seed", config.storage_dir_path);
Ok(io::utils::read_or_generate_seed_file(&seed_path, Arc::clone(&logger))
.map_err(|_| BuildError::InvalidSeedFile)?)
}
},
}
}
12 changes: 6 additions & 6 deletions src/error.rs
Original file line number Diff line number Diff line change
@@ -78,7 +78,7 @@ impl fmt::Display for Error {
Self::NotRunning => write!(f, "Node is not running."),
Self::OnchainTxCreationFailed => {
write!(f, "On-chain transaction could not be created.")
}
},
Self::ConnectionFailed => write!(f, "Network connection closed."),
Self::InvoiceCreationFailed => write!(f, "Failed to create invoice."),
Self::PaymentSendingFailed => write!(f, "Failed to send the given payment."),
@@ -89,7 +89,7 @@ impl fmt::Display for Error {
Self::PersistenceFailed => write!(f, "Failed to persist data."),
Self::FeerateEstimationUpdateFailed => {
write!(f, "Failed to update fee rate estimates.")
}
},
Self::WalletOperationFailed => write!(f, "Failed to conduct wallet operation."),
Self::OnchainTxSigningFailed => write!(f, "Failed to sign given transaction."),
Self::MessageSigningFailed => write!(f, "Failed to sign given message."),
@@ -109,16 +109,16 @@ impl fmt::Display for Error {
Self::InvalidNetwork => write!(f, "The given network is invalid."),
Self::DuplicatePayment => {
write!(f, "A payment with the given hash has already been initiated.")
}
},
Self::InsufficientFunds => {
write!(f, "The available funds are insufficient to complete the given operation.")
}
},
Self::LiquiditySourceUnavailable => {
write!(f, "The given operation failed due to the required liquidity source being unavailable.")
}
},
Self::LiquidityFeeTooHigh => {
write!(f, "The given operation failed due to the LSP's required opening fee being too high.")
}
},
}
}
}
Loading