File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -83,11 +83,15 @@ impl GossipSource {
8383 }
8484 }
8585
86- pub async fn update_rgs_snapshot ( & self ) -> Result < u32 , Error > {
86+ pub async fn update_rgs_snapshot ( & self , do_full_sync : bool ) -> Result < u32 , Error > {
8787 match self {
8888 Self :: P2PNetwork { gossip_sync : _, .. } => Ok ( 0 ) ,
8989 Self :: RapidGossipSync { gossip_sync, server_url, latest_sync_timestamp, logger } => {
90- let query_timestamp = latest_sync_timestamp. load ( Ordering :: Acquire ) ;
90+ let query_timestamp = if do_full_sync {
91+ 0
92+ } else {
93+ latest_sync_timestamp. load ( Ordering :: Acquire )
94+ } ;
9195 let query_url = format ! ( "{}/{}" , server_url, query_timestamp) ;
9296
9397 let response = tokio:: time:: timeout (
Original file line number Diff line number Diff line change @@ -281,7 +281,7 @@ impl Node {
281281 }
282282 _ = interval. tick( ) => {
283283 let now = Instant :: now( ) ;
284- match gossip_source. update_rgs_snapshot( ) . await {
284+ match gossip_source. update_rgs_snapshot( false ) . await {
285285 Ok ( updated_timestamp) => {
286286 log_info!(
287287 gossip_sync_logger,
@@ -1469,6 +1469,24 @@ impl Node {
14691469 } )
14701470 }
14711471
1472+ /// Manually sync the RGS snapshot.
1473+ ///
1474+ /// If `do_full_sync` is true, the RGS snapshot will be updated from scratch. Otherwise, the
1475+ /// snapshot will be updated from the last known sync point.
1476+ pub async fn sync_rgs ( & self , do_full_sync : bool ) -> Result < u32 , Error > {
1477+ let updated_timestamp = self . gossip_source . update_rgs_snapshot ( do_full_sync) . await ?;
1478+
1479+ let mut locked_node_metrics = self . node_metrics . write ( ) . unwrap ( ) ;
1480+ locked_node_metrics. latest_rgs_snapshot_timestamp = Some ( updated_timestamp) ;
1481+ write_node_metrics (
1482+ & * locked_node_metrics,
1483+ Arc :: clone ( & self . kv_store ) ,
1484+ Arc :: clone ( & self . logger ) ,
1485+ ) ?;
1486+
1487+ Ok ( updated_timestamp)
1488+ }
1489+
14721490 /// Close a previously opened channel.
14731491 ///
14741492 /// 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