Skip to content

Commit 321f2a8

Browse files
authored
Merge pull request #3135 from tnull/2024-06-rustfmt-rgs
Run `rustfmt` on `lightning-rapid-gossip-sync`
2 parents f45a840 + 8be13f6 commit 321f2a8

File tree

3 files changed

+222
-130
lines changed

3 files changed

+222
-130
lines changed

lightning-rapid-gossip-sync/src/lib.rs

Lines changed: 20 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
#![deny(rustdoc::broken_intra_doc_links)]
22
#![deny(rustdoc::private_intra_doc_links)]
3-
43
#![deny(missing_docs)]
54
#![deny(unsafe_code)]
65
#![deny(non_upper_case_globals)]
@@ -63,15 +62,16 @@
6362
6463
#![cfg_attr(all(not(feature = "std"), not(test)), no_std)]
6564

66-
#[cfg(ldk_bench)] extern crate criterion;
65+
#[cfg(ldk_bench)]
66+
extern crate criterion;
6767

6868
#[cfg(not(feature = "std"))]
6969
extern crate alloc;
7070

71-
#[cfg(feature = "std")]
72-
use std::fs::File;
7371
use core::ops::Deref;
7472
use core::sync::atomic::{AtomicBool, Ordering};
73+
#[cfg(feature = "std")]
74+
use std::fs::File;
7575

7676
use lightning::io;
7777
use lightning::ln::msgs::{DecodeError, LightningError};
@@ -121,21 +121,22 @@ impl From<LightningError> for GraphSyncError {
121121
/// See [crate-level documentation] for usage.
122122
///
123123
/// [crate-level documentation]: crate
124-
pub struct RapidGossipSync<NG: Deref<Target=NetworkGraph<L>>, L: Deref>
125-
where L::Target: Logger {
124+
pub struct RapidGossipSync<NG: Deref<Target = NetworkGraph<L>>, L: Deref>
125+
where
126+
L::Target: Logger,
127+
{
126128
network_graph: NG,
127129
logger: L,
128-
is_initial_sync_complete: AtomicBool
130+
is_initial_sync_complete: AtomicBool,
129131
}
130132

131-
impl<NG: Deref<Target=NetworkGraph<L>>, L: Deref> RapidGossipSync<NG, L> where L::Target: Logger {
133+
impl<NG: Deref<Target = NetworkGraph<L>>, L: Deref> RapidGossipSync<NG, L>
134+
where
135+
L::Target: Logger,
136+
{
132137
/// Instantiate a new [`RapidGossipSync`] instance.
133138
pub fn new(network_graph: NG, logger: L) -> Self {
134-
Self {
135-
network_graph,
136-
logger,
137-
is_initial_sync_complete: AtomicBool::new(false)
138-
}
139+
Self { network_graph, logger, is_initial_sync_complete: AtomicBool::new(false) }
139140
}
140141

141142
/// Sync gossip data from a file.
@@ -147,8 +148,7 @@ impl<NG: Deref<Target=NetworkGraph<L>>, L: Deref> RapidGossipSync<NG, L> where L
147148
///
148149
#[cfg(feature = "std")]
149150
pub fn sync_network_graph_with_file_path(
150-
&self,
151-
sync_path: &str,
151+
&self, sync_path: &str,
152152
) -> Result<u32, GraphSyncError> {
153153
let mut file = File::open(sync_path)?;
154154
self.update_network_graph_from_byte_stream(&mut file)
@@ -169,7 +169,9 @@ impl<NG: Deref<Target=NetworkGraph<L>>, L: Deref> RapidGossipSync<NG, L> where L
169169
///
170170
/// `update_data`: `&[u8]` binary stream that comprises the update data
171171
/// `current_time_unix`: `Option<u64>` optional current timestamp to verify data age
172-
pub fn update_network_graph_no_std(&self, update_data: &[u8], current_time_unix: Option<u64>) -> Result<u32, GraphSyncError> {
172+
pub fn update_network_graph_no_std(
173+
&self, update_data: &[u8], current_time_unix: Option<u64>,
174+
) -> Result<u32, GraphSyncError> {
173175
let mut read_cursor = io::Cursor::new(update_data);
174176
self.update_network_graph_from_byte_stream_no_std(&mut read_cursor, current_time_unix)
175177
}
@@ -195,10 +197,10 @@ mod tests {
195197

196198
use bitcoin::Network;
197199

200+
use crate::{GraphSyncError, RapidGossipSync};
198201
use lightning::ln::msgs::DecodeError;
199202
use lightning::routing::gossip::NetworkGraph;
200203
use lightning::util::test_utils::TestLogger;
201-
use crate::{GraphSyncError, RapidGossipSync};
202204

203205
#[test]
204206
fn test_sync_from_file() {
@@ -294,8 +296,7 @@ mod tests {
294296

295297
let rapid_sync = RapidGossipSync::new(&network_graph, &logger);
296298
let start = std::time::Instant::now();
297-
let sync_result = rapid_sync
298-
.sync_network_graph_with_file_path("./res/full_graph.lngossip");
299+
let sync_result = rapid_sync.sync_network_graph_with_file_path("./res/full_graph.lngossip");
299300
if let Err(GraphSyncError::DecodeError(DecodeError::Io(io_error))) = &sync_result {
300301
let error_string = format!("Input file lightning-rapid-gossip-sync/res/full_graph.lngossip is missing! Download it from https://bitcoin.ninja/ldk-compressed_graph-285cb27df79-2022-07-21.bin\n\n{:?}", io_error);
301302
#[cfg(not(require_route_graph_test))]

0 commit comments

Comments
 (0)