Skip to content

Commit

Permalink
Allow truncation of pubkey cache on creation
Browse files Browse the repository at this point in the history
Closes #1680
  • Loading branch information
michaelsproul committed Sep 29, 2020
1 parent 7bf1490 commit a327468
Showing 1 changed file with 2 additions and 8 deletions.
10 changes: 2 additions & 8 deletions beacon_node/beacon_chain/src/validator_pubkey_cache.rs
Original file line number Diff line number Diff line change
Expand Up @@ -39,13 +39,6 @@ impl ValidatorPubkeyCache {
state: &BeaconState<T>,
persistence_path: P,
) -> Result<Self, BeaconChainError> {
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![],
Expand Down Expand Up @@ -159,8 +152,9 @@ impl ValidatorPubkeyCacheFile {
/// Creates a file for reading and writing.
pub fn create<P: AsRef<Path>>(path: P) -> Result<Self, Error> {
OpenOptions::new()
.create_new(true)
.create(true)
.write(true)
.truncate(true)
.open(path)
.map(Self)
.map_err(Error::Io)
Expand Down

0 comments on commit a327468

Please sign in to comment.