mirror of
https://github.com/serai-dex/serai.git
synced 2024-12-28 22:49:42 +00:00
b823413c9b
* Use redb and in Dockerfiles The motivation for redb was to remove the multiple rocksdb compile times from CI. * Correct feature flagging of coordinator and message-queue in Dockerfiles * Correct message-queue DB type alias * Use consistent table typing in redb * Correct rebase artifacts * Correct removal of binaries feature from message-queue * Correct processor feature flagging * Replace redb with parity-db It still has much better compile times yet doesn't block when creating multiple transactions. It also is actively maintained and doesn't grow our tree. The MPT aspects are irrelevant. * Correct stray Redb * clippy warning * Correct txn get
39 lines
1.1 KiB
Rust
39 lines
1.1 KiB
Rust
mod create_db;
|
|
pub use create_db::*;
|
|
|
|
mod mem;
|
|
pub use mem::*;
|
|
|
|
#[cfg(feature = "rocksdb")]
|
|
mod rocks;
|
|
#[cfg(feature = "rocksdb")]
|
|
pub use rocks::{RocksDB, new_rocksdb};
|
|
|
|
#[cfg(feature = "parity-db")]
|
|
mod parity_db;
|
|
#[cfg(feature = "parity-db")]
|
|
pub use parity_db::{ParityDb, new_parity_db};
|
|
|
|
/// An object implementing get.
|
|
pub trait Get {
|
|
fn get(&self, key: impl AsRef<[u8]>) -> Option<Vec<u8>>;
|
|
}
|
|
|
|
/// An atomic database operation.
|
|
#[must_use]
|
|
pub trait DbTxn: Send + Get {
|
|
fn put(&mut self, key: impl AsRef<[u8]>, value: impl AsRef<[u8]>);
|
|
fn del(&mut self, key: impl AsRef<[u8]>);
|
|
fn commit(self);
|
|
}
|
|
|
|
/// A database supporting atomic operations.
|
|
pub trait Db: 'static + Send + Sync + Clone + Get {
|
|
type Transaction<'a>: DbTxn;
|
|
fn key(db_dst: &'static [u8], item_dst: &'static [u8], key: impl AsRef<[u8]>) -> Vec<u8> {
|
|
let db_len = u8::try_from(db_dst.len()).unwrap();
|
|
let dst_len = u8::try_from(item_dst.len()).unwrap();
|
|
[[db_len].as_ref(), db_dst, [dst_len].as_ref(), item_dst, key.as_ref()].concat()
|
|
}
|
|
fn txn(&mut self) -> Self::Transaction<'_>;
|
|
}
|