mirror of
https://github.com/logos-blockchain/lssa.git
synced 2026-01-03 13:53:12 +00:00
add destroy to nodeblockstore as well
This commit is contained in:
parent
84c7eaf1d0
commit
c8b1ce56d8
@ -1,6 +1,6 @@
|
||||
use std::path::Path;
|
||||
|
||||
use anyhow::Result;
|
||||
use anyhow::{Result, anyhow};
|
||||
use storage::{block::Block, RocksDBIO};
|
||||
|
||||
pub struct NodeBlockStore {
|
||||
@ -20,14 +20,20 @@ impl NodeBlockStore {
|
||||
|
||||
///Reopening existing database
|
||||
pub fn open_db_restart(location: &Path) -> Result<Self> {
|
||||
NodeBlockStore::db_destroy(location)?;
|
||||
NodeBlockStore::open_db_with_genesis(location, None)
|
||||
}
|
||||
|
||||
///Destroying existing database
|
||||
fn db_destroy(location: &Path) -> Result<()> {
|
||||
RocksDBIO::destroy(location).map_err(|err| anyhow!("RocksDBIO error: {}", err))
|
||||
}
|
||||
|
||||
pub fn get_block_at_id(&self, id: u64) -> Result<Block> {
|
||||
Ok(self.dbio.get_block(id)?)
|
||||
}
|
||||
|
||||
pub fn put_block_at_id(&self, block: Block) -> Result<()> {
|
||||
Ok(self.dbio.put_block(block)?)
|
||||
Ok(self.dbio.put_block(block, false)?)
|
||||
}
|
||||
}
|
||||
|
||||
@ -196,10 +196,10 @@ impl RocksDBIO {
|
||||
let cf_block = self.block_column();
|
||||
|
||||
if !first {
|
||||
let last_curr_block = self.get_meta_last_block_in_db()?;
|
||||
let last_curr_block = self.get_meta_last_block_in_db()?;
|
||||
|
||||
if block.block_id > last_curr_block {
|
||||
self.put_meta_last_block_in_db(block.block_id)?;
|
||||
if block.block_id > last_curr_block {
|
||||
self.put_meta_last_block_in_db(block.block_id)?;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user