mirror of
https://github.com/bitcoinresearchkit/brk.git
synced 2026-04-24 06:39:58 -07:00
core: init
This commit is contained in:
@@ -1,18 +1,14 @@
|
||||
[package]
|
||||
name = "brk_computer"
|
||||
description = "A Bitcoin dataset computer built on top of brk_indexer and brk_fetcher"
|
||||
description = "A Bitcoin dataset computer, built on top of brk_indexer"
|
||||
version = { workspace = true }
|
||||
edition = { workspace = true }
|
||||
license = { workspace = true }
|
||||
|
||||
[dependencies]
|
||||
brk_fetcher = { workspace = true }
|
||||
brk_core = { workspace = true }
|
||||
brk_indexer = { workspace = true }
|
||||
brk_parser = { workspace = true }
|
||||
byteview = { workspace = true }
|
||||
color-eyre = { workspace = true }
|
||||
derive_deref = { workspace = true }
|
||||
fjall = { workspace = true }
|
||||
hodor = { workspace = true }
|
||||
storable_vec = { workspace = true }
|
||||
zerocopy = { workspace = true }
|
||||
|
||||
@@ -5,12 +5,10 @@ pub use brk_parser::rpc;
|
||||
use hodor::Exit;
|
||||
|
||||
mod storage;
|
||||
mod structs;
|
||||
|
||||
use brk_fetcher::Date;
|
||||
use brk_core::Date;
|
||||
use storable_vec::SINGLE_THREAD;
|
||||
use storage::{Fjalls, StorableVecs};
|
||||
pub use structs::*;
|
||||
|
||||
pub struct Computer<const MODE: u8> {
|
||||
path: PathBuf,
|
||||
|
||||
@@ -4,8 +4,6 @@ use brk_computer::Computer;
|
||||
use brk_indexer::Indexer;
|
||||
use hodor::Exit;
|
||||
|
||||
mod structs;
|
||||
|
||||
pub fn main() -> color_eyre::Result<()> {
|
||||
color_eyre::install()?;
|
||||
|
||||
|
||||
@@ -1,10 +1,9 @@
|
||||
use std::path::Path;
|
||||
|
||||
use brk_core::{AddressindexTxoutindex, Unit};
|
||||
use brk_indexer::Store;
|
||||
use storable_vec::Version;
|
||||
|
||||
use crate::structs::{AddressindexTxoutindex, Unit};
|
||||
|
||||
pub struct Fjalls {
|
||||
pub address_to_utxos_received: Store<AddressindexTxoutindex, Unit>,
|
||||
pub address_to_utxos_spent: Store<AddressindexTxoutindex, Unit>,
|
||||
|
||||
@@ -1,11 +1,8 @@
|
||||
use std::{fs, path::Path};
|
||||
|
||||
use brk_fetcher::{Date, Dateindex};
|
||||
use brk_indexer::{Addressindex, Height, Sats, Timestamp, Txindex, Txinindex, Txoutindex};
|
||||
use brk_core::{Addressindex, Date, Dateindex, Feerate, Height, Sats, Timestamp, Txindex, Txinindex, Txoutindex};
|
||||
use storable_vec::{StorableVec, Version};
|
||||
|
||||
use crate::structs::Feerate;
|
||||
|
||||
// mod base;
|
||||
|
||||
// use base::*;
|
||||
|
||||
@@ -1,22 +0,0 @@
|
||||
use brk_indexer::{Addressindex, Txoutindex};
|
||||
use byteview::ByteView;
|
||||
use zerocopy::{FromBytes, Immutable, IntoBytes, KnownLayout};
|
||||
|
||||
#[derive(Debug, Clone, Copy, PartialEq, Eq, PartialOrd, Ord, Immutable, IntoBytes, KnownLayout, FromBytes)]
|
||||
pub struct AddressindexTxoutindex {
|
||||
addressindex: Addressindex,
|
||||
_padding: u32,
|
||||
txoutindex: Txoutindex,
|
||||
}
|
||||
|
||||
impl TryFrom<ByteView> for AddressindexTxoutindex {
|
||||
type Error = storable_vec::Error;
|
||||
fn try_from(value: ByteView) -> Result<Self, Self::Error> {
|
||||
Ok(Self::read_from_bytes(&value)?)
|
||||
}
|
||||
}
|
||||
impl From<AddressindexTxoutindex> for ByteView {
|
||||
fn from(value: AddressindexTxoutindex) -> Self {
|
||||
Self::new(value.as_bytes())
|
||||
}
|
||||
}
|
||||
@@ -1,14 +0,0 @@
|
||||
use brk_indexer::Sats;
|
||||
|
||||
#[derive(Debug, Default, Clone, Copy)]
|
||||
pub struct Bitcoin(f64);
|
||||
|
||||
impl Bitcoin {
|
||||
const ONE: Self = Self(100_000_000.0);
|
||||
}
|
||||
|
||||
impl From<Sats> for Bitcoin {
|
||||
fn from(value: Sats) -> Self {
|
||||
Self((*value as f64) / Self::ONE.0)
|
||||
}
|
||||
}
|
||||
@@ -1,4 +0,0 @@
|
||||
use derive_deref::Deref;
|
||||
|
||||
#[derive(Debug, Deref, Clone, Copy)]
|
||||
pub struct Feerate(f32);
|
||||
@@ -1,11 +0,0 @@
|
||||
mod addressindextxoutindex;
|
||||
mod bitcoin;
|
||||
mod feerate;
|
||||
// mod ohlc;
|
||||
mod unit;
|
||||
|
||||
pub use addressindextxoutindex::*;
|
||||
pub use bitcoin::*;
|
||||
pub use feerate::*;
|
||||
// pub use ohlc::*;
|
||||
pub use unit::*;
|
||||
@@ -1,36 +0,0 @@
|
||||
use serde::Serialize;
|
||||
use zerocopy::{FromBytes, Immutable, IntoBytes, KnownLayout};
|
||||
|
||||
use super::{Cents, Close, High, Low, Open};
|
||||
|
||||
// #[derive(Debug, Default, Clone, Copy, FromBytes, Immutable, IntoBytes, KnownLayout, Serialize)]
|
||||
// #[repr(C)]
|
||||
// pub struct OHLCCents(OHLC<Cents>);
|
||||
|
||||
#[derive(Debug, Default, Clone, Copy, FromBytes, Immutable, IntoBytes, KnownLayout, Serialize)]
|
||||
#[repr(C)]
|
||||
pub struct OHLCCents(Open<Cents>, High<Cents>, Low<Cents>, Close<Cents>);
|
||||
|
||||
impl OHLCCents {
|
||||
pub fn open(&self) -> Open<Cents> {
|
||||
self.0
|
||||
}
|
||||
|
||||
pub fn high(&self) -> High<Cents> {
|
||||
self.1
|
||||
}
|
||||
|
||||
pub fn low(&self) -> Low<Cents> {
|
||||
self.2
|
||||
}
|
||||
|
||||
pub fn close(&self) -> Close<Cents> {
|
||||
self.3
|
||||
}
|
||||
}
|
||||
|
||||
impl From<(Open<Cents>, High<Cents>, Low<Cents>, Close<Cents>)> for OHLCCents {
|
||||
fn from(value: (Open<Cents>, High<Cents>, Low<Cents>, Close<Cents>)) -> Self {
|
||||
Self(value.0, value.1, value.2, value.3)
|
||||
}
|
||||
}
|
||||
@@ -1,13 +0,0 @@
|
||||
use byteview::ByteView;
|
||||
|
||||
pub struct Unit();
|
||||
impl From<ByteView> for Unit {
|
||||
fn from(_: ByteView) -> Self {
|
||||
Self()
|
||||
}
|
||||
}
|
||||
impl From<Unit> for ByteView {
|
||||
fn from(_: Unit) -> Self {
|
||||
Self::new(&[])
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user