core: init

This commit is contained in:
nym21
2025-02-24 14:08:51 +01:00
parent bc7a76755b
commit 53175c9ed7
65 changed files with 444 additions and 424 deletions

View File

@@ -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,

View File

@@ -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()?;

View File

@@ -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>,

View File

@@ -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::*;

View File

@@ -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())
}
}

View File

@@ -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)
}
}

View File

@@ -1,4 +0,0 @@
use derive_deref::Deref;
#[derive(Debug, Deref, Clone, Copy)]
pub struct Feerate(f32);

View File

@@ -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::*;

View File

@@ -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)
}
}

View File

@@ -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(&[])
}
}