put blockchain_db into library

This commit is contained in:
Someone Else 2023-02-08 23:03:15 +01:00
parent 5e5170b750
commit 4e9e688a7f
6 changed files with 40 additions and 17 deletions

View file

@ -6,14 +6,19 @@ rust-version = "1.67.0"
description = "An upcoming experimental, modern & secure monero node"
readme = "readme.md"
repository = "https://github.com/SyntheticBird45/cuprate"
license = "BSD-3-Clause"
license = "GPL-3"
license-file = "LICENSE"
# All Contributors on github
authors=["SyntheticBird45"]
authors=[
"SyntheticBird45 <@someoneelse495495:matrix.org>"
]
[workspace]
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
members = [
"blockchain_db"
]
[dependencies]
monero = {version = "*", features = ['serde']}

18
blockchain_db/Cargo.toml Normal file
View file

@ -0,0 +1,18 @@
[package]
name = "blockchain_db"
version = "0.0.1"
edition = "2021"
rust-version = "1.67.0"
# All Contributors on github
authors=[
"SyntheticBird45 <@someoneelse495495:matrix.org>"
]
[dependencies]
monero = {version = "*", features = ['serde']}
serde = "*"
# As suggested by /u/danda :
thiserror = "*"

View file

@ -1,16 +1,26 @@
use thiserror::Error;
use monero::{Hash, Transaction, Block, BlockHeader};
use crate::{cryptonote_protocol::enums::{RelayMethod}, cryptonote_basic::difficulty::difficulty_type, blockchain_db::{}};
use std::{error::Error, ops::Range};
const MONERO_DEFAULT_LOG_CATEGORY: &str = "blockchain.db";
pub type difficulty_type = u128;
type Blobdata = Vec<u8>;
type TxOutIndex = (Hash, u64);
/// Methods tracking how a tx was received and relayed
pub enum RelayMethod {
none, //< Received via RPC with `do_not_relay` set
local, //< Received via RPC; trying to send over i2p/tor, etc.
forward, //< Received over i2p/tor; timer delayed before ipv4/6 public broadcast
stem, //< Received/send over network using Dandelion++ stem
fluff, //< Received/sent over network using Dandelion++ fluff
block, //< Received in block, takes precedence over others
}
// the database types are going to be defined in the monero rust library.
pub(in super) enum RelayCategory {
pub enum RelayCategory {
broadcasted, //< Public txes received via block/fluff
relayable, //< Every tx not marked `relay_method::none`
legacy, //< `relay_category::broadcasted` + `relay_method::none` for rpc relay requests or historical reasons
@ -96,7 +106,7 @@ pub enum TESTTT {
#[allow(dead_code)]
#[derive(Error, Debug)]
pub(in super) enum DB_FAILURES {
pub enum DB_FAILURES {
#[error("DB_ERROR: `{0}`. The database is likely corrupted.")]
DB_ERROR(String),
#[error("DB_ERROR_TXN_START: `{0}`. The database failed starting a txn.")]
@ -132,7 +142,7 @@ pub(in super) enum DB_FAILURES {
HASH_DNE(Option<Hash>),
}
pub(in super) trait BlockchainDB {
pub trait BlockchainDB {
// supposed to be private

View file

@ -1 +0,0 @@
pub type difficulty_type = u128;

View file

@ -1,9 +0,0 @@
/// Methods tracking how a tx was received and relayed
pub enum RelayMethod {
none, //< Received via RPC with `do_not_relay` set
local, //< Received via RPC; trying to send over i2p/tor, etc.
forward, //< Received over i2p/tor; timer delayed before ipv4/6 public broadcast
stem, //< Received/send over network using Dandelion++ stem
fluff, //< Received/sent over network using Dandelion++ fluff
block, //< Received in block, takes precedence over others
}