File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -82,11 +82,15 @@ impl GossipSource {
8282 }
8383 }
8484
85- pub async fn update_rgs_snapshot ( & self ) -> Result < u32 , Error > {
85+ pub async fn update_rgs_snapshot ( & self , do_full_sync : bool ) -> Result < u32 , Error > {
8686 match self {
8787 Self :: P2PNetwork { gossip_sync : _, .. } => Ok ( 0 ) ,
8888 Self :: RapidGossipSync { gossip_sync, server_url, latest_sync_timestamp, logger } => {
89- let query_timestamp = latest_sync_timestamp. load ( Ordering :: Acquire ) ;
89+ let query_timestamp = if do_full_sync {
90+ 0
91+ } else {
92+ latest_sync_timestamp. load ( Ordering :: Acquire )
93+ } ;
9094 let query_url = format ! ( "{}/{}" , server_url, query_timestamp) ;
9195
9296 let response = tokio:: time:: timeout (
Original file line number Diff line number Diff line change @@ -301,7 +301,7 @@ impl Node {
301301 _ = interval. tick( ) => {
302302 let gossip_sync_logger = Arc :: clone( & gossip_sync_logger) ;
303303 let now = Instant :: now( ) ;
304- match gossip_source. update_rgs_snapshot( ) . await {
304+ match gossip_source. update_rgs_snapshot( false ) . await {
305305 Ok ( updated_timestamp) => {
306306 log_trace!(
307307 gossip_sync_logger,
@@ -1360,6 +1360,24 @@ impl Node {
13601360 } )
13611361 }
13621362
1363+ /// Manually sync the RGS snapshot.
1364+ ///
1365+ /// If `do_full_sync` is true, the RGS snapshot will be updated from scratch. Otherwise, the
1366+ /// snapshot will be updated from the last known sync point.
1367+ pub async fn sync_rgs ( & self , do_full_sync : bool ) -> Result < u32 , Error > {
1368+ let updated_timestamp = self . gossip_source . update_rgs_snapshot ( do_full_sync) . await ?;
1369+
1370+ let mut locked_node_metrics = self . node_metrics . write ( ) . unwrap ( ) ;
1371+ locked_node_metrics. latest_rgs_snapshot_timestamp = Some ( updated_timestamp) ;
1372+ write_node_metrics (
1373+ & * locked_node_metrics,
1374+ Arc :: clone ( & self . kv_store ) ,
1375+ Arc :: clone ( & self . logger ) ,
1376+ ) ?;
1377+
1378+ Ok ( updated_timestamp)
1379+ }
1380+
13631381 /// Close a previously opened channel.
13641382 ///
13651383 /// Will attempt to close a channel coopertively. If this fails, users might need to resort to
You can’t perform that action at this time.
0 commit comments