@@ -72,8 +72,10 @@ enum GossipSourceConfig {
72
72
/// [`Node`]: crate::Node
73
73
#[ derive( Debug , Clone ) ]
74
74
pub enum BuildError {
75
- /// The given seed bytes are invalid, e.g, are of invalid length.
75
+ /// The given seed bytes are invalid, e.g., have invalid length.
76
76
InvalidSeedBytes ,
77
+ /// The given seed file is invalid, e.g., has invalid length, or could not be read.
78
+ InvalidSeedFile ,
77
79
/// The current system time is invalid, clocks might have gone backwards.
78
80
InvalidSystemTime ,
79
81
/// We failed to read data from the [`KVStore`].
@@ -92,6 +94,7 @@ impl fmt::Display for BuildError {
92
94
fn fmt ( & self , f : & mut fmt:: Formatter ) -> fmt:: Result {
93
95
match * self {
94
96
Self :: InvalidSeedBytes => write ! ( f, "Given seed bytes are invalid." ) ,
97
+ Self :: InvalidSeedFile => write ! ( f, "Given seed file is invalid or could not be read." ) ,
95
98
Self :: InvalidSystemTime => {
96
99
write ! ( f, "System time is invalid. Clocks might have gone back in time." )
97
100
}
@@ -389,7 +392,8 @@ fn build_with_store_internal<K: KVStore + Sync + Send + 'static>(
389
392
let seed_bytes = match entropy_source_config {
390
393
Some ( EntropySourceConfig :: SeedBytes ( bytes) ) => bytes. clone ( ) ,
391
394
Some ( EntropySourceConfig :: SeedFile ( seed_path) ) => {
392
- io:: utils:: read_or_generate_seed_file ( seed_path)
395
+ io:: utils:: read_or_generate_seed_file ( seed_path, Arc :: clone ( & logger) )
396
+ . map_err ( |_| BuildError :: InvalidSeedFile ) ?
393
397
}
394
398
Some ( EntropySourceConfig :: Bip39Mnemonic { mnemonic, passphrase } ) => match passphrase {
395
399
Some ( passphrase) => mnemonic. to_seed ( passphrase) ,
@@ -398,7 +402,8 @@ fn build_with_store_internal<K: KVStore + Sync + Send + 'static>(
398
402
None => {
399
403
// Default to read or generate from the default location generate a seed file.
400
404
let seed_path = format ! ( "{}/keys_seed" , config. storage_dir_path) ;
401
- io:: utils:: read_or_generate_seed_file ( & seed_path)
405
+ io:: utils:: read_or_generate_seed_file ( & seed_path, Arc :: clone ( & logger) )
406
+ . map_err ( |_| BuildError :: InvalidSeedFile ) ?
402
407
}
403
408
} ;
404
409
0 commit comments