@@ -89,6 +89,7 @@ pub mod logger;
8989mod message_handler;
9090pub mod payment;
9191mod peer_store;
92+ mod scoring;
9293mod sweep;
9394mod tx_broadcaster;
9495mod types;
@@ -122,8 +123,9 @@ pub use builder::NodeBuilder as Builder;
122123
123124use chain:: ChainSource ;
124125use config:: {
125- default_user_config, may_announce_channel, ChannelConfig , Config , NODE_ANN_BCAST_INTERVAL ,
126- PEER_RECONNECTION_INTERVAL , RGS_SYNC_INTERVAL ,
126+ default_user_config, may_announce_channel, ChannelConfig , Config ,
127+ EXTERNAL_PATHFINDING_SCORES_SYNC_INTERVAL , EXTERNAL_PATHFINDING_SCORES_SYNC_TIMEOUT_SECS ,
128+ NODE_ANN_BCAST_INTERVAL , PEER_RECONNECTION_INTERVAL , RGS_SYNC_INTERVAL ,
127129} ;
128130use connection:: ConnectionManager ;
129131use event:: { EventHandler , EventQueue } ;
@@ -137,6 +139,7 @@ use payment::{
137139 UnifiedQrPayment ,
138140} ;
139141use peer_store:: { PeerInfo , PeerStore } ;
142+ use scoring:: setup_background_pathfinding_scores_sync;
140143use types:: {
141144 Broadcaster , BumpTransactionEventHandler , ChainMonitor , ChannelManager , DynStore , Graph ,
142145 KeysManager , OnionMessenger , PeerManager , Router , Scorer , Sweeper , Wallet ,
@@ -189,6 +192,7 @@ pub struct Node {
189192 keys_manager : Arc < KeysManager > ,
190193 network_graph : Arc < Graph > ,
191194 gossip_source : Arc < GossipSource > ,
195+ pathfinding_scores_sync_url : Option < String > ,
192196 liquidity_source : Option < Arc < LiquiditySource < Arc < Logger > > > > ,
193197 kv_store : Arc < DynStore > ,
194198 logger : Arc < Logger > ,
@@ -303,6 +307,18 @@ impl Node {
303307 } ) ;
304308 }
305309
310+ if let Some ( pathfinding_scores_sync_url) = self . pathfinding_scores_sync_url . as_ref ( ) {
311+ setup_background_pathfinding_scores_sync (
312+ pathfinding_scores_sync_url. clone ( ) ,
313+ Arc :: clone ( & self . scorer ) ,
314+ Arc :: clone ( & self . node_metrics ) ,
315+ Arc :: clone ( & self . kv_store ) ,
316+ Arc :: clone ( & self . logger ) ,
317+ & runtime,
318+ self . stop_sender . subscribe ( ) ,
319+ ) ;
320+ }
321+
306322 if let Some ( listening_addresses) = & self . config . listening_addresses {
307323 // Setup networking
308324 let peer_manager_connection_handler = Arc :: clone ( & self . peer_manager ) ;
@@ -724,6 +740,8 @@ impl Node {
724740 locked_node_metrics. latest_fee_rate_cache_update_timestamp ;
725741 let latest_rgs_snapshot_timestamp =
726742 locked_node_metrics. latest_rgs_snapshot_timestamp . map ( |val| val as u64 ) ;
743+ let latest_pathfinding_scores_sync_timestamp =
744+ locked_node_metrics. latest_pathfinding_scores_sync_timestamp ;
727745 let latest_node_announcement_broadcast_timestamp =
728746 locked_node_metrics. latest_node_announcement_broadcast_timestamp ;
729747 let latest_channel_monitor_archival_height =
@@ -737,6 +755,7 @@ impl Node {
737755 latest_onchain_wallet_sync_timestamp,
738756 latest_fee_rate_cache_update_timestamp,
739757 latest_rgs_snapshot_timestamp,
758+ latest_pathfinding_scores_sync_timestamp,
740759 latest_node_announcement_broadcast_timestamp,
741760 latest_channel_monitor_archival_height,
742761 }
@@ -1565,6 +1584,8 @@ pub struct NodeStatus {
15651584 ///
15661585 /// Will be `None` if RGS isn't configured or the snapshot hasn't been updated yet.
15671586 pub latest_rgs_snapshot_timestamp : Option < u64 > ,
1587+ /// The timestamp, in seconds since start of the UNIX epoch, when we last successfully merged external scores.
1588+ pub latest_pathfinding_scores_sync_timestamp : Option < u64 > ,
15681589 /// The timestamp, in seconds since start of the UNIX epoch, when we last broadcasted a node
15691590 /// announcement.
15701591 ///
@@ -1583,6 +1604,7 @@ pub(crate) struct NodeMetrics {
15831604 latest_onchain_wallet_sync_timestamp : Option < u64 > ,
15841605 latest_fee_rate_cache_update_timestamp : Option < u64 > ,
15851606 latest_rgs_snapshot_timestamp : Option < u32 > ,
1607+ latest_pathfinding_scores_sync_timestamp : Option < u64 > ,
15861608 latest_node_announcement_broadcast_timestamp : Option < u64 > ,
15871609 latest_channel_monitor_archival_height : Option < u32 > ,
15881610}
@@ -1594,6 +1616,7 @@ impl Default for NodeMetrics {
15941616 latest_onchain_wallet_sync_timestamp : None ,
15951617 latest_fee_rate_cache_update_timestamp : None ,
15961618 latest_rgs_snapshot_timestamp : None ,
1619+ latest_pathfinding_scores_sync_timestamp : None ,
15971620 latest_node_announcement_broadcast_timestamp : None ,
15981621 latest_channel_monitor_archival_height : None ,
15991622 }
@@ -1602,6 +1625,7 @@ impl Default for NodeMetrics {
16021625
16031626impl_writeable_tlv_based ! ( NodeMetrics , {
16041627 ( 0 , latest_lightning_wallet_sync_timestamp, option) ,
1628+ ( 1 , latest_pathfinding_scores_sync_timestamp, option) ,
16051629 ( 2 , latest_onchain_wallet_sync_timestamp, option) ,
16061630 ( 4 , latest_fee_rate_cache_update_timestamp, option) ,
16071631 ( 6 , latest_rgs_snapshot_timestamp, option) ,
0 commit comments