@@ -3,15 +3,12 @@ use crate::{Config, FilesystemLogger, NetworkGraph, Scorer, WALLET_KEYS_SEED_LEN
33
44use lightning:: routing:: scoring:: { ProbabilisticScorer , ProbabilisticScoringParameters } ;
55use lightning:: util:: ser:: { Readable , ReadableArgs } ;
6- use lightning_persister:: FilesystemPersister ;
76
87use rand:: { thread_rng, RngCore } ;
98
109use std:: fs;
1110use std:: io:: { BufReader , Write } ;
12- use std:: os:: unix:: io:: AsRawFd ;
1311use std:: path:: Path ;
14- use std:: path:: PathBuf ;
1512use std:: sync:: Arc ;
1613
1714pub ( crate ) fn read_or_generate_seed_file ( keys_seed_path : & str ) -> [ u8 ; WALLET_KEYS_SEED_LEN ] {
@@ -86,43 +83,3 @@ pub(crate) fn read_payment_info(config: &Config) -> Vec<PaymentInfo> {
8683
8784 payments
8885}
89-
90- /// Provides an interface that allows a previously persisted key to be unpersisted.
91- pub trait KVStoreUnpersister {
92- /// Unpersist (i.e., remove) the writeable previously persisted under the provided key.
93- /// Returns `true` if the key was present, and `false` otherwise.
94- fn unpersist ( & self , key : & str ) -> std:: io:: Result < bool > ;
95- }
96-
97- impl KVStoreUnpersister for FilesystemPersister {
98- fn unpersist ( & self , key : & str ) -> std:: io:: Result < bool > {
99- let mut dest_file = PathBuf :: from ( self . get_data_dir ( ) ) ;
100- dest_file. push ( key) ;
101-
102- if !dest_file. is_file ( ) {
103- return Ok ( false ) ;
104- }
105-
106- fs:: remove_file ( & dest_file) ?;
107- #[ cfg( not( target_os = "windows" ) ) ]
108- {
109- let parent_directory = dest_file. parent ( ) . unwrap ( ) ;
110- let dir_file = fs:: OpenOptions :: new ( ) . read ( true ) . open ( parent_directory) ?;
111- unsafe {
112- // The above call to `fs::remove_file` corresponds to POSIX `unlink`, whose changes
113- // to the inode might get cached (and hence possibly lost on crash), depending on
114- // the target platform and file system.
115- //
116- // In order to assert we permanently removed the file in question we therefore
117- // call `fsync` on the parent directory on platforms that support it,
118- libc:: fsync ( dir_file. as_raw_fd ( ) ) ;
119- }
120- }
121-
122- if dest_file. is_file ( ) {
123- return Err ( std:: io:: Error :: new ( std:: io:: ErrorKind :: Other , "Unpersisting key failed" ) ) ;
124- }
125-
126- return Ok ( true ) ;
127- }
128- }
0 commit comments