Skip to content

Commit 3fdc60f

Browse files
authored
Fix unchecked optional access and sha of snapshot (#7338)
1 parent b3d9943 commit 3fdc60f

File tree

1 file changed

+4
-8
lines changed

1 file changed

+4
-8
lines changed

src/host/main.cpp

Lines changed: 4 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -859,12 +859,6 @@ int main(int argc, char** argv) // NOLINT(bugprone-exception-escape)
859859
config.command.type == StartType::Recover)
860860
{
861861
auto latest_local_snapshot = snapshots.find_latest_committed_snapshot();
862-
auto sha = ccf::crypto::Sha256Hash(startup_snapshot);
863-
LOG_INFO_FMT(
864-
"Found latest snapshot file: {} (size: {}, sha256: {})",
865-
latest_local_snapshot->first / latest_local_snapshot->second,
866-
startup_snapshot.size(),
867-
sha.hex_str());
868862

869863
if (
870864
config.command.type == StartType::Join &&
@@ -915,10 +909,12 @@ int main(int argc, char** argv) // NOLINT(bugprone-exception-escape)
915909
auto& [snapshot_dir, snapshot_file] = latest_local_snapshot.value();
916910
startup_snapshot = files::slurp(snapshot_dir / snapshot_file);
917911

912+
auto sha = ccf::crypto::Sha256Hash(startup_snapshot);
918913
LOG_INFO_FMT(
919-
"Found latest local snapshot file: {} (size: {})",
914+
"Found latest snapshot file: {} (size: {}, sha256: {})",
920915
snapshot_dir / snapshot_file,
921-
startup_snapshot.size());
916+
startup_snapshot.size(),
917+
sha.hex_str());
922918
}
923919
else
924920
{

0 commit comments

Comments
 (0)