@@ -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 ,
@@ -169,6 +172,11 @@ use std::time::{Duration, Instant, SystemTime, UNIX_EPOCH};
169
172
#[ cfg( feature = "uniffi" ) ]
170
173
uniffi:: include_scaffolding!( "ldk_node" ) ;
171
174
175
+ #[ derive( Debug , Clone ) ]
176
+ struct PathfindingScoresSyncConfig {
177
+ url : String ,
178
+ }
179
+
172
180
/// The main interface object of LDK Node, wrapping the necessary LDK and BDK functionalities.
173
181
///
174
182
/// Needs to be initialized and instantiated through [`Builder::build`].
@@ -190,6 +198,7 @@ pub struct Node {
190
198
keys_manager : Arc < KeysManager > ,
191
199
network_graph : Arc < Graph > ,
192
200
gossip_source : Arc < GossipSource > ,
201
+ pathfinding_scores_sync_config : Option < PathfindingScoresSyncConfig > ,
193
202
liquidity_source : Option < Arc < LiquiditySource < Arc < Logger > > > > ,
194
203
kv_store : Arc < DynStore > ,
195
204
logger : Arc < Logger > ,
@@ -304,6 +313,18 @@ impl Node {
304
313
} ) ;
305
314
}
306
315
316
+ if let Some ( pathfinding_scores_sync_config) = self . pathfinding_scores_sync_config . as_ref ( ) {
317
+ setup_background_pathfinding_scores_sync (
318
+ pathfinding_scores_sync_config. url . clone ( ) ,
319
+ self . scorer . clone ( ) ,
320
+ self . node_metrics . clone ( ) ,
321
+ self . kv_store . clone ( ) ,
322
+ self . logger . clone ( ) ,
323
+ & runtime,
324
+ & self . stop_sender ,
325
+ ) ;
326
+ }
327
+
307
328
if let Some ( listening_addresses) = & self . config . listening_addresses {
308
329
// Setup networking
309
330
let peer_manager_connection_handler = Arc :: clone ( & self . peer_manager ) ;
@@ -725,6 +746,8 @@ impl Node {
725
746
locked_node_metrics. latest_fee_rate_cache_update_timestamp ;
726
747
let latest_rgs_snapshot_timestamp =
727
748
locked_node_metrics. latest_rgs_snapshot_timestamp . map ( |val| val as u64 ) ;
749
+ let latest_pathfinding_scores_sync_timestamp =
750
+ locked_node_metrics. latest_pathfinding_scores_sync_timestamp ;
728
751
let latest_node_announcement_broadcast_timestamp =
729
752
locked_node_metrics. latest_node_announcement_broadcast_timestamp ;
730
753
let latest_channel_monitor_archival_height =
@@ -738,6 +761,7 @@ impl Node {
738
761
latest_onchain_wallet_sync_timestamp,
739
762
latest_fee_rate_cache_update_timestamp,
740
763
latest_rgs_snapshot_timestamp,
764
+ latest_pathfinding_scores_sync_timestamp,
741
765
latest_node_announcement_broadcast_timestamp,
742
766
latest_channel_monitor_archival_height,
743
767
}
@@ -1547,6 +1571,8 @@ pub struct NodeStatus {
1547
1571
///
1548
1572
/// Will be `None` if RGS isn't configured or the snapshot hasn't been updated yet.
1549
1573
pub latest_rgs_snapshot_timestamp : Option < u64 > ,
1574
+ /// The timestamp, in seconds since start of the UNIX epoch, when we last successfully merged external scores.
1575
+ pub latest_pathfinding_scores_sync_timestamp : Option < u64 > ,
1550
1576
/// The timestamp, in seconds since start of the UNIX epoch, when we last broadcasted a node
1551
1577
/// announcement.
1552
1578
///
@@ -1565,6 +1591,7 @@ pub(crate) struct NodeMetrics {
1565
1591
latest_onchain_wallet_sync_timestamp : Option < u64 > ,
1566
1592
latest_fee_rate_cache_update_timestamp : Option < u64 > ,
1567
1593
latest_rgs_snapshot_timestamp : Option < u32 > ,
1594
+ latest_pathfinding_scores_sync_timestamp : Option < u64 > ,
1568
1595
latest_node_announcement_broadcast_timestamp : Option < u64 > ,
1569
1596
latest_channel_monitor_archival_height : Option < u32 > ,
1570
1597
}
@@ -1576,6 +1603,7 @@ impl Default for NodeMetrics {
1576
1603
latest_onchain_wallet_sync_timestamp : None ,
1577
1604
latest_fee_rate_cache_update_timestamp : None ,
1578
1605
latest_rgs_snapshot_timestamp : None ,
1606
+ latest_pathfinding_scores_sync_timestamp : None ,
1579
1607
latest_node_announcement_broadcast_timestamp : None ,
1580
1608
latest_channel_monitor_archival_height : None ,
1581
1609
}
@@ -1584,6 +1612,7 @@ impl Default for NodeMetrics {
1584
1612
1585
1613
impl_writeable_tlv_based ! ( NodeMetrics , {
1586
1614
( 0 , latest_lightning_wallet_sync_timestamp, option) ,
1615
+ ( 1 , latest_pathfinding_scores_sync_timestamp, option) ,
1587
1616
( 2 , latest_onchain_wallet_sync_timestamp, option) ,
1588
1617
( 4 , latest_fee_rate_cache_update_timestamp, option) ,
1589
1618
( 6 , latest_rgs_snapshot_timestamp, option) ,
0 commit comments