From 193e82289fd975c072ec252d29865b7bb679b249 Mon Sep 17 00:00:00 2001 From: Michael Sproul Date: Wed, 30 Sep 2020 14:35:26 +1000 Subject: [PATCH] Allow truncation of pubkey cache on creation Closes #1680 --- beacon_node/beacon_chain/src/validator_pubkey_cache.rs | 10 ++-------- 1 file changed, 2 insertions(+), 8 deletions(-) diff --git a/beacon_node/beacon_chain/src/validator_pubkey_cache.rs b/beacon_node/beacon_chain/src/validator_pubkey_cache.rs index 02d35acaa82..48ec5d1b2bb 100644 --- a/beacon_node/beacon_chain/src/validator_pubkey_cache.rs +++ b/beacon_node/beacon_chain/src/validator_pubkey_cache.rs @@ -39,13 +39,6 @@ impl ValidatorPubkeyCache { state: &BeaconState, persistence_path: P, ) -> Result { - if persistence_path.as_ref().exists() { - return Err(BeaconChainError::ValidatorPubkeyCacheFileError(format!( - "Persistence file already exists: {:?}", - persistence_path.as_ref() - ))); - } - let mut cache = Self { persitence_file: ValidatorPubkeyCacheFile::create(persistence_path)?, pubkeys: vec![], @@ -159,8 +152,9 @@ impl ValidatorPubkeyCacheFile { /// Creates a file for reading and writing. pub fn create>(path: P) -> Result { OpenOptions::new() - .create_new(true) + .create(true) .write(true) + .truncate(true) .open(path) .map(Self) .map_err(Error::Io)