Skip to content

Commit

Permalink
fix: fix prune mode (#2952)
Browse files Browse the repository at this point in the history
  • Loading branch information
stringhandler committed Jun 4, 2021
2 parents b6e74bb + 6204d5d commit f7dc3a4
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -406,9 +406,10 @@ impl<'a, B: BlockchainBackend + 'static> HeaderSynchronizer<'a, B> {
for header in headers {
debug!(
target: LOG_TARGET,
"Validating header #{} (Pow: {})",
"Validating header #{} (Pow: {}) with hash: ({})",
header.height,
header.pow_algo(),
header.hash().to_hex(),
);
self.header_validator.validate(header)?;
}
Expand Down Expand Up @@ -510,9 +511,10 @@ impl<'a, B: BlockchainBackend + 'static> HeaderSynchronizer<'a, B> {
let header = BlockHeader::try_from(header?).map_err(BlockHeaderSyncError::ReceivedInvalidHeader)?;
debug!(
target: LOG_TARGET,
"Validating header: #{} (PoW = {})",
"Validating header #{} (Pow: {}) with hash: ({})",
header.height,
header.pow_algo()
header.pow_algo(),
header.hash().to_hex(),
);
let existing_header = self.db.fetch_header_by_block_hash(header.hash()).await?;
// TODO: Due to a bug in a previous version of base node sync RPC, the duplicate headers can be sent. We
Expand Down
9 changes: 6 additions & 3 deletions base_layer/core/src/chain_storage/lmdb_db/lmdb_db.rs
Original file line number Diff line number Diff line change
Expand Up @@ -971,9 +971,12 @@ impl LMDBDatabase {
horizon: u64,
) -> Result<(), ChainStorageError> {
for pos in output_positions {
let (_height, hash) =
lmdb_first_after::<_, (u64, Vec<u8>)>(&write_txn, &self.output_mmr_size_index, &pos.to_be_bytes())
.or_not_found("BlockHeader", "mmr_position", pos.to_string())?;
let (_height, hash) = lmdb_first_after::<_, (u64, Vec<u8>)>(
&write_txn,
&self.output_mmr_size_index,
&(pos as u64).to_be_bytes(),
)
.or_not_found("BlockHeader", "mmr_position", pos.to_string())?;
let key = format!("{}-{:010}", hash.to_hex(), pos);
debug!(target: LOG_TARGET, "Pruning output: {}", key);
self.prune_output(&write_txn, &key)?;
Expand Down

0 comments on commit f7dc3a4

Please sign in to comment.