@@ -89,6 +89,7 @@ pub mod logger;
89
89
mod message_handler;
90
90
pub mod payment;
91
91
mod peer_store;
92
+ mod scoring;
92
93
mod sweep;
93
94
mod tx_broadcaster;
94
95
mod types;
@@ -122,8 +123,9 @@ pub use builder::NodeBuilder as Builder;
122
123
123
124
use chain:: ChainSource ;
124
125
use 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 ,
127
129
} ;
128
130
use connection:: ConnectionManager ;
129
131
use event:: { EventHandler , EventQueue } ;
@@ -137,6 +139,7 @@ use payment::{
137
139
UnifiedQrPayment ,
138
140
} ;
139
141
use peer_store:: { PeerInfo , PeerStore } ;
142
+ use scoring:: setup_background_pathfinding_scores_sync;
140
143
use types:: {
141
144
Broadcaster , BumpTransactionEventHandler , ChainMonitor , ChannelManager , DynStore , Graph ,
142
145
KeysManager , OnionMessenger , PeerManager , Router , Scorer , Sweeper , Wallet ,
@@ -189,6 +192,7 @@ pub struct Node {
189
192
keys_manager : Arc < KeysManager > ,
190
193
network_graph : Arc < Graph > ,
191
194
gossip_source : Arc < GossipSource > ,
195
+ pathfinding_scores_sync_url : Option < String > ,
192
196
liquidity_source : Option < Arc < LiquiditySource < Arc < Logger > > > > ,
193
197
kv_store : Arc < DynStore > ,
194
198
logger : Arc < Logger > ,
@@ -303,6 +307,18 @@ impl Node {
303
307
} ) ;
304
308
}
305
309
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
+
306
322
if let Some ( listening_addresses) = & self . config . listening_addresses {
307
323
// Setup networking
308
324
let peer_manager_connection_handler = Arc :: clone ( & self . peer_manager ) ;
@@ -724,6 +740,8 @@ impl Node {
724
740
locked_node_metrics. latest_fee_rate_cache_update_timestamp ;
725
741
let latest_rgs_snapshot_timestamp =
726
742
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 ;
727
745
let latest_node_announcement_broadcast_timestamp =
728
746
locked_node_metrics. latest_node_announcement_broadcast_timestamp ;
729
747
let latest_channel_monitor_archival_height =
@@ -737,6 +755,7 @@ impl Node {
737
755
latest_onchain_wallet_sync_timestamp,
738
756
latest_fee_rate_cache_update_timestamp,
739
757
latest_rgs_snapshot_timestamp,
758
+ latest_pathfinding_scores_sync_timestamp,
740
759
latest_node_announcement_broadcast_timestamp,
741
760
latest_channel_monitor_archival_height,
742
761
}
@@ -1565,6 +1584,8 @@ pub struct NodeStatus {
1565
1584
///
1566
1585
/// Will be `None` if RGS isn't configured or the snapshot hasn't been updated yet.
1567
1586
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 > ,
1568
1589
/// The timestamp, in seconds since start of the UNIX epoch, when we last broadcasted a node
1569
1590
/// announcement.
1570
1591
///
@@ -1583,6 +1604,7 @@ pub(crate) struct NodeMetrics {
1583
1604
latest_onchain_wallet_sync_timestamp : Option < u64 > ,
1584
1605
latest_fee_rate_cache_update_timestamp : Option < u64 > ,
1585
1606
latest_rgs_snapshot_timestamp : Option < u32 > ,
1607
+ latest_pathfinding_scores_sync_timestamp : Option < u64 > ,
1586
1608
latest_node_announcement_broadcast_timestamp : Option < u64 > ,
1587
1609
latest_channel_monitor_archival_height : Option < u32 > ,
1588
1610
}
@@ -1594,6 +1616,7 @@ impl Default for NodeMetrics {
1594
1616
latest_onchain_wallet_sync_timestamp : None ,
1595
1617
latest_fee_rate_cache_update_timestamp : None ,
1596
1618
latest_rgs_snapshot_timestamp : None ,
1619
+ latest_pathfinding_scores_sync_timestamp : None ,
1597
1620
latest_node_announcement_broadcast_timestamp : None ,
1598
1621
latest_channel_monitor_archival_height : None ,
1599
1622
}
@@ -1602,6 +1625,7 @@ impl Default for NodeMetrics {
1602
1625
1603
1626
impl_writeable_tlv_based ! ( NodeMetrics , {
1604
1627
( 0 , latest_lightning_wallet_sync_timestamp, option) ,
1628
+ ( 1 , latest_pathfinding_scores_sync_timestamp, option) ,
1605
1629
( 2 , latest_onchain_wallet_sync_timestamp, option) ,
1606
1630
( 4 , latest_fee_rate_cache_update_timestamp, option) ,
1607
1631
( 6 , latest_rgs_snapshot_timestamp, option) ,
0 commit comments