Changeset View
Changeset View
Standalone View
Standalone View
chronik/chronik-db/src/io/block_stats.rs
// Copyright (c) 2023 The Bitcoin developers | // Copyright (c) 2023 The Bitcoin developers | ||||
// Distributed under the MIT software license, see the accompanying | // Distributed under the MIT software license, see the accompanying | ||||
// file COPYING or http://www.opensource.org/licenses/mit-license.php. | // file COPYING or http://www.opensource.org/licenses/mit-license.php. | ||||
use abc_rust_error::Result; | use abc_rust_error::Result; | ||||
#[cfg(test)] | |||||
use rocksdb::ColumnFamilyDescriptor; | use rocksdb::ColumnFamilyDescriptor; | ||||
use serde::{Deserialize, Serialize}; | use serde::{Deserialize, Serialize}; | ||||
use crate::{ | use crate::{ | ||||
db::{Db, CF, CF_BLK_STATS}, | db::{Db, CF, CF_BLK_STATS}, | ||||
index_tx::IndexTx, | index_tx::IndexTx, | ||||
io::{bh_to_bytes, BlockHeight}, | io::{bh_to_bytes, BlockHeight}, | ||||
ser::{db_deserialize, db_serialize}, | ser::{db_deserialize, db_serialize}, | ||||
▲ Show 20 Lines • Show All 112 Lines • ▼ Show 20 Lines | impl<'a> BlockStatsWriter<'a> { | ||||
pub fn delete( | pub fn delete( | ||||
&self, | &self, | ||||
batch: &mut rocksdb::WriteBatch, | batch: &mut rocksdb::WriteBatch, | ||||
block_height: BlockHeight, | block_height: BlockHeight, | ||||
) { | ) { | ||||
batch.delete_cf(self.col.cf, bh_to_bytes(block_height)); | batch.delete_cf(self.col.cf, bh_to_bytes(block_height)); | ||||
} | } | ||||
#[cfg(test)] | |||||
pub(crate) fn add_cfs(columns: &mut Vec<ColumnFamilyDescriptor>) { | pub(crate) fn add_cfs(columns: &mut Vec<ColumnFamilyDescriptor>) { | ||||
columns.push(ColumnFamilyDescriptor::new( | columns.push(ColumnFamilyDescriptor::new( | ||||
CF_BLK_STATS, | CF_BLK_STATS, | ||||
rocksdb::Options::default(), | rocksdb::Options::default(), | ||||
)); | )); | ||||
} | } | ||||
} | } | ||||
▲ Show 20 Lines • Show All 130 Lines • Show Last 20 Lines |