@@ -100,6 +100,8 @@ pub trait Persister<'a, M: Deref, T: Deref, ES: Deref, NS: Deref, SP: Deref, F:
100
100
}
101
101
102
102
103
+ impl < ' a , A : KVStore , M : Deref , T : Deref , ES : Deref , NS : Deref , SP : Deref , F : Deref , R : Deref , L : Deref , S : WriteableScore < ' a > > Persister < ' a , M , T , ES , NS , SP , F , R , L , S > for A
104
+
103
105
impl < ' a , A : KVStore , M : Deref , T : Deref , ES : Deref , NS : Deref , SP : Deref , F : Deref , R : Deref , L : Deref , S : WriteableScore < ' a > > Persister < ' a , M , T , ES , NS , SP , F , R , L , S > for A
104
106
where M :: Target : ' static + chain:: Watch < <SP :: Target as SignerProvider >:: Signer > ,
105
107
T :: Target : ' static + BroadcasterInterface ,
@@ -110,29 +112,38 @@ impl<'a, A: KVStore, M: Deref, T: Deref, ES: Deref, NS: Deref, SP: Deref, F: Der
110
112
R :: Target : ' static + Router ,
111
113
L :: Target : ' static + Logger ,
112
114
{
115
+ /// Persist the given ['ChannelManager'] to disk, returning an error if persistence failed.
113
116
/// Persist the given ['ChannelManager'] to disk, returning an error if persistence failed.
114
117
fn persist_manager ( & self , channel_manager : & ChannelManager < M , T , ES , NS , SP , F , R , L > ) -> Result < ( ) , io:: Error > {
115
118
self . write ( CHANNEL_MANAGER_PERSISTENCE_NAMESPACE , CHANNEL_MANAGER_PERSISTENCE_KEY , & channel_manager. encode ( ) )
119
+ self. write ( CHANNEL_MANAGER_PERSISTENCE_NAMESPACE , CHANNEL_MANAGER_PERSISTENCE_KEY , & channel_manager. encode ( ) )
116
120
}
117
121
122
+ /// Persist the given [`NetworkGraph`] to disk, returning an error if persistence failed.
118
123
/// Persist the given [`NetworkGraph`] to disk, returning an error if persistence failed.
119
124
fn persist_graph ( & self , network_graph : & NetworkGraph < L > ) -> Result < ( ) , io:: Error > {
120
125
self . write ( NETWORK_GRAPH_PERSISTENCE_NAMESPACE , NETWORK_GRAPH_PERSISTENCE_KEY , & network_graph. encode ( ) )
126
+ self. write ( NETWORK_GRAPH_PERSISTENCE_NAMESPACE , NETWORK_GRAPH_PERSISTENCE_KEY , & network_graph. encode ( ) )
121
127
}
122
128
129
+ /// Persist the given [`WriteableScore`] to disk, returning an error if persistence failed.
123
130
/// Persist the given [`WriteableScore`] to disk, returning an error if persistence failed.
124
131
fn persist_scorer ( & self , scorer : & S ) -> Result < ( ) , io:: Error > {
125
132
self . write ( SCORER_PERSISTENCE_NAMESPACE , SCORER_PERSISTENCE_KEY , & scorer. encode ( ) )
133
+ self. write ( SCORER_PERSISTENCE_NAMESPACE , SCORER_PERSISTENCE_KEY , & scorer. encode ( ) )
126
134
}
127
135
}
128
136
137
+ impl < ChannelSigner : WriteableEcdsaChannelSigner , K : KVStore > Persist < ChannelSigner > for K {
129
138
impl < ChannelSigner : WriteableEcdsaChannelSigner , K : KVStore > Persist < ChannelSigner > for K {
130
139
// TODO: We really need a way for the persister to inform the user that its time to crash/shut
131
140
// down once these start returning failure.
132
141
// A PermanentFailure implies we should probably just shut down the node since we're
133
142
// force-closing channels without even broadcasting!
134
143
135
144
fn persist_new_channel ( & self , funding_txo : OutPoint , monitor : & ChannelMonitor < ChannelSigner > , _update_id : MonitorUpdateId ) -> chain:: ChannelMonitorUpdateStatus {
145
+ let key = format ! ( "{}_{}" , funding_txo. txid. to_hex( ) , funding_txo. index) ;
146
+ match self . write ( CHANNEL_MONITOR_PERSISTENCE_NAMESPACE , & key, & monitor. encode ( ) ) {
136
147
let key = format ! ( "{}_{}" , funding_txo. txid. to_hex( ) , funding_txo. index) ;
137
148
match self . write( CHANNEL_MONITOR_PERSISTENCE_NAMESPACE , & key, & monitor. encode( ) ) {
138
149
Ok ( ( ) ) => chain:: ChannelMonitorUpdateStatus :: Completed ,
@@ -141,6 +152,8 @@ impl<ChannelSigner: WriteableEcdsaChannelSigner, K: KVStore> Persist<ChannelSign
141
152
}
142
153
143
154
fn update_persisted_channel ( & self , funding_txo : OutPoint , _update : Option < & ChannelMonitorUpdate > , monitor : & ChannelMonitor < ChannelSigner > , _update_id : MonitorUpdateId ) -> chain:: ChannelMonitorUpdateStatus {
155
+ let key = format ! ( "{}_{}" , funding_txo. txid. to_hex( ) , funding_txo. index) ;
156
+ match self . write ( CHANNEL_MONITOR_PERSISTENCE_NAMESPACE , & key, & monitor. encode ( ) ) {
144
157
let key = format ! ( "{}_{}" , funding_txo. txid. to_hex( ) , funding_txo. index) ;
145
158
match self . write( CHANNEL_MONITOR_PERSISTENCE_NAMESPACE , & key, & monitor. encode( ) ) {
146
159
Ok ( ( ) ) => chain:: ChannelMonitorUpdateStatus :: Completed ,
0 commit comments