@@ -72,8 +72,10 @@ enum GossipSourceConfig {
7272/// [`Node`]: crate::Node
7373#[ derive( Debug , Clone ) ]
7474pub 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.
7676 InvalidSeedBytes ,
77+ /// The given seed file is invalid, e.g., has invalid length, or could not be read.
78+ InvalidSeedFile ,
7779 /// The current system time is invalid, clocks might have gone backwards.
7880 InvalidSystemTime ,
7981 /// We failed to read data from the [`KVStore`].
@@ -92,6 +94,7 @@ impl fmt::Display for BuildError {
9294 fn fmt ( & self , f : & mut fmt:: Formatter ) -> fmt:: Result {
9395 match * self {
9496 Self :: InvalidSeedBytes => write ! ( f, "Given seed bytes are invalid." ) ,
97+ Self :: InvalidSeedFile => write ! ( f, "Given seed file is invalid or could not be read." ) ,
9598 Self :: InvalidSystemTime => {
9699 write ! ( f, "System time is invalid. Clocks might have gone back in time." )
97100 }
@@ -389,7 +392,8 @@ fn build_with_store_internal<K: KVStore + Sync + Send + 'static>(
389392 let seed_bytes = match entropy_source_config {
390393 Some ( EntropySourceConfig :: SeedBytes ( bytes) ) => bytes. clone ( ) ,
391394 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 ) ?
393397 }
394398 Some ( EntropySourceConfig :: Bip39Mnemonic { mnemonic, passphrase } ) => match passphrase {
395399 Some ( passphrase) => mnemonic. to_seed ( passphrase) ,
@@ -398,7 +402,8 @@ fn build_with_store_internal<K: KVStore + Sync + Send + 'static>(
398402 None => {
399403 // Default to read or generate from the default location generate a seed file.
400404 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 ) ?
402407 }
403408 } ;
404409
0 commit comments