we need to be lenient when deleting entries from the output_pos index (may be missing) (#3251)

This commit is contained in:
Antioch Peverell 2020-02-28 12:41:40 +00:00 committed by GitHub
parent 5071084445
commit bcf0e0b4eb
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -1174,8 +1174,19 @@ impl<'a> Extension<'a> {
// Remove any entries from the output_pos created by the block being rewound. // Remove any entries from the output_pos created by the block being rewound.
let block = batch.get_block(&header.hash())?; let block = batch.get_block(&header.hash())?;
let mut missing_count = 0;
for out in block.outputs() { for out in block.outputs() {
batch.delete_output_pos_height(&out.commitment())?; if batch.delete_output_pos_height(&out.commitment()).is_err() {
missing_count += 1;
}
}
if missing_count > 0 {
warn!(
"rewind_single_block: {} output_pos entries missing for: {} at {}",
missing_count,
header.hash(),
header.height,
);
} }
// Update output_pos based on "unspending" all spent pos from this block. // Update output_pos based on "unspending" all spent pos from this block.