mirror of
https://github.com/bitcoinresearchkit/brk.git
synced 2026-07-29 19:58:10 -07:00
parser: reactivate 'first_defragment' option
This commit is contained in:
@@ -32,11 +32,9 @@ pub fn iter_blocks(
|
|||||||
let mut databases = Databases::import();
|
let mut databases = Databases::import();
|
||||||
|
|
||||||
if config.first_defragment() {
|
if config.first_defragment() {
|
||||||
|
exit.block();
|
||||||
databases.defragment();
|
databases.defragment();
|
||||||
|
exit.unblock();
|
||||||
if true {
|
|
||||||
panic!("Done");
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
log("Imported databases");
|
log("Imported databases");
|
||||||
|
|||||||
@@ -49,7 +49,13 @@ where
|
|||||||
Value: Storable + PartialEq,
|
Value: Storable + PartialEq,
|
||||||
{
|
{
|
||||||
pub fn open(folder: &str, file: &str) -> color_eyre::Result<Self> {
|
pub fn open(folder: &str, file: &str) -> color_eyre::Result<Self> {
|
||||||
let mut txn = Self::init_txn(folder, file)?;
|
let path = databases_folder_path(folder);
|
||||||
|
fs::create_dir_all(&path)?;
|
||||||
|
|
||||||
|
let path = format!("{path}/{file}");
|
||||||
|
let env = unsafe { Env::new_nolock(path, PAGE_SIZE, 1).unwrap() };
|
||||||
|
|
||||||
|
let mut txn = Env::mut_txn_begin(env)?;
|
||||||
|
|
||||||
let db = txn
|
let db = txn
|
||||||
.root_db(ROOT_DB)
|
.root_db(ROOT_DB)
|
||||||
@@ -169,18 +175,6 @@ where
|
|||||||
format!("{}/{}", databases_folder_path(&self.folder), self.file)
|
format!("{}/{}", databases_folder_path(&self.folder), self.file)
|
||||||
}
|
}
|
||||||
|
|
||||||
fn init_txn(folder: &str, file: &str) -> color_eyre::Result<MutTxn<Env, ()>> {
|
|
||||||
let path = databases_folder_path(folder);
|
|
||||||
|
|
||||||
fs::create_dir_all(&path)?;
|
|
||||||
|
|
||||||
let env = unsafe { Env::new_nolock(format!("{path}/{file}"), PAGE_SIZE, 1).unwrap() };
|
|
||||||
|
|
||||||
let txn = Env::mut_txn_begin(env)?;
|
|
||||||
|
|
||||||
Ok(txn)
|
|
||||||
}
|
|
||||||
|
|
||||||
fn db_multi_put(&mut self, tree: BTreeMap<Key, Value>) -> Result<(), Error> {
|
fn db_multi_put(&mut self, tree: BTreeMap<Key, Value>) -> Result<(), Error> {
|
||||||
tree.into_iter()
|
tree.into_iter()
|
||||||
.try_for_each(|(key, value)| -> Result<(), Error> {
|
.try_for_each(|(key, value)| -> Result<(), Error> {
|
||||||
@@ -244,10 +238,12 @@ where
|
|||||||
|
|
||||||
let mut s = Self::open(&folder, &file).unwrap();
|
let mut s = Self::open(&folder, &file).unwrap();
|
||||||
|
|
||||||
if s.is_empty() {
|
if !s.is_empty() {
|
||||||
s.cached_puts = btree;
|
panic!()
|
||||||
s.export().unwrap();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
s.cached_puts = btree;
|
||||||
|
s.export().unwrap();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -103,39 +103,27 @@ impl Databases {
|
|||||||
fn open_all(&mut self) {
|
fn open_all(&mut self) {
|
||||||
thread::scope(|s| {
|
thread::scope(|s| {
|
||||||
s.spawn(|| {
|
s.spawn(|| {
|
||||||
time("Opening all address_index_to_address_data", || {
|
self.address_index_to_address_data.open_all();
|
||||||
self.address_index_to_address_data.open_all()
|
|
||||||
})
|
|
||||||
});
|
});
|
||||||
|
|
||||||
s.spawn(|| {
|
s.spawn(|| {
|
||||||
time("Opening all address_index_to_empty_address_data", || {
|
self.address_index_to_empty_address_data.open_all();
|
||||||
self.address_index_to_empty_address_data.open_all()
|
|
||||||
})
|
|
||||||
});
|
});
|
||||||
|
|
||||||
s.spawn(|| {
|
s.spawn(|| {
|
||||||
time("Opening all address_to_address_index", || {
|
self.address_to_address_index.open_all();
|
||||||
self.address_to_address_index.open_all()
|
|
||||||
})
|
|
||||||
});
|
});
|
||||||
|
|
||||||
s.spawn(|| {
|
s.spawn(|| {
|
||||||
time("Opening all txid_to_tx_data", || {
|
self.txid_to_tx_data.open_all();
|
||||||
self.txid_to_tx_data.open_all()
|
|
||||||
})
|
|
||||||
});
|
});
|
||||||
|
|
||||||
s.spawn(|| {
|
s.spawn(|| {
|
||||||
time("Opening all txout_index_to_address_index", || {
|
self.txout_index_to_address_index.open_all();
|
||||||
self.txout_index_to_address_index.open_all()
|
|
||||||
})
|
|
||||||
});
|
});
|
||||||
|
|
||||||
s.spawn(|| {
|
s.spawn(|| {
|
||||||
time("Opening all txout_index_to_amount", || {
|
self.txout_index_to_amount.open_all();
|
||||||
self.txout_index_to_amount.open_all()
|
|
||||||
})
|
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -169,8 +169,6 @@ impl Config {
|
|||||||
}
|
}
|
||||||
|
|
||||||
pub fn first_defragment(&self) -> bool {
|
pub fn first_defragment(&self) -> bool {
|
||||||
log("Buggy for now, skipped");
|
self.first_defragment.is_some_and(|b| b)
|
||||||
false
|
|
||||||
// self.first_defragment.is_some_and(|b| b)
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user