fix: check checkpoint file exists (#183)

This commit is contained in:
Noah Citron 2023-01-31 14:18:51 -05:00 committed by GitHub
parent 72267b4563
commit 5b9e90436a
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 13 additions and 13 deletions

14
Cargo.lock generated
View File

@ -525,7 +525,7 @@ dependencies = [
[[package]] [[package]]
name = "cli" name = "cli"
version = "0.1.3" version = "0.2.0"
dependencies = [ dependencies = [
"clap", "clap",
"client", "client",
@ -542,7 +542,7 @@ dependencies = [
[[package]] [[package]]
name = "client" name = "client"
version = "0.1.3" version = "0.2.0"
dependencies = [ dependencies = [
"common", "common",
"config", "config",
@ -646,7 +646,7 @@ checksum = "3d7b894f5411737b7867f4827955924d7c254fc9f4d91a6aad6b097804b1018b"
[[package]] [[package]]
name = "common" name = "common"
version = "0.1.3" version = "0.2.0"
dependencies = [ dependencies = [
"ethers", "ethers",
"eyre", "eyre",
@ -658,7 +658,7 @@ dependencies = [
[[package]] [[package]]
name = "config" name = "config"
version = "0.1.3" version = "0.2.0"
dependencies = [ dependencies = [
"common", "common",
"ethers", "ethers",
@ -678,7 +678,7 @@ dependencies = [
[[package]] [[package]]
name = "consensus" name = "consensus"
version = "0.1.3" version = "0.2.0"
dependencies = [ dependencies = [
"async-trait", "async-trait",
"bytes", "bytes",
@ -1451,7 +1451,7 @@ checksum = "0206175f82b8d6bf6652ff7d71a1e27fd2e4efde587fd368662814d6ec1d9ce0"
[[package]] [[package]]
name = "execution" name = "execution"
version = "0.1.3" version = "0.2.0"
dependencies = [ dependencies = [
"async-trait", "async-trait",
"bytes", "bytes",
@ -1964,7 +1964,7 @@ checksum = "2540771e65fc8cb83cd6e8a237f70c319bd5c29f78ed1084ba5d50eeac86f7f9"
[[package]] [[package]]
name = "helios" name = "helios"
version = "0.1.3" version = "0.2.0"
dependencies = [ dependencies = [
"client", "client",
"common", "common",

View File

@ -50,14 +50,14 @@ impl Database for FileDB {
} }
fn load_checkpoint(&self) -> Result<Vec<u8>> { fn load_checkpoint(&self) -> Result<Vec<u8>> {
let mut f = fs::OpenOptions::new()
.read(true)
.open(self.data_dir.join("checkpoint"))?;
let mut buf = Vec::new(); let mut buf = Vec::new();
f.read_to_end(&mut buf)?;
if buf.len() == 32 { let res = fs::OpenOptions::new()
.read(true)
.open(self.data_dir.join("checkpoint"))
.map(|mut f| f.read_to_end(&mut buf));
if buf.len() == 32 && res.is_ok() {
Ok(buf) Ok(buf)
} else { } else {
Ok(self.default_checkpoint.clone()) Ok(self.default_checkpoint.clone())