Changeset View
Changeset View
Standalone View
Standalone View
chronik/chronik-db/src/db.rs
Show All 9 Lines | |||||
use abc_rust_error::Result; | use abc_rust_error::Result; | ||||
pub use rocksdb::WriteBatch; | pub use rocksdb::WriteBatch; | ||||
use rocksdb::{ColumnFamilyDescriptor, IteratorMode}; | use rocksdb::{ColumnFamilyDescriptor, IteratorMode}; | ||||
use thiserror::Error; | use thiserror::Error; | ||||
use crate::{ | use crate::{ | ||||
groups::{ScriptHistoryWriter, ScriptUtxoWriter}, | groups::{ScriptHistoryWriter, ScriptUtxoWriter}, | ||||
io::{BlockWriter, MetadataWriter, SpentByWriter, TxWriter}, | io::{ | ||||
BlockStatsWriter, BlockWriter, MetadataWriter, SpentByWriter, TxWriter, | |||||
}, | |||||
}; | }; | ||||
// All column family names used by Chronik should be defined here | // All column family names used by Chronik should be defined here | ||||
/// Column family name for the block data. | /// Column family name for the block data. | ||||
pub const CF_BLK: &str = "blk"; | pub const CF_BLK: &str = "blk"; | ||||
/// Column family for the first tx_num of the block. Used to get a list of the | /// Column family for the first tx_num of the block. Used to get a list of the | ||||
/// txs of the block. | /// txs of the block. | ||||
pub const CF_BLK_BY_FIRST_TX: &str = "blk_by_first_tx"; | pub const CF_BLK_BY_FIRST_TX: &str = "blk_by_first_tx"; | ||||
▲ Show 20 Lines • Show All 42 Lines • ▼ Show 20 Lines | |||||
use self::DbError::*; | use self::DbError::*; | ||||
impl Db { | impl Db { | ||||
/// Opens the database under the specified path. | /// Opens the database under the specified path. | ||||
/// Creates the database file and necessary column families if necessary. | /// Creates the database file and necessary column families if necessary. | ||||
pub fn open(path: impl AsRef<Path>) -> Result<Self> { | pub fn open(path: impl AsRef<Path>) -> Result<Self> { | ||||
let mut cfs = Vec::new(); | let mut cfs = Vec::new(); | ||||
BlockWriter::add_cfs(&mut cfs); | BlockWriter::add_cfs(&mut cfs); | ||||
BlockStatsWriter::add_cfs(&mut cfs); | |||||
MetadataWriter::add_cfs(&mut cfs); | MetadataWriter::add_cfs(&mut cfs); | ||||
TxWriter::add_cfs(&mut cfs); | TxWriter::add_cfs(&mut cfs); | ||||
ScriptHistoryWriter::add_cfs(&mut cfs); | ScriptHistoryWriter::add_cfs(&mut cfs); | ||||
ScriptUtxoWriter::add_cfs(&mut cfs); | ScriptUtxoWriter::add_cfs(&mut cfs); | ||||
SpentByWriter::add_cfs(&mut cfs); | SpentByWriter::add_cfs(&mut cfs); | ||||
Self::open_with_cfs(path, cfs) | Self::open_with_cfs(path, cfs) | ||||
} | } | ||||
▲ Show 20 Lines • Show All 89 Lines • Show Last 20 Lines |