mirror of
https://github.com/Cuprate/cuprate.git
synced 2024-11-16 15:58:17 +00:00
repo: add skeleton directories, fix labels (#139)
* `database/` -> `storage/`, create skeleton `storage/` crates * add skeleton root directories * books: add skeleton * ci: fix labeler.yml * fix CONTRIBUTING.md * fix workspace Cargo.toml * fix `storage/` * rename helper fs fn, `cuprate_database` -> `cuprate_blockchain` * fix Cargo.toml * cuprate-blockchain: revert find-and-replace Since it has to be ported to the book anyway, there's not much reason to update this and create review diffs. * labeler.yml: remove `A-docs` from `books/` changes Although books are documentation, the `A-books` label already exists for this
This commit is contained in:
parent
45656fe653
commit
4876e159e7
70 changed files with 209 additions and 139 deletions
38
.github/labeler.yml
vendored
38
.github/labeler.yml
vendored
|
@ -30,13 +30,31 @@ A-consensus: # This is the tag name
|
||||||
# will cause the `github-actions` bot
|
# will cause the `github-actions` bot
|
||||||
# to add the `A-consensus` tag.
|
# to add the `A-consensus` tag.
|
||||||
|
|
||||||
|
# Cuprate's books.
|
||||||
|
A-books:
|
||||||
|
- changed-files:
|
||||||
|
- any-glob-to-any-file: books/**
|
||||||
|
|
||||||
|
A-book-architecture:
|
||||||
|
- changed-files:
|
||||||
|
- any-glob-to-any-file: books/architecture/**
|
||||||
|
|
||||||
|
A-book-protocol:
|
||||||
|
- changed-files:
|
||||||
|
- any-glob-to-any-file: books/protocol/**
|
||||||
|
|
||||||
|
# Crate (sub-)directories.
|
||||||
|
A-binaries:
|
||||||
|
- changed-files:
|
||||||
|
- any-glob-to-any-file: binaries/**
|
||||||
|
|
||||||
A-cryptonight:
|
A-cryptonight:
|
||||||
- changed-files:
|
- changed-files:
|
||||||
- any-glob-to-any-file: cryptonight/**
|
- any-glob-to-any-file: cryptonight/**
|
||||||
|
|
||||||
A-database:
|
A-storage:
|
||||||
- changed-files:
|
- changed-files:
|
||||||
- any-glob-to-any-file: database/**
|
- any-glob-to-any-file: storage/**
|
||||||
|
|
||||||
A-helper:
|
A-helper:
|
||||||
- changed-files:
|
- changed-files:
|
||||||
|
@ -62,10 +80,24 @@ A-types:
|
||||||
- changed-files:
|
- changed-files:
|
||||||
- any-glob-to-any-file: types/**
|
- any-glob-to-any-file: types/**
|
||||||
|
|
||||||
|
A-rpc:
|
||||||
|
- changed-files:
|
||||||
|
- any-glob-to-any-file: rpc/**
|
||||||
|
|
||||||
|
A-zmq:
|
||||||
|
- changed-files:
|
||||||
|
- any-glob-to-any-file: zmq/**
|
||||||
|
|
||||||
|
# CI files.
|
||||||
A-ci:
|
A-ci:
|
||||||
- changed-files:
|
- changed-files:
|
||||||
- any-glob-to-any-file: .github/**
|
- any-glob-to-any-file: .github/**
|
||||||
|
|
||||||
|
# Misc
|
||||||
|
A-benches:
|
||||||
|
- changed-files:
|
||||||
|
- any-glob-to-any-file: benches/** # Benchmarks
|
||||||
|
|
||||||
A-dependency:
|
A-dependency:
|
||||||
- changed-files:
|
- changed-files:
|
||||||
- any-glob-to-any-file: '**/Cargo.toml' # Any Cargo file in the entire repo
|
- any-glob-to-any-file: '**/Cargo.toml' # Any Cargo file in the entire repo
|
||||||
|
@ -74,7 +106,9 @@ A-dependency:
|
||||||
A-workspace:
|
A-workspace:
|
||||||
- changed-files:
|
- changed-files:
|
||||||
- any-glob-to-any-file: '*' # Any root file change
|
- any-glob-to-any-file: '*' # Any root file change
|
||||||
|
- any-glob-to-any-file: misc/**
|
||||||
|
|
||||||
A-docs:
|
A-docs:
|
||||||
- changed-files:
|
- changed-files:
|
||||||
- any-glob-to-any-file: '**/*.md' # Any file in the entire repo ending in `.md`
|
- any-glob-to-any-file: '**/*.md' # Any file in the entire repo ending in `.md`
|
||||||
|
# `A-books` label is used for book documentation.
|
||||||
|
|
2
.github/workflows/ci.yml
vendored
2
.github/workflows/ci.yml
vendored
|
@ -133,7 +133,7 @@ jobs:
|
||||||
- name: Test
|
- name: Test
|
||||||
run: |
|
run: |
|
||||||
cargo test --all-features --workspace
|
cargo test --all-features --workspace
|
||||||
cargo test --package cuprate-database --no-default-features --features redb --features service
|
cargo test --package cuprate-blockchain --no-default-features --features redb --features service
|
||||||
|
|
||||||
# TODO: upload binaries with `actions/upload-artifact@v3`
|
# TODO: upload binaries with `actions/upload-artifact@v3`
|
||||||
- name: Build
|
- name: Build
|
||||||
|
|
|
@ -49,14 +49,13 @@ This section is primarily targeted at maintainers. Most contributors aren't able
|
||||||
|
|
||||||
| Labels | Description | Example |
|
| Labels | Description | Example |
|
||||||
|--------------|-------------|---------|
|
|--------------|-------------|---------|
|
||||||
| [A-] | The **area** of the project an issue relates to. | `A-database`, `A-rpc`, `A-docs`
|
| [A-] | The **area** of the project an issue relates to. | `A-storage`, `A-rpc`, `A-docs`
|
||||||
| [C-] | The **category** of an issue. | `C-cleanup`, `C-optimization`
|
| [C-] | The **category** of an issue. | `C-cleanup`, `C-optimization`
|
||||||
| [D-] | Issues for **diagnostics**. | `D-confusing`, `D-verbose`
|
| [D-] | Issues for **diagnostics**. | `D-confusing`, `D-verbose`
|
||||||
| [E-] | The **experience** level necessary to fix an issue. | `E-easy`, `E-hard`
|
| [E-] | The **experience** level necessary to fix an issue. | `E-easy`, `E-hard`
|
||||||
| [I-] | The **importance** of the issue. | `I-crash`, `I-memory`
|
| [I-] | The **importance** of the issue. | `I-crash`, `I-memory`
|
||||||
| [O-] | The **operating system** or platform that the issue is specific to. | `O-windows`, `O-macos`, `O-linux`
|
| [O-] | The **operating system** or platform that the issue is specific to. | `O-windows`, `O-macos`, `O-linux`
|
||||||
| [P-] | The issue **priority**. These labels can be assigned by anyone that understand the issue and is able to prioritize it, and remove the [I-prioritize] label. | `P-high`, `P-low`
|
| [P-] | The issue **priority**. These labels can be assigned by anyone that understand the issue and is able to prioritize it, and remove the [I-prioritize] label. | `P-high`, `P-low`
|
||||||
| [wontfix] | Indicates an issue will not be fixed. | |
|
|
||||||
|
|
||||||
[A-]: https://github.com/Cuprate/cuprate/labels?q=A
|
[A-]: https://github.com/Cuprate/cuprate/labels?q=A
|
||||||
[C-]: https://github.com/Cuprate/cuprate/labels?q=C
|
[C-]: https://github.com/Cuprate/cuprate/labels?q=C
|
||||||
|
@ -65,4 +64,3 @@ This section is primarily targeted at maintainers. Most contributors aren't able
|
||||||
[I-]: https://github.com/Cuprate/cuprate/labels?q=I
|
[I-]: https://github.com/Cuprate/cuprate/labels?q=I
|
||||||
[O-]: https://github.com/Cuprate/cuprate/labels?q=O
|
[O-]: https://github.com/Cuprate/cuprate/labels?q=O
|
||||||
[P-]: https://github.com/Cuprate/cuprate/labels?q=P
|
[P-]: https://github.com/Cuprate/cuprate/labels?q=P
|
||||||
[wontfix]: https://github.com/Cuprate/cuprate/labels?q=wontfix
|
|
74
Cargo.lock
generated
74
Cargo.lock
generated
|
@ -495,6 +495,39 @@ dependencies = [
|
||||||
"thiserror",
|
"thiserror",
|
||||||
]
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "cuprate-blockchain"
|
||||||
|
version = "0.0.0"
|
||||||
|
dependencies = [
|
||||||
|
"bitflags 2.5.0",
|
||||||
|
"bytemuck",
|
||||||
|
"bytes",
|
||||||
|
"cfg-if",
|
||||||
|
"crossbeam",
|
||||||
|
"cuprate-helper",
|
||||||
|
"cuprate-test-utils",
|
||||||
|
"cuprate-types",
|
||||||
|
"curve25519-dalek",
|
||||||
|
"futures",
|
||||||
|
"heed",
|
||||||
|
"hex",
|
||||||
|
"hex-literal",
|
||||||
|
"monero-pruning",
|
||||||
|
"monero-serai",
|
||||||
|
"page_size",
|
||||||
|
"paste",
|
||||||
|
"pretty_assertions",
|
||||||
|
"rayon",
|
||||||
|
"redb",
|
||||||
|
"serde",
|
||||||
|
"tempfile",
|
||||||
|
"thiserror",
|
||||||
|
"thread_local",
|
||||||
|
"tokio",
|
||||||
|
"tokio-util",
|
||||||
|
"tower",
|
||||||
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "cuprate-consensus"
|
name = "cuprate-consensus"
|
||||||
version = "0.1.0"
|
version = "0.1.0"
|
||||||
|
@ -528,39 +561,6 @@ dependencies = [
|
||||||
"tracing-subscriber",
|
"tracing-subscriber",
|
||||||
]
|
]
|
||||||
|
|
||||||
[[package]]
|
|
||||||
name = "cuprate-database"
|
|
||||||
version = "0.0.0"
|
|
||||||
dependencies = [
|
|
||||||
"bitflags 2.5.0",
|
|
||||||
"bytemuck",
|
|
||||||
"bytes",
|
|
||||||
"cfg-if",
|
|
||||||
"crossbeam",
|
|
||||||
"cuprate-helper",
|
|
||||||
"cuprate-test-utils",
|
|
||||||
"cuprate-types",
|
|
||||||
"curve25519-dalek",
|
|
||||||
"futures",
|
|
||||||
"heed",
|
|
||||||
"hex",
|
|
||||||
"hex-literal",
|
|
||||||
"monero-pruning",
|
|
||||||
"monero-serai",
|
|
||||||
"page_size",
|
|
||||||
"paste",
|
|
||||||
"pretty_assertions",
|
|
||||||
"rayon",
|
|
||||||
"redb",
|
|
||||||
"serde",
|
|
||||||
"tempfile",
|
|
||||||
"thiserror",
|
|
||||||
"thread_local",
|
|
||||||
"tokio",
|
|
||||||
"tokio-util",
|
|
||||||
"tower",
|
|
||||||
]
|
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "cuprate-helper"
|
name = "cuprate-helper"
|
||||||
version = "0.1.0"
|
version = "0.1.0"
|
||||||
|
@ -628,6 +628,10 @@ dependencies = [
|
||||||
"tokio-util",
|
"tokio-util",
|
||||||
]
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "cuprate-txpool"
|
||||||
|
version = "0.0.0"
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "cuprate-types"
|
name = "cuprate-types"
|
||||||
version = "0.0.0"
|
version = "0.0.0"
|
||||||
|
@ -713,6 +717,10 @@ dependencies = [
|
||||||
"parking_lot_core",
|
"parking_lot_core",
|
||||||
]
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "database"
|
||||||
|
version = "0.0.0"
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "diff"
|
name = "diff"
|
||||||
version = "0.1.13"
|
version = "0.1.13"
|
||||||
|
|
|
@ -5,7 +5,6 @@ members = [
|
||||||
"consensus",
|
"consensus",
|
||||||
"consensus/rules",
|
"consensus/rules",
|
||||||
"cryptonight",
|
"cryptonight",
|
||||||
"database",
|
|
||||||
"helper",
|
"helper",
|
||||||
"net/epee-encoding",
|
"net/epee-encoding",
|
||||||
"net/fixed-bytes",
|
"net/fixed-bytes",
|
||||||
|
@ -15,6 +14,9 @@ members = [
|
||||||
"p2p/dandelion",
|
"p2p/dandelion",
|
||||||
"p2p/monero-p2p",
|
"p2p/monero-p2p",
|
||||||
"p2p/address-book",
|
"p2p/address-book",
|
||||||
|
"storage/cuprate-blockchain",
|
||||||
|
"storage/cuprate-txpool",
|
||||||
|
"storage/database",
|
||||||
"pruning",
|
"pruning",
|
||||||
"test-utils",
|
"test-utils",
|
||||||
"types",
|
"types",
|
||||||
|
|
1
benches/README.md
Normal file
1
benches/README.md
Normal file
|
@ -0,0 +1 @@
|
||||||
|
# TODO
|
1
binaries/README.md
Normal file
1
binaries/README.md
Normal file
|
@ -0,0 +1 @@
|
||||||
|
# TODO
|
1
books/README.md
Normal file
1
books/README.md
Normal file
|
@ -0,0 +1 @@
|
||||||
|
# TODO
|
1
books/architecture/README.md
Normal file
1
books/architecture/README.md
Normal file
|
@ -0,0 +1 @@
|
||||||
|
# TODO
|
1
books/protocol/README.md
Normal file
1
books/protocol/README.md
Normal file
|
@ -0,0 +1 @@
|
||||||
|
# TODO
|
|
@ -68,7 +68,7 @@ pub const CUPRATE_DIR: &str = {
|
||||||
/// - [`cuprate_cache_dir()`]
|
/// - [`cuprate_cache_dir()`]
|
||||||
/// - [`cuprate_config_dir()`]
|
/// - [`cuprate_config_dir()`]
|
||||||
/// - [`cuprate_data_dir()`]
|
/// - [`cuprate_data_dir()`]
|
||||||
/// - [`cuprate_database_dir()`]
|
/// - [`cuprate_blockchain_dir()`]
|
||||||
///
|
///
|
||||||
/// FIXME: Use `LazyLock` when stabilized.
|
/// FIXME: Use `LazyLock` when stabilized.
|
||||||
/// <https://github.com/rust-lang/rust/issues/109736>.
|
/// <https://github.com/rust-lang/rust/issues/109736>.
|
||||||
|
@ -166,18 +166,18 @@ impl_path_oncelock_and_fn! {
|
||||||
data_dir,
|
data_dir,
|
||||||
"",
|
"",
|
||||||
|
|
||||||
/// Cuprate's database directory.
|
/// Cuprate's blockchain directory.
|
||||||
///
|
///
|
||||||
/// This is the PATH used for any Cuprate database files.
|
/// This is the PATH used for any Cuprate blockchain files.
|
||||||
///
|
///
|
||||||
/// | OS | PATH |
|
/// | OS | PATH |
|
||||||
/// |---------|--------------------------------------------------------------|
|
/// |---------|----------------------------------------------------------------|
|
||||||
/// | Windows | `C:\Users\Alice\AppData\Roaming\Cuprate\database\` |
|
/// | Windows | `C:\Users\Alice\AppData\Roaming\Cuprate\blockchain\` |
|
||||||
/// | macOS | `/Users/Alice/Library/Application Support/Cuprate/database/` |
|
/// | macOS | `/Users/Alice/Library/Application Support/Cuprate/blockchain/` |
|
||||||
/// | Linux | `/home/alice/.local/share/cuprate/database/` |
|
/// | Linux | `/home/alice/.local/share/cuprate/blockchain/` |
|
||||||
cuprate_database_dir,
|
cuprate_blockchain_dir,
|
||||||
data_dir,
|
data_dir,
|
||||||
"database",
|
"blockchain",
|
||||||
}
|
}
|
||||||
|
|
||||||
//---------------------------------------------------------------------------------------------------- Tests
|
//---------------------------------------------------------------------------------------------------- Tests
|
||||||
|
@ -195,7 +195,7 @@ mod test {
|
||||||
assert!(cuprate_cache_dir().is_absolute());
|
assert!(cuprate_cache_dir().is_absolute());
|
||||||
assert!(cuprate_config_dir().is_absolute());
|
assert!(cuprate_config_dir().is_absolute());
|
||||||
assert!(cuprate_data_dir().is_absolute());
|
assert!(cuprate_data_dir().is_absolute());
|
||||||
assert!(cuprate_database_dir().is_absolute());
|
assert!(cuprate_blockchain_dir().is_absolute());
|
||||||
|
|
||||||
if cfg!(target_os = "windows") {
|
if cfg!(target_os = "windows") {
|
||||||
let dir = cuprate_cache_dir();
|
let dir = cuprate_cache_dir();
|
||||||
|
@ -210,9 +210,9 @@ mod test {
|
||||||
println!("cuprate_data_dir: {dir:?}");
|
println!("cuprate_data_dir: {dir:?}");
|
||||||
assert!(dir.ends_with(r"AppData\Roaming\Cuprate"));
|
assert!(dir.ends_with(r"AppData\Roaming\Cuprate"));
|
||||||
|
|
||||||
let dir = cuprate_database_dir();
|
let dir = cuprate_blockchain_dir();
|
||||||
println!("cuprate_database_dir: {dir:?}");
|
println!("cuprate_blockchain_dir: {dir:?}");
|
||||||
assert!(dir.ends_with(r"AppData\Roaming\Cuprate\database"));
|
assert!(dir.ends_with(r"AppData\Roaming\Cuprate\blockchain"));
|
||||||
} else if cfg!(target_os = "macos") {
|
} else if cfg!(target_os = "macos") {
|
||||||
let dir = cuprate_cache_dir();
|
let dir = cuprate_cache_dir();
|
||||||
println!("cuprate_cache_dir: {dir:?}");
|
println!("cuprate_cache_dir: {dir:?}");
|
||||||
|
@ -226,9 +226,9 @@ mod test {
|
||||||
println!("cuprate_data_dir: {dir:?}");
|
println!("cuprate_data_dir: {dir:?}");
|
||||||
assert!(dir.ends_with("Library/Application Support/Cuprate"));
|
assert!(dir.ends_with("Library/Application Support/Cuprate"));
|
||||||
|
|
||||||
let dir = cuprate_database_dir();
|
let dir = cuprate_blockchain_dir();
|
||||||
println!("cuprate_database_dir: {dir:?}");
|
println!("cuprate_blockchain_dir: {dir:?}");
|
||||||
assert!(dir.ends_with("Library/Application Support/Cuprate/database"));
|
assert!(dir.ends_with("Library/Application Support/Cuprate/blockchain"));
|
||||||
} else {
|
} else {
|
||||||
// Assumes Linux.
|
// Assumes Linux.
|
||||||
let dir = cuprate_cache_dir();
|
let dir = cuprate_cache_dir();
|
||||||
|
@ -243,9 +243,9 @@ mod test {
|
||||||
println!("cuprate_data_dir: {dir:?}");
|
println!("cuprate_data_dir: {dir:?}");
|
||||||
assert!(dir.ends_with(".local/share/cuprate"));
|
assert!(dir.ends_with(".local/share/cuprate"));
|
||||||
|
|
||||||
let dir = cuprate_database_dir();
|
let dir = cuprate_blockchain_dir();
|
||||||
println!("cuprate_database_dir: {dir:?}");
|
println!("cuprate_blockchain_dir: {dir:?}");
|
||||||
assert!(dir.ends_with(".local/share/cuprate/database"));
|
assert!(dir.ends_with(".local/share/cuprate/blockchain"));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
1
rpc/README.md
Normal file
1
rpc/README.md
Normal file
|
@ -0,0 +1 @@
|
||||||
|
# TODO
|
5
storage/README.md
Normal file
5
storage/README.md
Normal file
|
@ -0,0 +1,5 @@
|
||||||
|
# storage
|
||||||
|
|
||||||
|
TODO: This subdirectory used to be `database/` and is in the middle of being shifted around.
|
||||||
|
|
||||||
|
The old `database/` design document is in `cuprate-blockchain/` which will eventually be ported Cuprate's architecture book.
|
|
@ -1,12 +1,12 @@
|
||||||
[package]
|
[package]
|
||||||
name = "cuprate-database"
|
name = "cuprate-blockchain"
|
||||||
version = "0.0.0"
|
version = "0.0.0"
|
||||||
edition = "2021"
|
edition = "2021"
|
||||||
description = "Cuprate's database abstraction"
|
description = "Cuprate's blockchain database"
|
||||||
license = "MIT"
|
license = "MIT"
|
||||||
authors = ["hinto-janai"]
|
authors = ["hinto-janai"]
|
||||||
repository = "https://github.com/Cuprate/cuprate/tree/main/database"
|
repository = "https://github.com/Cuprate/cuprate/tree/main/storage/cuprate-blockchain"
|
||||||
keywords = ["cuprate", "database"]
|
keywords = ["cuprate", "blockchain", "database"]
|
||||||
|
|
||||||
[features]
|
[features]
|
||||||
default = ["heed", "redb", "service"]
|
default = ["heed", "redb", "service"]
|
||||||
|
@ -25,10 +25,10 @@ cfg-if = { workspace = true }
|
||||||
# FIXME:
|
# FIXME:
|
||||||
# We only need the `thread` feature if `service` is enabled.
|
# We only need the `thread` feature if `service` is enabled.
|
||||||
# Figure out how to enable features of an already pulled in dependency conditionally.
|
# Figure out how to enable features of an already pulled in dependency conditionally.
|
||||||
cuprate-helper = { path = "../helper", features = ["fs", "thread", "map"] }
|
cuprate-helper = { path = "../../helper", features = ["fs", "thread", "map"] }
|
||||||
cuprate-types = { path = "../types", features = ["service"] }
|
cuprate-types = { path = "../../types", features = ["service"] }
|
||||||
curve25519-dalek = { workspace = true }
|
curve25519-dalek = { workspace = true }
|
||||||
monero-pruning = { path = "../pruning" }
|
monero-pruning = { path = "../../pruning" }
|
||||||
monero-serai = { workspace = true, features = ["std"] }
|
monero-serai = { workspace = true, features = ["std"] }
|
||||||
paste = { workspace = true }
|
paste = { workspace = true }
|
||||||
page_size = { version = "0.6.0" } # Needed for database resizes, they must be a multiple of the OS page size.
|
page_size = { version = "0.6.0" } # Needed for database resizes, they must be a multiple of the OS page size.
|
||||||
|
@ -50,10 +50,10 @@ serde = { workspace = true, optional = true }
|
||||||
|
|
||||||
[dev-dependencies]
|
[dev-dependencies]
|
||||||
bytemuck = { version = "1.14.3", features = ["must_cast", "derive", "min_const_generics", "extern_crate_alloc"] }
|
bytemuck = { version = "1.14.3", features = ["must_cast", "derive", "min_const_generics", "extern_crate_alloc"] }
|
||||||
cuprate-helper = { path = "../helper", features = ["thread"] }
|
cuprate-helper = { path = "../../helper", features = ["thread"] }
|
||||||
cuprate-test-utils = { path = "../test-utils" }
|
cuprate-test-utils = { path = "../../test-utils" }
|
||||||
page_size = { version = "0.6.0" }
|
page_size = { version = "0.6.0" }
|
||||||
tempfile = { version = "3.10.0" }
|
tempfile = { version = "3.10.0" }
|
||||||
pretty_assertions = { workspace = true }
|
pretty_assertions = { workspace = true }
|
||||||
hex = { workspace = true }
|
hex = { workspace = true }
|
||||||
hex-literal = { workspace = true }
|
hex-literal = { workspace = true }
|
|
@ -1,5 +1,7 @@
|
||||||
# Database
|
# Database
|
||||||
Cuprate's database implementation.
|
FIXME: This documentation must be updated and moved to the architecture book.
|
||||||
|
|
||||||
|
Cuprate's blockchain implementation.
|
||||||
|
|
||||||
- [1. Documentation](#1-documentation)
|
- [1. Documentation](#1-documentation)
|
||||||
- [2. File structure](#2-file-structure)
|
- [2. File structure](#2-file-structure)
|
||||||
|
@ -595,4 +597,4 @@ struct PreRctOutputId { amount: 1, amount_index: 1 }
|
||||||
|
|
||||||
This means `cuprated`'s database will be slightly larger than `monerod`'s.
|
This means `cuprated`'s database will be slightly larger than `monerod`'s.
|
||||||
|
|
||||||
The current method `cuprate_database` uses will be "good enough" until usage shows that it must be optimized as multimap tables are tricky to implement across all backends.
|
The current method `cuprate_database` uses will be "good enough" until usage shows that it must be optimized as multimap tables are tricky to implement across all backends.
|
|
@ -27,7 +27,7 @@ use crate::{
|
||||||
//---------------------------------------------------------------------------------------------------- Consts
|
//---------------------------------------------------------------------------------------------------- Consts
|
||||||
/// Panic message when there's a table missing.
|
/// Panic message when there's a table missing.
|
||||||
const PANIC_MSG_MISSING_TABLE: &str =
|
const PANIC_MSG_MISSING_TABLE: &str =
|
||||||
"cuprate_database::Env should uphold the invariant that all tables are already created";
|
"cuprate_blockchain::Env should uphold the invariant that all tables are already created";
|
||||||
|
|
||||||
//---------------------------------------------------------------------------------------------------- ConcreteEnv
|
//---------------------------------------------------------------------------------------------------- ConcreteEnv
|
||||||
/// A strongly typed, concrete database environment, backed by `heed`.
|
/// A strongly typed, concrete database environment, backed by `heed`.
|
|
@ -1,4 +1,4 @@
|
||||||
//! Conversion from `heed::Error` -> `cuprate_database`'s errors.
|
//! Conversion from `heed::Error` -> `cuprate_blockchain`'s errors.
|
||||||
|
|
||||||
//---------------------------------------------------------------------------------------------------- Use
|
//---------------------------------------------------------------------------------------------------- Use
|
||||||
use crate::constants::DATABASE_CORRUPT_MSG;
|
use crate::constants::DATABASE_CORRUPT_MSG;
|
||||||
|
@ -85,7 +85,7 @@ impl From<heed::Error> for crate::RuntimeError {
|
||||||
E2::Corrupted | E2::PageNotFound => panic!("{mdb_error:#?}\n{DATABASE_CORRUPT_MSG}"),
|
E2::Corrupted | E2::PageNotFound => panic!("{mdb_error:#?}\n{DATABASE_CORRUPT_MSG}"),
|
||||||
|
|
||||||
// These errors should not occur, and if they do,
|
// These errors should not occur, and if they do,
|
||||||
// the best thing `cuprate_database` can do for
|
// the best thing `cuprate_blockchain` can do for
|
||||||
// safety is to panic right here.
|
// safety is to panic right here.
|
||||||
E2::Panic
|
E2::Panic
|
||||||
| E2::PageFull
|
| E2::PageFull
|
|
@ -1,4 +1,4 @@
|
||||||
//! `cuprate_database::Storable` <-> `heed` serde trait compatibility layer.
|
//! `cuprate_blockchain::Storable` <-> `heed` serde trait compatibility layer.
|
||||||
|
|
||||||
//---------------------------------------------------------------------------------------------------- Use
|
//---------------------------------------------------------------------------------------------------- Use
|
||||||
use std::{borrow::Cow, marker::PhantomData};
|
use std::{borrow::Cow, marker::PhantomData};
|
||||||
|
@ -9,7 +9,7 @@ use crate::storable::Storable;
|
||||||
|
|
||||||
//---------------------------------------------------------------------------------------------------- StorableHeed
|
//---------------------------------------------------------------------------------------------------- StorableHeed
|
||||||
/// The glue struct that implements `heed`'s (de)serialization
|
/// The glue struct that implements `heed`'s (de)serialization
|
||||||
/// traits on any type that implements `cuprate_database::Storable`.
|
/// traits on any type that implements `cuprate_blockchain::Storable`.
|
||||||
///
|
///
|
||||||
/// Never actually gets constructed, just used for trait bound translations.
|
/// Never actually gets constructed, just used for trait bound translations.
|
||||||
pub(super) struct StorableHeed<T>(PhantomData<T>)
|
pub(super) struct StorableHeed<T>(PhantomData<T>)
|
|
@ -22,7 +22,7 @@ pub struct ConcreteEnv {
|
||||||
/// (and in current use).
|
/// (and in current use).
|
||||||
config: Config,
|
config: Config,
|
||||||
|
|
||||||
/// A cached, redb version of `cuprate_database::config::SyncMode`.
|
/// A cached, redb version of `cuprate_blockchain::config::SyncMode`.
|
||||||
/// `redb` needs the sync mode to be set _per_ TX, so we
|
/// `redb` needs the sync mode to be set _per_ TX, so we
|
||||||
/// will continue to use this value every `Env::tx_rw`.
|
/// will continue to use this value every `Env::tx_rw`.
|
||||||
durability: redb::Durability,
|
durability: redb::Durability,
|
|
@ -1,4 +1,4 @@
|
||||||
//! Conversion from `redb`'s errors -> `cuprate_database`'s errors.
|
//! Conversion from `redb`'s errors -> `cuprate_blockchain`'s errors.
|
||||||
//!
|
//!
|
||||||
//! HACK: There's a lot of `_ =>` usage here because
|
//! HACK: There's a lot of `_ =>` usage here because
|
||||||
//! `redb`'s errors are `#[non_exhaustive]`...
|
//! `redb`'s errors are `#[non_exhaustive]`...
|
|
@ -1,4 +1,4 @@
|
||||||
//! `cuprate_database::Storable` <-> `redb` serde trait compatibility layer.
|
//! `cuprate_blockchain::Storable` <-> `redb` serde trait compatibility layer.
|
||||||
|
|
||||||
//---------------------------------------------------------------------------------------------------- Use
|
//---------------------------------------------------------------------------------------------------- Use
|
||||||
use std::{cmp::Ordering, fmt::Debug, marker::PhantomData};
|
use std::{cmp::Ordering, fmt::Debug, marker::PhantomData};
|
||||||
|
@ -9,7 +9,7 @@ use crate::{key::Key, storable::Storable};
|
||||||
|
|
||||||
//---------------------------------------------------------------------------------------------------- StorableRedb
|
//---------------------------------------------------------------------------------------------------- StorableRedb
|
||||||
/// The glue structs that implements `redb`'s (de)serialization
|
/// The glue structs that implements `redb`'s (de)serialization
|
||||||
/// traits on any type that implements `cuprate_database::Key`.
|
/// traits on any type that implements `cuprate_blockchain::Key`.
|
||||||
///
|
///
|
||||||
/// Never actually get constructed, just used for trait bound translations.
|
/// Never actually get constructed, just used for trait bound translations.
|
||||||
#[derive(Debug)]
|
#[derive(Debug)]
|
|
@ -1,4 +1,4 @@
|
||||||
//! Tests for `cuprate_database`'s backends.
|
//! Tests for `cuprate_blockchain`'s backends.
|
||||||
//!
|
//!
|
||||||
//! These tests are fully trait-based, meaning there
|
//! These tests are fully trait-based, meaning there
|
||||||
//! is no reference to `backend/`-specific types.
|
//! is no reference to `backend/`-specific types.
|
|
@ -10,7 +10,7 @@ use std::{
|
||||||
#[cfg(feature = "serde")]
|
#[cfg(feature = "serde")]
|
||||||
use serde::{Deserialize, Serialize};
|
use serde::{Deserialize, Serialize};
|
||||||
|
|
||||||
use cuprate_helper::fs::cuprate_database_dir;
|
use cuprate_helper::fs::cuprate_blockchain_dir;
|
||||||
|
|
||||||
use crate::{
|
use crate::{
|
||||||
config::{ReaderThreads, SyncMode},
|
config::{ReaderThreads, SyncMode},
|
|
@ -9,7 +9,7 @@ use std::{
|
||||||
#[cfg(feature = "serde")]
|
#[cfg(feature = "serde")]
|
||||||
use serde::{Deserialize, Serialize};
|
use serde::{Deserialize, Serialize};
|
||||||
|
|
||||||
use cuprate_helper::fs::cuprate_database_dir;
|
use cuprate_helper::fs::cuprate_blockchain_dir;
|
||||||
|
|
||||||
use crate::{
|
use crate::{
|
||||||
config::{ReaderThreads, SyncMode},
|
config::{ReaderThreads, SyncMode},
|
||||||
|
@ -55,7 +55,7 @@ impl ConfigBuilder {
|
||||||
///
|
///
|
||||||
/// # Default values
|
/// # Default values
|
||||||
/// If [`ConfigBuilder::db_directory`] was not called,
|
/// If [`ConfigBuilder::db_directory`] was not called,
|
||||||
/// the default [`cuprate_database_dir`] will be used.
|
/// the default [`cuprate_blockchain_dir`] will be used.
|
||||||
///
|
///
|
||||||
/// For all other values, [`Default::default`] is used.
|
/// For all other values, [`Default::default`] is used.
|
||||||
pub fn build(self) -> Config {
|
pub fn build(self) -> Config {
|
||||||
|
@ -63,7 +63,7 @@ impl ConfigBuilder {
|
||||||
// in `helper::fs`. No need to do them here.
|
// in `helper::fs`. No need to do them here.
|
||||||
let db_directory = self
|
let db_directory = self
|
||||||
.db_directory
|
.db_directory
|
||||||
.unwrap_or_else(|| Cow::Borrowed(cuprate_database_dir()));
|
.unwrap_or_else(|| Cow::Borrowed(cuprate_blockchain_dir()));
|
||||||
|
|
||||||
// Add the database filename to the directory.
|
// Add the database filename to the directory.
|
||||||
let db_file = {
|
let db_file = {
|
||||||
|
@ -137,7 +137,7 @@ impl ConfigBuilder {
|
||||||
impl Default for ConfigBuilder {
|
impl Default for ConfigBuilder {
|
||||||
fn default() -> Self {
|
fn default() -> Self {
|
||||||
Self {
|
Self {
|
||||||
db_directory: Some(Cow::Borrowed(cuprate_database_dir())),
|
db_directory: Some(Cow::Borrowed(cuprate_blockchain_dir())),
|
||||||
sync_mode: Some(SyncMode::default()),
|
sync_mode: Some(SyncMode::default()),
|
||||||
reader_threads: Some(ReaderThreads::default()),
|
reader_threads: Some(ReaderThreads::default()),
|
||||||
resize_algorithm: Some(ResizeAlgorithm::default()),
|
resize_algorithm: Some(ResizeAlgorithm::default()),
|
||||||
|
@ -163,7 +163,7 @@ pub struct Config {
|
||||||
/// The directory used to store all database files.
|
/// The directory used to store all database files.
|
||||||
///
|
///
|
||||||
/// By default, if no value is provided in the [`Config`]
|
/// By default, if no value is provided in the [`Config`]
|
||||||
/// constructor functions, this will be [`cuprate_database_dir`].
|
/// constructor functions, this will be [`cuprate_blockchain_dir`].
|
||||||
///
|
///
|
||||||
// SOMEDAY: we should also support `/etc/cuprated.conf`.
|
// SOMEDAY: we should also support `/etc/cuprated.conf`.
|
||||||
// This could be represented with an `enum DbPath { Default, Custom, Etc, }`
|
// This could be represented with an `enum DbPath { Default, Custom, Etc, }`
|
||||||
|
@ -190,20 +190,20 @@ pub struct Config {
|
||||||
impl Config {
|
impl Config {
|
||||||
/// Create a new [`Config`] with sane default settings.
|
/// Create a new [`Config`] with sane default settings.
|
||||||
///
|
///
|
||||||
/// The [`Config::db_directory`] will be [`cuprate_database_dir`].
|
/// The [`Config::db_directory`] will be [`cuprate_blockchain_dir`].
|
||||||
///
|
///
|
||||||
/// All other values will be [`Default::default`].
|
/// All other values will be [`Default::default`].
|
||||||
///
|
///
|
||||||
/// Same as [`Config::default`].
|
/// Same as [`Config::default`].
|
||||||
///
|
///
|
||||||
/// ```rust
|
/// ```rust
|
||||||
/// use cuprate_database::{config::*, resize::*, DATABASE_DATA_FILENAME};
|
/// use cuprate_blockchain::{config::*, resize::*, DATABASE_DATA_FILENAME};
|
||||||
/// use cuprate_helper::fs::*;
|
/// use cuprate_helper::fs::*;
|
||||||
///
|
///
|
||||||
/// let config = Config::new();
|
/// let config = Config::new();
|
||||||
///
|
///
|
||||||
/// assert_eq!(config.db_directory(), cuprate_database_dir());
|
/// assert_eq!(config.db_directory(), cuprate_blockchain_dir());
|
||||||
/// assert!(config.db_file().starts_with(cuprate_database_dir()));
|
/// assert!(config.db_file().starts_with(cuprate_blockchain_dir()));
|
||||||
/// assert!(config.db_file().ends_with(DATABASE_DATA_FILENAME));
|
/// assert!(config.db_file().ends_with(DATABASE_DATA_FILENAME));
|
||||||
/// assert_eq!(config.sync_mode, SyncMode::default());
|
/// assert_eq!(config.sync_mode, SyncMode::default());
|
||||||
/// assert_eq!(config.reader_threads, ReaderThreads::default());
|
/// assert_eq!(config.reader_threads, ReaderThreads::default());
|
||||||
|
@ -228,7 +228,7 @@ impl Default for Config {
|
||||||
/// Same as [`Config::new`].
|
/// Same as [`Config::new`].
|
||||||
///
|
///
|
||||||
/// ```rust
|
/// ```rust
|
||||||
/// # use cuprate_database::config::*;
|
/// # use cuprate_blockchain::config::*;
|
||||||
/// assert_eq!(Config::default(), Config::new());
|
/// assert_eq!(Config::default(), Config::new());
|
||||||
/// ```
|
/// ```
|
||||||
fn default() -> Self {
|
fn default() -> Self {
|
|
@ -12,7 +12,7 @@
|
||||||
//!
|
//!
|
||||||
//! # Example
|
//! # Example
|
||||||
//! ```rust
|
//! ```rust
|
||||||
//! use cuprate_database::{
|
//! use cuprate_blockchain::{
|
||||||
//! Env,
|
//! Env,
|
||||||
//! config::{ConfigBuilder, ReaderThreads, SyncMode}
|
//! config::{ConfigBuilder, ReaderThreads, SyncMode}
|
||||||
//! };
|
//! };
|
||||||
|
@ -31,7 +31,7 @@
|
||||||
//! .build();
|
//! .build();
|
||||||
//!
|
//!
|
||||||
//! // Start a database `service` using this configuration.
|
//! // Start a database `service` using this configuration.
|
||||||
//! let (reader_handle, _) = cuprate_database::service::init(config.clone())?;
|
//! let (reader_handle, _) = cuprate_blockchain::service::init(config.clone())?;
|
||||||
//! // It's using the config we provided.
|
//! // It's using the config we provided.
|
||||||
//! assert_eq!(reader_handle.env().config(), &config);
|
//! assert_eq!(reader_handle.env().config(), &config);
|
||||||
//! # Ok(()) }
|
//! # Ok(()) }
|
|
@ -49,7 +49,7 @@ pub enum ReaderThreads {
|
||||||
/// as such, it is equal to [`ReaderThreads::OnePerThread`].
|
/// as such, it is equal to [`ReaderThreads::OnePerThread`].
|
||||||
///
|
///
|
||||||
/// ```rust
|
/// ```rust
|
||||||
/// # use cuprate_database::config::*;
|
/// # use cuprate_blockchain::config::*;
|
||||||
/// let reader_threads = ReaderThreads::from(0_usize);
|
/// let reader_threads = ReaderThreads::from(0_usize);
|
||||||
/// assert!(matches!(reader_threads, ReaderThreads::OnePerThread));
|
/// assert!(matches!(reader_threads, ReaderThreads::OnePerThread));
|
||||||
/// ```
|
/// ```
|
||||||
|
@ -81,7 +81,7 @@ pub enum ReaderThreads {
|
||||||
/// non-zero, but not 1 thread, the minimum value 1 will be returned.
|
/// non-zero, but not 1 thread, the minimum value 1 will be returned.
|
||||||
///
|
///
|
||||||
/// ```rust
|
/// ```rust
|
||||||
/// # use cuprate_database::config::*;
|
/// # use cuprate_blockchain::config::*;
|
||||||
/// assert_eq!(ReaderThreads::Percent(0.000000001).as_threads().get(), 1);
|
/// assert_eq!(ReaderThreads::Percent(0.000000001).as_threads().get(), 1);
|
||||||
/// ```
|
/// ```
|
||||||
Percent(f32),
|
Percent(f32),
|
||||||
|
@ -97,7 +97,7 @@ impl ReaderThreads {
|
||||||
///
|
///
|
||||||
/// # Example
|
/// # Example
|
||||||
/// ```rust
|
/// ```rust
|
||||||
/// use cuprate_database::config::ReaderThreads as Rt;
|
/// use cuprate_blockchain::config::ReaderThreads as Rt;
|
||||||
///
|
///
|
||||||
/// let total_threads: std::num::NonZeroUsize =
|
/// let total_threads: std::num::NonZeroUsize =
|
||||||
/// cuprate_helper::thread::threads();
|
/// cuprate_helper::thread::threads();
|
|
@ -1,4 +1,4 @@
|
||||||
//! General constants used throughout `cuprate-database`.
|
//! General constants used throughout `cuprate-blockchain`.
|
||||||
|
|
||||||
//---------------------------------------------------------------------------------------------------- Import
|
//---------------------------------------------------------------------------------------------------- Import
|
||||||
use cfg_if::cfg_if;
|
use cfg_if::cfg_if;
|
||||||
|
@ -8,7 +8,7 @@ use cfg_if::cfg_if;
|
||||||
///
|
///
|
||||||
/// Returned by [`crate::ops::property::db_version`].
|
/// Returned by [`crate::ops::property::db_version`].
|
||||||
///
|
///
|
||||||
/// This is incremented by 1 when `cuprate_database`'s
|
/// This is incremented by 1 when `cuprate_blockchain`'s
|
||||||
/// structure/schema/tables change.
|
/// structure/schema/tables change.
|
||||||
///
|
///
|
||||||
/// This is akin to `VERSION` in `monerod`:
|
/// This is akin to `VERSION` in `monerod`:
|
|
@ -66,7 +66,7 @@ pub enum InitError {
|
||||||
/// 2. (De)serialization
|
/// 2. (De)serialization
|
||||||
/// 3. Shutdown errors
|
/// 3. Shutdown errors
|
||||||
///
|
///
|
||||||
/// as `cuprate_database` upholds the invariant that:
|
/// as `cuprate_blockchain` upholds the invariant that:
|
||||||
///
|
///
|
||||||
/// 1. All tables exist
|
/// 1. All tables exist
|
||||||
/// 2. (De)serialization never fails
|
/// 2. (De)serialization never fails
|
|
@ -23,7 +23,7 @@ pub trait Key: Storable + Sized {
|
||||||
/// not a comparison of the key's value.
|
/// not a comparison of the key's value.
|
||||||
///
|
///
|
||||||
/// ```rust
|
/// ```rust
|
||||||
/// # use cuprate_database::*;
|
/// # use cuprate_blockchain::*;
|
||||||
/// assert_eq!(
|
/// assert_eq!(
|
||||||
/// <u64 as Key>::compare([0].as_slice(), [1].as_slice()),
|
/// <u64 as Key>::compare([0].as_slice(), [1].as_slice()),
|
||||||
/// std::cmp::Ordering::Less,
|
/// std::cmp::Ordering::Less,
|
|
@ -1,6 +1,6 @@
|
||||||
//! Cuprate's database abstraction.
|
//! Cuprate's database abstraction.
|
||||||
//!
|
//!
|
||||||
//! This documentation is mostly for practical usage of `cuprate_database`.
|
//! This documentation is mostly for practical usage of `cuprate_blockchain`.
|
||||||
//!
|
//!
|
||||||
//! For a high-level overview,
|
//! For a high-level overview,
|
||||||
//! see [`database/README.md`](https://github.com/Cuprate/cuprate/blob/main/database/README.md).
|
//! see [`database/README.md`](https://github.com/Cuprate/cuprate/blob/main/database/README.md).
|
||||||
|
@ -13,7 +13,7 @@
|
||||||
//!
|
//!
|
||||||
//! Each layer builds on-top of the previous.
|
//! Each layer builds on-top of the previous.
|
||||||
//!
|
//!
|
||||||
//! As a user of `cuprate_database`, consider using the higher-level [`service`] module,
|
//! As a user of `cuprate_blockchain`, consider using the higher-level [`service`] module,
|
||||||
//! or at the very least the [`ops`] module instead of interacting with the database traits directly.
|
//! or at the very least the [`ops`] module instead of interacting with the database traits directly.
|
||||||
//!
|
//!
|
||||||
//! With that said, many database traits and internals (like [`DatabaseRo::get`]) are exposed.
|
//! With that said, many database traits and internals (like [`DatabaseRo::get`]) are exposed.
|
||||||
|
@ -82,7 +82,7 @@
|
||||||
//! <!-- FIXME: tracing should be behind a feature flag -->
|
//! <!-- FIXME: tracing should be behind a feature flag -->
|
||||||
//!
|
//!
|
||||||
//! # Invariants when not using `service`
|
//! # Invariants when not using `service`
|
||||||
//! `cuprate_database` can be used without the `service` feature enabled but
|
//! `cuprate_blockchain` can be used without the `service` feature enabled but
|
||||||
//! there are some things that must be kept in mind when doing so.
|
//! there are some things that must be kept in mind when doing so.
|
||||||
//!
|
//!
|
||||||
//! Failing to uphold these invariants may cause panics.
|
//! Failing to uphold these invariants may cause panics.
|
||||||
|
@ -92,7 +92,7 @@
|
||||||
//! 1. `LMDB` has [maximum key/value byte size](http://www.lmdb.tech/doc/group__internal.html#gac929399f5d93cef85f874b9e9b1d09e0) which must not be exceeded
|
//! 1. `LMDB` has [maximum key/value byte size](http://www.lmdb.tech/doc/group__internal.html#gac929399f5d93cef85f874b9e9b1d09e0) which must not be exceeded
|
||||||
//!
|
//!
|
||||||
//! # Examples
|
//! # Examples
|
||||||
//! The below is an example of using `cuprate_database`'s
|
//! The below is an example of using `cuprate_blockchain`'s
|
||||||
//! lowest API, i.e. using the database directly.
|
//! lowest API, i.e. using the database directly.
|
||||||
//!
|
//!
|
||||||
//! For examples of the higher-level APIs, see:
|
//! For examples of the higher-level APIs, see:
|
||||||
|
@ -100,7 +100,7 @@
|
||||||
//! - [`service`]
|
//! - [`service`]
|
||||||
//!
|
//!
|
||||||
//! ```rust
|
//! ```rust
|
||||||
//! use cuprate_database::{
|
//! use cuprate_blockchain::{
|
||||||
//! ConcreteEnv,
|
//! ConcreteEnv,
|
||||||
//! config::ConfigBuilder,
|
//! config::ConfigBuilder,
|
||||||
//! Env, EnvInner,
|
//! Env, EnvInner,
|
|
@ -56,7 +56,7 @@
|
||||||
//!
|
//!
|
||||||
//! use cuprate_test_utils::data::block_v16_tx0;
|
//! use cuprate_test_utils::data::block_v16_tx0;
|
||||||
//!
|
//!
|
||||||
//! use cuprate_database::{
|
//! use cuprate_blockchain::{
|
||||||
//! ConcreteEnv,
|
//! ConcreteEnv,
|
||||||
//! config::ConfigBuilder,
|
//! config::ConfigBuilder,
|
||||||
//! Env, EnvInner,
|
//! Env, EnvInner,
|
|
@ -13,7 +13,7 @@ use crate::{error::RuntimeError, ops::macros::doc_error};
|
||||||
///
|
///
|
||||||
/// # Example
|
/// # Example
|
||||||
/// ```rust
|
/// ```rust
|
||||||
/// # use cuprate_database::{*, tables::*, ops::block::*, ops::tx::*};
|
/// # use cuprate_blockchain::{*, tables::*, ops::block::*, ops::tx::*};
|
||||||
/// // SOMEDAY
|
/// // SOMEDAY
|
||||||
/// ```
|
/// ```
|
||||||
#[inline]
|
#[inline]
|
||||||
|
@ -29,7 +29,7 @@ pub const fn get_blockchain_pruning_seed() -> Result<PruningSeed, RuntimeError>
|
||||||
///
|
///
|
||||||
/// # Example
|
/// # Example
|
||||||
/// ```rust
|
/// ```rust
|
||||||
/// # use cuprate_database::{*, tables::*, ops::block::*, ops::tx::*};
|
/// # use cuprate_blockchain::{*, tables::*, ops::block::*, ops::tx::*};
|
||||||
/// // SOMEDAY
|
/// // SOMEDAY
|
||||||
/// ```
|
/// ```
|
||||||
#[inline]
|
#[inline]
|
|
@ -50,7 +50,7 @@ impl ResizeAlgorithm {
|
||||||
/// Returns [`Self::Monero`].
|
/// Returns [`Self::Monero`].
|
||||||
///
|
///
|
||||||
/// ```rust
|
/// ```rust
|
||||||
/// # use cuprate_database::resize::*;
|
/// # use cuprate_blockchain::resize::*;
|
||||||
/// assert!(matches!(ResizeAlgorithm::new(), ResizeAlgorithm::Monero));
|
/// assert!(matches!(ResizeAlgorithm::new(), ResizeAlgorithm::Monero));
|
||||||
/// ```
|
/// ```
|
||||||
#[inline]
|
#[inline]
|
||||||
|
@ -75,7 +75,7 @@ impl Default for ResizeAlgorithm {
|
||||||
/// Calls [`Self::new`].
|
/// Calls [`Self::new`].
|
||||||
///
|
///
|
||||||
/// ```rust
|
/// ```rust
|
||||||
/// # use cuprate_database::resize::*;
|
/// # use cuprate_blockchain::resize::*;
|
||||||
/// assert_eq!(ResizeAlgorithm::new(), ResizeAlgorithm::default());
|
/// assert_eq!(ResizeAlgorithm::new(), ResizeAlgorithm::default());
|
||||||
/// ```
|
/// ```
|
||||||
#[inline]
|
#[inline]
|
||||||
|
@ -113,7 +113,7 @@ pub fn page_size() -> NonZeroUsize {
|
||||||
/// [^2]: `1_073_745_920`
|
/// [^2]: `1_073_745_920`
|
||||||
///
|
///
|
||||||
/// ```rust
|
/// ```rust
|
||||||
/// # use cuprate_database::resize::*;
|
/// # use cuprate_blockchain::resize::*;
|
||||||
/// // The value this function will increment by
|
/// // The value this function will increment by
|
||||||
/// // (assuming page multiple of 4096).
|
/// // (assuming page multiple of 4096).
|
||||||
/// const N: usize = 1_073_741_824;
|
/// const N: usize = 1_073_741_824;
|
||||||
|
@ -129,7 +129,7 @@ pub fn page_size() -> NonZeroUsize {
|
||||||
/// This function will panic if adding onto `current_size_bytes` overflows [`usize::MAX`].
|
/// This function will panic if adding onto `current_size_bytes` overflows [`usize::MAX`].
|
||||||
///
|
///
|
||||||
/// ```rust,should_panic
|
/// ```rust,should_panic
|
||||||
/// # use cuprate_database::resize::*;
|
/// # use cuprate_blockchain::resize::*;
|
||||||
/// // Ridiculous large numbers panic.
|
/// // Ridiculous large numbers panic.
|
||||||
/// monero(usize::MAX);
|
/// monero(usize::MAX);
|
||||||
/// ```
|
/// ```
|
||||||
|
@ -166,7 +166,7 @@ pub fn monero(current_size_bytes: usize) -> NonZeroUsize {
|
||||||
/// and then round up to nearest OS page size.
|
/// and then round up to nearest OS page size.
|
||||||
///
|
///
|
||||||
/// ```rust
|
/// ```rust
|
||||||
/// # use cuprate_database::resize::*;
|
/// # use cuprate_blockchain::resize::*;
|
||||||
/// let page_size: usize = page_size().get();
|
/// let page_size: usize = page_size().get();
|
||||||
///
|
///
|
||||||
/// // Anything below the page size will round up to the page size.
|
/// // Anything below the page size will round up to the page size.
|
||||||
|
@ -185,7 +185,7 @@ pub fn monero(current_size_bytes: usize) -> NonZeroUsize {
|
||||||
/// This function will panic if adding onto `current_size_bytes` overflows [`usize::MAX`].
|
/// This function will panic if adding onto `current_size_bytes` overflows [`usize::MAX`].
|
||||||
///
|
///
|
||||||
/// ```rust,should_panic
|
/// ```rust,should_panic
|
||||||
/// # use cuprate_database::resize::*;
|
/// # use cuprate_blockchain::resize::*;
|
||||||
/// // Ridiculous large numbers panic.
|
/// // Ridiculous large numbers panic.
|
||||||
/// fixed_bytes(1, usize::MAX);
|
/// fixed_bytes(1, usize::MAX);
|
||||||
/// ```
|
/// ```
|
||||||
|
@ -221,7 +221,7 @@ pub fn fixed_bytes(current_size_bytes: usize, add_bytes: usize) -> NonZeroUsize
|
||||||
/// (rounded up to the OS page size).
|
/// (rounded up to the OS page size).
|
||||||
///
|
///
|
||||||
/// ```rust
|
/// ```rust
|
||||||
/// # use cuprate_database::resize::*;
|
/// # use cuprate_blockchain::resize::*;
|
||||||
/// let page_size: usize = page_size().get();
|
/// let page_size: usize = page_size().get();
|
||||||
///
|
///
|
||||||
/// // Anything below the page size will round up to the page size.
|
/// // Anything below the page size will round up to the page size.
|
||||||
|
@ -247,7 +247,7 @@ pub fn fixed_bytes(current_size_bytes: usize, add_bytes: usize) -> NonZeroUsize
|
||||||
/// is closer to [`usize::MAX`] than the OS page size.
|
/// is closer to [`usize::MAX`] than the OS page size.
|
||||||
///
|
///
|
||||||
/// ```rust,should_panic
|
/// ```rust,should_panic
|
||||||
/// # use cuprate_database::resize::*;
|
/// # use cuprate_blockchain::resize::*;
|
||||||
/// // Ridiculous large numbers panic.
|
/// // Ridiculous large numbers panic.
|
||||||
/// percent(usize::MAX, 1.001);
|
/// percent(usize::MAX, 1.001);
|
||||||
/// ```
|
/// ```
|
|
@ -1,4 +1,4 @@
|
||||||
//! General free functions used (related to `cuprate_database::service`).
|
//! General free functions used (related to `cuprate_blockchain::service`).
|
||||||
|
|
||||||
//---------------------------------------------------------------------------------------------------- Import
|
//---------------------------------------------------------------------------------------------------- Import
|
||||||
use std::sync::Arc;
|
use std::sync::Arc;
|
|
@ -66,7 +66,7 @@
|
||||||
//! use cuprate_types::service::{ReadRequest, WriteRequest, Response};
|
//! use cuprate_types::service::{ReadRequest, WriteRequest, Response};
|
||||||
//! use cuprate_test_utils::data::block_v16_tx0;
|
//! use cuprate_test_utils::data::block_v16_tx0;
|
||||||
//!
|
//!
|
||||||
//! use cuprate_database::{ConcreteEnv, config::ConfigBuilder, Env};
|
//! use cuprate_blockchain::{ConcreteEnv, config::ConfigBuilder, Env};
|
||||||
//!
|
//!
|
||||||
//! # #[tokio::main]
|
//! # #[tokio::main]
|
||||||
//! # async fn main() -> Result<(), Box<dyn std::error::Error>> {
|
//! # async fn main() -> Result<(), Box<dyn std::error::Error>> {
|
||||||
|
@ -77,7 +77,7 @@
|
||||||
//! .build();
|
//! .build();
|
||||||
//!
|
//!
|
||||||
//! // Initialize the database thread-pool.
|
//! // Initialize the database thread-pool.
|
||||||
//! let (mut read_handle, mut write_handle) = cuprate_database::service::init(config)?;
|
//! let (mut read_handle, mut write_handle) = cuprate_blockchain::service::init(config)?;
|
||||||
//!
|
//!
|
||||||
//! // Prepare a request to write block.
|
//! // Prepare a request to write block.
|
||||||
//! let mut block = block_v16_tx0().clone();
|
//! let mut block = block_v16_tx0().clone();
|
|
@ -29,7 +29,7 @@ use bytes::Bytes;
|
||||||
/// See [`StorableVec`] & [`StorableBytes`] for storing slices of `T: Storable`.
|
/// See [`StorableVec`] & [`StorableBytes`] for storing slices of `T: Storable`.
|
||||||
///
|
///
|
||||||
/// ```rust
|
/// ```rust
|
||||||
/// # use cuprate_database::*;
|
/// # use cuprate_blockchain::*;
|
||||||
/// # use std::borrow::*;
|
/// # use std::borrow::*;
|
||||||
/// let number: u64 = 0;
|
/// let number: u64 = 0;
|
||||||
///
|
///
|
||||||
|
@ -77,7 +77,7 @@ pub trait Storable: Debug {
|
||||||
///
|
///
|
||||||
/// # Examples
|
/// # Examples
|
||||||
/// ```rust
|
/// ```rust
|
||||||
/// # use cuprate_database::*;
|
/// # use cuprate_blockchain::*;
|
||||||
/// assert_eq!(<()>::BYTE_LENGTH, Some(0));
|
/// assert_eq!(<()>::BYTE_LENGTH, Some(0));
|
||||||
/// assert_eq!(u8::BYTE_LENGTH, Some(1));
|
/// assert_eq!(u8::BYTE_LENGTH, Some(1));
|
||||||
/// assert_eq!(u16::BYTE_LENGTH, Some(2));
|
/// assert_eq!(u16::BYTE_LENGTH, Some(2));
|
||||||
|
@ -99,7 +99,7 @@ pub trait Storable: Debug {
|
||||||
///
|
///
|
||||||
/// # Blanket implementation
|
/// # Blanket implementation
|
||||||
/// The blanket implementation that covers all types used
|
/// The blanket implementation that covers all types used
|
||||||
/// by `cuprate_database` will simply bitwise copy `bytes`
|
/// by `cuprate_blockchain` will simply bitwise copy `bytes`
|
||||||
/// into `Self`.
|
/// into `Self`.
|
||||||
///
|
///
|
||||||
/// The bytes do not have be correctly aligned.
|
/// The bytes do not have be correctly aligned.
|
||||||
|
@ -136,7 +136,7 @@ where
|
||||||
///
|
///
|
||||||
/// # Example
|
/// # Example
|
||||||
/// ```rust
|
/// ```rust
|
||||||
/// # use cuprate_database::*;
|
/// # use cuprate_blockchain::*;
|
||||||
/// //---------------------------------------------------- u8
|
/// //---------------------------------------------------- u8
|
||||||
/// let vec: StorableVec<u8> = StorableVec(vec![0,1]);
|
/// let vec: StorableVec<u8> = StorableVec(vec![0,1]);
|
||||||
///
|
///
|
||||||
|
@ -202,7 +202,7 @@ impl<T> Borrow<[T]> for StorableVec<T> {
|
||||||
/// A [`Storable`] version of [`Bytes`].
|
/// A [`Storable`] version of [`Bytes`].
|
||||||
///
|
///
|
||||||
/// ```rust
|
/// ```rust
|
||||||
/// # use cuprate_database::*;
|
/// # use cuprate_blockchain::*;
|
||||||
/// # use bytes::Bytes;
|
/// # use bytes::Bytes;
|
||||||
/// let bytes: StorableBytes = StorableBytes(Bytes::from_static(&[0,1]));
|
/// let bytes: StorableBytes = StorableBytes(Bytes::from_static(&[0,1]));
|
||||||
///
|
///
|
|
@ -1,7 +1,7 @@
|
||||||
//! Database tables.
|
//! Database tables.
|
||||||
//!
|
//!
|
||||||
//! # Table marker structs
|
//! # Table marker structs
|
||||||
//! This module contains all the table definitions used by `cuprate_database`.
|
//! This module contains all the table definitions used by `cuprate_blockchain`.
|
||||||
//!
|
//!
|
||||||
//! The zero-sized structs here represents the table type;
|
//! The zero-sized structs here represents the table type;
|
||||||
//! they all are essentially marker types that implement [`Table`].
|
//! they all are essentially marker types that implement [`Table`].
|
||||||
|
@ -331,7 +331,7 @@ macro_rules! tables {
|
||||||
///
|
///
|
||||||
/// ## Table Name
|
/// ## Table Name
|
||||||
/// ```rust
|
/// ```rust
|
||||||
/// # use cuprate_database::{*,tables::*};
|
/// # use cuprate_blockchain::{*,tables::*};
|
||||||
#[doc = concat!(
|
#[doc = concat!(
|
||||||
"assert_eq!(",
|
"assert_eq!(",
|
||||||
stringify!([<$table:camel>]),
|
stringify!([<$table:camel>]),
|
|
@ -1,4 +1,4 @@
|
||||||
//! Utilities for `cuprate_database` testing.
|
//! Utilities for `cuprate_blockchain` testing.
|
||||||
//!
|
//!
|
||||||
//! These types/fn's are only:
|
//! These types/fn's are only:
|
||||||
//! - enabled on #[cfg(test)]
|
//! - enabled on #[cfg(test)]
|
|
@ -105,7 +105,7 @@ pub type UnlockTime = u64;
|
||||||
///
|
///
|
||||||
/// ```rust
|
/// ```rust
|
||||||
/// # use std::borrow::*;
|
/// # use std::borrow::*;
|
||||||
/// # use cuprate_database::{*, types::*};
|
/// # use cuprate_blockchain::{*, types::*};
|
||||||
/// // Assert Storable is correct.
|
/// // Assert Storable is correct.
|
||||||
/// let a = PreRctOutputId {
|
/// let a = PreRctOutputId {
|
||||||
/// amount: 1,
|
/// amount: 1,
|
||||||
|
@ -118,7 +118,7 @@ pub type UnlockTime = u64;
|
||||||
///
|
///
|
||||||
/// # Size & Alignment
|
/// # Size & Alignment
|
||||||
/// ```rust
|
/// ```rust
|
||||||
/// # use cuprate_database::types::*;
|
/// # use cuprate_blockchain::types::*;
|
||||||
/// # use std::mem::*;
|
/// # use std::mem::*;
|
||||||
/// assert_eq!(size_of::<PreRctOutputId>(), 16);
|
/// assert_eq!(size_of::<PreRctOutputId>(), 16);
|
||||||
/// assert_eq!(align_of::<PreRctOutputId>(), 8);
|
/// assert_eq!(align_of::<PreRctOutputId>(), 8);
|
||||||
|
@ -148,7 +148,7 @@ pub struct PreRctOutputId {
|
||||||
///
|
///
|
||||||
/// ```rust
|
/// ```rust
|
||||||
/// # use std::borrow::*;
|
/// # use std::borrow::*;
|
||||||
/// # use cuprate_database::{*, types::*};
|
/// # use cuprate_blockchain::{*, types::*};
|
||||||
/// // Assert Storable is correct.
|
/// // Assert Storable is correct.
|
||||||
/// let a = BlockInfo {
|
/// let a = BlockInfo {
|
||||||
/// timestamp: 1,
|
/// timestamp: 1,
|
||||||
|
@ -167,7 +167,7 @@ pub struct PreRctOutputId {
|
||||||
///
|
///
|
||||||
/// # Size & Alignment
|
/// # Size & Alignment
|
||||||
/// ```rust
|
/// ```rust
|
||||||
/// # use cuprate_database::types::*;
|
/// # use cuprate_blockchain::types::*;
|
||||||
/// # use std::mem::*;
|
/// # use std::mem::*;
|
||||||
/// assert_eq!(size_of::<BlockInfo>(), 88);
|
/// assert_eq!(size_of::<BlockInfo>(), 88);
|
||||||
/// assert_eq!(align_of::<BlockInfo>(), 8);
|
/// assert_eq!(align_of::<BlockInfo>(), 8);
|
||||||
|
@ -207,7 +207,7 @@ bitflags::bitflags! {
|
||||||
///
|
///
|
||||||
/// ```rust
|
/// ```rust
|
||||||
/// # use std::borrow::*;
|
/// # use std::borrow::*;
|
||||||
/// # use cuprate_database::{*, types::*};
|
/// # use cuprate_blockchain::{*, types::*};
|
||||||
/// // Assert Storable is correct.
|
/// // Assert Storable is correct.
|
||||||
/// let a = OutputFlags::NON_ZERO_UNLOCK_TIME;
|
/// let a = OutputFlags::NON_ZERO_UNLOCK_TIME;
|
||||||
/// let b = Storable::as_bytes(&a);
|
/// let b = Storable::as_bytes(&a);
|
||||||
|
@ -217,7 +217,7 @@ bitflags::bitflags! {
|
||||||
///
|
///
|
||||||
/// # Size & Alignment
|
/// # Size & Alignment
|
||||||
/// ```rust
|
/// ```rust
|
||||||
/// # use cuprate_database::types::*;
|
/// # use cuprate_blockchain::types::*;
|
||||||
/// # use std::mem::*;
|
/// # use std::mem::*;
|
||||||
/// assert_eq!(size_of::<OutputFlags>(), 4);
|
/// assert_eq!(size_of::<OutputFlags>(), 4);
|
||||||
/// assert_eq!(align_of::<OutputFlags>(), 4);
|
/// assert_eq!(align_of::<OutputFlags>(), 4);
|
||||||
|
@ -236,7 +236,7 @@ bitflags::bitflags! {
|
||||||
///
|
///
|
||||||
/// ```rust
|
/// ```rust
|
||||||
/// # use std::borrow::*;
|
/// # use std::borrow::*;
|
||||||
/// # use cuprate_database::{*, types::*};
|
/// # use cuprate_blockchain::{*, types::*};
|
||||||
/// // Assert Storable is correct.
|
/// // Assert Storable is correct.
|
||||||
/// let a = Output {
|
/// let a = Output {
|
||||||
/// key: [1; 32],
|
/// key: [1; 32],
|
||||||
|
@ -251,7 +251,7 @@ bitflags::bitflags! {
|
||||||
///
|
///
|
||||||
/// # Size & Alignment
|
/// # Size & Alignment
|
||||||
/// ```rust
|
/// ```rust
|
||||||
/// # use cuprate_database::types::*;
|
/// # use cuprate_blockchain::types::*;
|
||||||
/// # use std::mem::*;
|
/// # use std::mem::*;
|
||||||
/// assert_eq!(size_of::<Output>(), 48);
|
/// assert_eq!(size_of::<Output>(), 48);
|
||||||
/// assert_eq!(align_of::<Output>(), 8);
|
/// assert_eq!(align_of::<Output>(), 8);
|
||||||
|
@ -277,7 +277,7 @@ pub struct Output {
|
||||||
///
|
///
|
||||||
/// ```rust
|
/// ```rust
|
||||||
/// # use std::borrow::*;
|
/// # use std::borrow::*;
|
||||||
/// # use cuprate_database::{*, types::*};
|
/// # use cuprate_blockchain::{*, types::*};
|
||||||
/// // Assert Storable is correct.
|
/// // Assert Storable is correct.
|
||||||
/// let a = RctOutput {
|
/// let a = RctOutput {
|
||||||
/// key: [1; 32],
|
/// key: [1; 32],
|
||||||
|
@ -293,7 +293,7 @@ pub struct Output {
|
||||||
///
|
///
|
||||||
/// # Size & Alignment
|
/// # Size & Alignment
|
||||||
/// ```rust
|
/// ```rust
|
||||||
/// # use cuprate_database::types::*;
|
/// # use cuprate_blockchain::types::*;
|
||||||
/// # use std::mem::*;
|
/// # use std::mem::*;
|
||||||
/// assert_eq!(size_of::<RctOutput>(), 80);
|
/// assert_eq!(size_of::<RctOutput>(), 80);
|
||||||
/// assert_eq!(align_of::<RctOutput>(), 8);
|
/// assert_eq!(align_of::<RctOutput>(), 8);
|
6
storage/cuprate-txpool/Cargo.toml
Normal file
6
storage/cuprate-txpool/Cargo.toml
Normal file
|
@ -0,0 +1,6 @@
|
||||||
|
[package]
|
||||||
|
name = "cuprate-txpool"
|
||||||
|
version = "0.0.0"
|
||||||
|
edition = "2021"
|
||||||
|
|
||||||
|
[dependencies]
|
1
storage/cuprate-txpool/src/lib.rs
Normal file
1
storage/cuprate-txpool/src/lib.rs
Normal file
|
@ -0,0 +1 @@
|
||||||
|
|
6
storage/database/Cargo.toml
Normal file
6
storage/database/Cargo.toml
Normal file
|
@ -0,0 +1,6 @@
|
||||||
|
[package]
|
||||||
|
name = "database"
|
||||||
|
version = "0.0.0"
|
||||||
|
edition = "2021"
|
||||||
|
|
||||||
|
[dependencies]
|
1
storage/database/src/lib.rs
Normal file
1
storage/database/src/lib.rs
Normal file
|
@ -0,0 +1 @@
|
||||||
|
|
1
zmq/README.md
Normal file
1
zmq/README.md
Normal file
|
@ -0,0 +1 @@
|
||||||
|
# TODO
|
Loading…
Reference in a new issue