mirror of
https://github.com/Cuprate/cuprate.git
synced 2024-12-23 03:59:31 +00:00
put blockchain_db into library
This commit is contained in:
parent
5e5170b750
commit
4e9e688a7f
6 changed files with 40 additions and 17 deletions
11
Cargo.toml
11
Cargo.toml
|
@ -6,14 +6,19 @@ rust-version = "1.67.0"
|
||||||
description = "An upcoming experimental, modern & secure monero node"
|
description = "An upcoming experimental, modern & secure monero node"
|
||||||
readme = "readme.md"
|
readme = "readme.md"
|
||||||
repository = "https://github.com/SyntheticBird45/cuprate"
|
repository = "https://github.com/SyntheticBird45/cuprate"
|
||||||
license = "BSD-3-Clause"
|
license = "GPL-3"
|
||||||
license-file = "LICENSE"
|
license-file = "LICENSE"
|
||||||
|
|
||||||
# All Contributors on github
|
# 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]
|
[dependencies]
|
||||||
monero = {version = "*", features = ['serde']}
|
monero = {version = "*", features = ['serde']}
|
||||||
|
|
18
blockchain_db/Cargo.toml
Normal file
18
blockchain_db/Cargo.toml
Normal 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 = "*"
|
|
@ -1,16 +1,26 @@
|
||||||
use thiserror::Error;
|
use thiserror::Error;
|
||||||
use monero::{Hash, Transaction, Block, BlockHeader};
|
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};
|
use std::{error::Error, ops::Range};
|
||||||
|
|
||||||
const MONERO_DEFAULT_LOG_CATEGORY: &str = "blockchain.db";
|
const MONERO_DEFAULT_LOG_CATEGORY: &str = "blockchain.db";
|
||||||
|
|
||||||
|
pub type difficulty_type = u128;
|
||||||
type Blobdata = Vec<u8>;
|
type Blobdata = Vec<u8>;
|
||||||
type TxOutIndex = (Hash, u64);
|
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.
|
// 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
|
broadcasted, //< Public txes received via block/fluff
|
||||||
relayable, //< Every tx not marked `relay_method::none`
|
relayable, //< Every tx not marked `relay_method::none`
|
||||||
legacy, //< `relay_category::broadcasted` + `relay_method::none` for rpc relay requests or historical reasons
|
legacy, //< `relay_category::broadcasted` + `relay_method::none` for rpc relay requests or historical reasons
|
||||||
|
@ -96,7 +106,7 @@ pub enum TESTTT {
|
||||||
|
|
||||||
#[allow(dead_code)]
|
#[allow(dead_code)]
|
||||||
#[derive(Error, Debug)]
|
#[derive(Error, Debug)]
|
||||||
pub(in super) enum DB_FAILURES {
|
pub enum DB_FAILURES {
|
||||||
#[error("DB_ERROR: `{0}`. The database is likely corrupted.")]
|
#[error("DB_ERROR: `{0}`. The database is likely corrupted.")]
|
||||||
DB_ERROR(String),
|
DB_ERROR(String),
|
||||||
#[error("DB_ERROR_TXN_START: `{0}`. The database failed starting a txn.")]
|
#[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>),
|
HASH_DNE(Option<Hash>),
|
||||||
}
|
}
|
||||||
|
|
||||||
pub(in super) trait BlockchainDB {
|
pub trait BlockchainDB {
|
||||||
|
|
||||||
// supposed to be private
|
// supposed to be private
|
||||||
|
|
|
@ -1 +0,0 @@
|
||||||
pub type difficulty_type = u128;
|
|
|
@ -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
|
|
||||||
}
|
|
Loading…
Reference in a new issue