11
11
use core:: ops:: Deref ;
12
12
use bitcoin:: hashes:: hex:: ToHex ;
13
13
use io:: { self } ;
14
+ use routing:: scoring:: WriteableScore ;
14
15
15
16
use crate :: { chain:: { keysinterface:: { Sign , KeysInterface } , self , transaction:: { OutPoint } , chaininterface:: { BroadcasterInterface , FeeEstimator } , chainmonitor:: { Persist , MonitorUpdateId } , channelmonitor:: { ChannelMonitor , ChannelMonitorUpdate } } , ln:: channelmanager:: ChannelManager , routing:: network_graph:: NetworkGraph } ;
16
17
use super :: { logger:: Logger , ser:: Writeable } ;
@@ -24,27 +25,32 @@ pub trait KVStorePersister {
24
25
fn persist < W : Writeable > ( & self , key : & str , object : & W ) -> io:: Result < ( ) > ;
25
26
}
26
27
27
- /// Trait that handles persisting a [`ChannelManager`] and [`NetworkGraph `] to disk.
28
- pub trait Persister < Signer : Sign , M : Deref , T : Deref , K : Deref , F : Deref , L : Deref >
28
+ /// Trait that handles persisting a [`ChannelManager`], [`NetworkGraph`], and [`WriteableScore `] to disk.
29
+ pub trait Persister < ' a , Signer : Sign , M : Deref , T : Deref , K : Deref , F : Deref , L : Deref , S : Deref >
29
30
where M :: Target : ' static + chain:: Watch < Signer > ,
30
31
T :: Target : ' static + BroadcasterInterface ,
31
32
K :: Target : ' static + KeysInterface < Signer = Signer > ,
32
33
F :: Target : ' static + FeeEstimator ,
33
34
L :: Target : ' static + Logger ,
35
+ S :: Target : ' static + WriteableScore < ' a > ,
34
36
{
35
37
/// Persist the given ['ChannelManager'] to disk, returning an error if persistence failed.
36
38
fn persist_manager ( & self , channel_manager : & ChannelManager < Signer , M , T , K , F , L > ) -> Result < ( ) , io:: Error > ;
37
39
38
40
/// Persist the given [`NetworkGraph`] to disk, returning an error if persistence failed.
39
41
fn persist_graph ( & self , network_graph : & NetworkGraph ) -> Result < ( ) , io:: Error > ;
42
+
43
+ /// Persist the given [`WriteableScore`] to disk, returning an error if persistence failed.
44
+ fn persist_scorer ( & self , scorer : & ' a S ) -> Result < ( ) , io:: Error > ;
40
45
}
41
46
42
- impl < A : KVStorePersister , Signer : Sign , M : Deref , T : Deref , K : Deref , F : Deref , L : Deref > Persister < Signer , M , T , K , F , L > for A
47
+ impl < ' a , A : KVStorePersister , Signer : Sign , M : Deref , T : Deref , K : Deref , F : Deref , L : Deref , S : Deref > Persister < ' a , Signer , M , T , K , F , L , S > for A
43
48
where M :: Target : ' static + chain:: Watch < Signer > ,
44
49
T :: Target : ' static + BroadcasterInterface ,
45
50
K :: Target : ' static + KeysInterface < Signer = Signer > ,
46
51
F :: Target : ' static + FeeEstimator ,
47
52
L :: Target : ' static + Logger ,
53
+ S :: Target : ' static + WriteableScore < ' a > ,
48
54
{
49
55
/// Persist the given ['ChannelManager'] to disk, returning an error if persistence failed.
50
56
fn persist_manager ( & self , channel_manager : & ChannelManager < Signer , M , T , K , F , L > ) -> Result < ( ) , io:: Error > {
@@ -55,6 +61,11 @@ impl<A: KVStorePersister, Signer: Sign, M: Deref, T: Deref, K: Deref, F: Deref,
55
61
fn persist_graph ( & self , network_graph : & NetworkGraph ) -> Result < ( ) , io:: Error > {
56
62
self . persist ( "network_graph" , network_graph)
57
63
}
64
+
65
+ /// Persist the given [`WriteableScore`] to disk, returning an error if persistence failed.
66
+ fn persist_scorer ( & self , scorer : & ' a S ) -> Result < ( ) , io:: Error > {
67
+ self . persist ( "scorer" , scorer)
68
+ }
58
69
}
59
70
60
71
impl < ChannelSigner : Sign , K : KVStorePersister > Persist < ChannelSigner > for K {
0 commit comments