Skip to content

Commit

Permalink
Align rustfmt.toml with rust-lightning
Browse files Browse the repository at this point in the history
Now that `rust-lightning` has added `rustfmt` support, we make sure our
coding style is aligned.
  • Loading branch information
tnull committed Feb 23, 2024
1 parent 299620e commit 88bb090
Show file tree
Hide file tree
Showing 15 changed files with 167 additions and 160 deletions.
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
Expand Up @@ -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."),
Expand Down Expand Up @@ -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();
Expand All @@ -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));
Expand Down Expand Up @@ -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(
Expand All @@ -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();
Expand All @@ -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
Expand Down Expand Up @@ -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),
Expand All @@ -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| {
Expand Down Expand Up @@ -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| {
Expand All @@ -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))
Expand All @@ -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)) {
Expand All @@ -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();
Expand All @@ -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(());
Expand Down Expand Up @@ -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("")),
Expand All @@ -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
Expand Up @@ -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."),
Expand All @@ -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."),
Expand All @@ -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.")
}
},
}
}
}
Expand Down
Loading

0 comments on commit 88bb090

Please sign in to comment.