- #[cfg(test)]
- fn load_channel_data<Keys: KeysInterface>(&self, keys: &Keys) ->
- Result<HashMap<OutPoint, ChannelMonitor<Keys::Signer>>, ChannelMonitorUpdateErr> {
- if let Err(_) = fs::create_dir_all(&self.path_to_channel_data) {
- return Err(ChannelMonitorUpdateErr::PermanentFailure);
+ /// Write the provided `NetworkGraph` to the path provided at `FilesystemPersister`
+ /// initialization, within a file called "network_graph"
+ pub fn persist_network_graph(data_dir: String, network_graph: &NetworkGraph) -> Result<(), std::io::Error> {
+ let path = PathBuf::from(data_dir);
+ util::write_to_file(path, "network_graph".to_string(), network_graph)
+ }
+
+ /// Read `ChannelMonitor`s from disk.
+ pub fn read_channelmonitors<Signer: Sign, K: Deref> (
+ &self, keys_manager: K
+ ) -> Result<Vec<(BlockHash, ChannelMonitor<Signer>)>, std::io::Error>
+ where K::Target: KeysInterface<Signer=Signer> + Sized,
+ {
+ let path = self.path_to_monitor_data();
+ if !Path::new(&path).exists() {
+ return Ok(Vec::new());