Purge old witnesses

This commit is contained in:
Hanh 2022-11-16 15:44:51 +08:00
parent 4e553b42a6
commit ca7feb3680
2 changed files with 11 additions and 1 deletions

View File

@ -694,6 +694,14 @@ impl DbAdapter {
params![min_height], params![min_height],
)?; )?;
transaction.execute("DELETE FROM blocks WHERE height < ?1", params![min_height])?; transaction.execute("DELETE FROM blocks WHERE height < ?1", params![min_height])?;
transaction.execute(
"DELETE FROM sapling_tree WHERE height < ?1",
params![min_height],
)?;
transaction.execute(
"DELETE FROM orchard_tree WHERE height < ?1",
params![min_height],
)?;
transaction.commit()?; transaction.commit()?;
} }
log::debug!("-purge_old_witnesses"); log::debug!("-purge_old_witnesses");

View File

@ -207,8 +207,9 @@ async fn sync_async_inner<'a>(
} }
} }
let db = db_builder.build()?; let mut db = db_builder.build()?;
db.store_block_timestamp(last_height, &last_hash, last_timestamp)?; db.store_block_timestamp(last_height, &last_hash, last_timestamp)?;
db.purge_old_witnesses(last_height - 500)?;
height = last_height; height = last_height;
let cb = progress_callback.lock().await; let cb = progress_callback.lock().await;
cb(progress.clone()); cb(progress.clone());
@ -219,6 +220,7 @@ async fn sync_async_inner<'a>(
if get_tx { if get_tx {
get_transaction_details(coin).await?; get_transaction_details(coin).await?;
} }
Ok(()) Ok(())
} }