1
1
#![ deny( rustdoc:: broken_intra_doc_links) ]
2
2
#![ deny( rustdoc:: private_intra_doc_links) ]
3
-
4
3
#![ deny( missing_docs) ]
5
4
#![ deny( unsafe_code) ]
6
5
#![ deny( non_upper_case_globals) ]
63
62
64
63
#![ cfg_attr( all( not( feature = "std" ) , not( test) ) , no_std) ]
65
64
66
- #[ cfg( ldk_bench) ] extern crate criterion;
65
+ #[ cfg( ldk_bench) ]
66
+ extern crate criterion;
67
67
68
68
#[ cfg( not( feature = "std" ) ) ]
69
69
extern crate alloc;
70
70
71
- #[ cfg( feature = "std" ) ]
72
- use std:: fs:: File ;
73
71
use core:: ops:: Deref ;
74
72
use core:: sync:: atomic:: { AtomicBool , Ordering } ;
73
+ #[ cfg( feature = "std" ) ]
74
+ use std:: fs:: File ;
75
75
76
76
use lightning:: io;
77
77
use lightning:: ln:: msgs:: { DecodeError , LightningError } ;
@@ -121,21 +121,22 @@ impl From<LightningError> for GraphSyncError {
121
121
/// See [crate-level documentation] for usage.
122
122
///
123
123
/// [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
+ {
126
128
network_graph : NG ,
127
129
logger : L ,
128
- is_initial_sync_complete : AtomicBool
130
+ is_initial_sync_complete : AtomicBool ,
129
131
}
130
132
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
+ {
132
137
/// Instantiate a new [`RapidGossipSync`] instance.
133
138
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 ) }
139
140
}
140
141
141
142
/// Sync gossip data from a file.
@@ -147,8 +148,7 @@ impl<NG: Deref<Target=NetworkGraph<L>>, L: Deref> RapidGossipSync<NG, L> where L
147
148
///
148
149
#[ cfg( feature = "std" ) ]
149
150
pub fn sync_network_graph_with_file_path (
150
- & self ,
151
- sync_path : & str ,
151
+ & self , sync_path : & str ,
152
152
) -> Result < u32 , GraphSyncError > {
153
153
let mut file = File :: open ( sync_path) ?;
154
154
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
169
169
///
170
170
/// `update_data`: `&[u8]` binary stream that comprises the update data
171
171
/// `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 > {
173
175
let mut read_cursor = io:: Cursor :: new ( update_data) ;
174
176
self . update_network_graph_from_byte_stream_no_std ( & mut read_cursor, current_time_unix)
175
177
}
@@ -195,10 +197,10 @@ mod tests {
195
197
196
198
use bitcoin:: Network ;
197
199
200
+ use crate :: { GraphSyncError , RapidGossipSync } ;
198
201
use lightning:: ln:: msgs:: DecodeError ;
199
202
use lightning:: routing:: gossip:: NetworkGraph ;
200
203
use lightning:: util:: test_utils:: TestLogger ;
201
- use crate :: { GraphSyncError , RapidGossipSync } ;
202
204
203
205
#[ test]
204
206
fn test_sync_from_file ( ) {
@@ -294,8 +296,7 @@ mod tests {
294
296
295
297
let rapid_sync = RapidGossipSync :: new ( & network_graph, & logger) ;
296
298
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" ) ;
299
300
if let Err ( GraphSyncError :: DecodeError ( DecodeError :: Io ( io_error) ) ) = & sync_result {
300
301
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) ;
301
302
#[ cfg( not( require_route_graph_test) ) ]
0 commit comments