kibo: part 2 (broken)

This commit is contained in:
nym21
2025-03-25 20:55:47 +01:00
parent 7a8896864f
commit 50bf670931
126 changed files with 7131 additions and 2758 deletions

View File

@@ -17,9 +17,15 @@
<a href="https://deps.rs/crate/brk_indexer">
<img src="https://deps.rs/crate/brk_indexer/latest/status.svg" alt="Dependency status">
</a>
<a href="https://discord.gg/EScZAYX4">
<a href="https://discord.gg/Cvrwpv3zEG">
<img src="https://img.shields.io/discord/1350431684562124850" alt="Chat" />
</a>
<a href="https://primal.net/p/nprofile1qqsfw5dacngjlahye34krvgz7u0yghhjgk7gxzl5ptm9v6n2y3sn03sqxu2e6">
<img src="https://img.shields.io/badge/nostr-purple?link=https%3A%2F%2Fprimal.net%2Fp%2Fnprofile1qqsfw5dacngjlahye34krvgz7u0yghhjgk7gxzl5ptm9v6n2y3sn03sqxu2e6" alt="Nostr" />
</a>
<a href="https://bsky.app/profile/bitcoinresearchkit.org">
<img src="https://img.shields.io/badge/bluesky-blue?link=https%3A%2F%2Fbsky.app%2Fprofile%2Fbitcoinresearchkit.org" alt="Bluesky" />
</a>
</p>
A [Bitcoin Core](https://bitcoincore.org/en/about/) node indexer which iterates over the chain (via `../brk_parser`) and creates a database of the vecs (`brk_vec`) and key/value stores ([`fjall`](https://crates.io/crates/fjall)) that can be used in your Rust code.

View File

@@ -10,7 +10,8 @@ use brk_core::Height;
use brk_vec::{Value, Version};
use byteview::ByteView;
use fjall::{
PartitionCreateOptions, PersistMode, ReadTransaction, Result, TransactionalKeyspace, TransactionalPartitionHandle,
PartitionCreateOptions, PersistMode, ReadTransaction, Result, TransactionalKeyspace,
TransactionalPartitionHandle,
};
use zerocopy::{Immutable, IntoBytes};
@@ -71,7 +72,7 @@ where
if let Some(v) = self.puts.get(key) {
Ok(Some(Value::Ref(v)))
} else if let Some(slice) = self.rtx.get(&self.part, key.as_bytes())? {
Ok(Some(Value::Owned(V::try_from(slice.into())?)))
Ok(Some(Value::Owned(V::try_from(slice.as_bytes().into())?)))
} else {
Ok(None)
}
@@ -109,23 +110,29 @@ where
mem::take(&mut self.dels)
.into_iter()
.for_each(|key| wtx.remove(&self.part, key.into()));
.for_each(|key| wtx.remove(&self.part, key.as_bytes()));
mem::take(&mut self.puts).into_iter().for_each(|(key, value)| {
if CHECK_COLLISISONS {
#[allow(unused_must_use)]
if let Ok(Some(value)) = wtx.get(&self.part, key.as_bytes()) {
dbg!(
&key,
V::try_from(value.into()).unwrap(),
&self.meta,
self.rtx.get(&self.part, key.as_bytes())
);
unreachable!();
mem::take(&mut self.puts)
.into_iter()
.for_each(|(key, value)| {
if CHECK_COLLISISONS {
#[allow(unused_must_use)]
if let Ok(Some(value)) = wtx.get(&self.part, key.as_bytes()) {
dbg!(
&key,
V::try_from(value.as_bytes().into()).unwrap(),
&self.meta,
self.rtx.get(&self.part, key.as_bytes())
);
unreachable!();
}
}
}
wtx.insert(&self.part, key.into(), value.into())
});
wtx.insert(
&self.part,
key.as_bytes(),
&*ByteView::try_from(value).unwrap(),
)
});
wtx.commit()?;
@@ -164,7 +171,9 @@ where
.open_transactional()
}
fn open_partition_handle(keyspace: &TransactionalKeyspace) -> Result<TransactionalPartitionHandle> {
fn open_partition_handle(
keyspace: &TransactionalKeyspace,
) -> Result<TransactionalPartitionHandle> {
keyspace.open_partition(
"partition",
PartitionCreateOptions::default()