mirror of
https://github.com/romanz/electrs.git
synced 2024-11-19 09:54:09 +01:00
parent
a552a2bb2d
commit
632fe4c622
7
Cargo.lock
generated
7
Cargo.lock
generated
@ -342,6 +342,7 @@ dependencies = [
|
||||
"dirs-next",
|
||||
"electrs-rocksdb",
|
||||
"env_logger",
|
||||
"fs_extra",
|
||||
"log",
|
||||
"parking_lot",
|
||||
"prometheus",
|
||||
@ -423,6 +424,12 @@ dependencies = [
|
||||
"percent-encoding",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "fs_extra"
|
||||
version = "1.2.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "2022715d62ab30faffd124d40b76f4134a550a87792276512b18d63272333394"
|
||||
|
||||
[[package]]
|
||||
name = "fuchsia-cprng"
|
||||
version = "0.1.1"
|
||||
|
@ -28,6 +28,7 @@ configure_me = "0.4"
|
||||
crossbeam-channel = "0.5"
|
||||
dirs-next = "2.0"
|
||||
env_logger = "0.7"
|
||||
fs_extra = "1.2"
|
||||
log = "0.4"
|
||||
parking_lot = "0.11"
|
||||
prometheus = { version = "0.13", optional = true }
|
||||
|
@ -269,6 +269,10 @@ impl DBStore {
|
||||
}
|
||||
}
|
||||
|
||||
pub(crate) fn get_size(&self) -> Result<u64> {
|
||||
fs_extra::dir::get_size(self.db.path()).context("failed to get DB size")
|
||||
}
|
||||
|
||||
fn start_compactions(&self) {
|
||||
self.bulk_import.store(false, Ordering::Relaxed);
|
||||
for name in COLUMN_FAMILIES {
|
||||
|
@ -16,6 +16,7 @@ struct Stats {
|
||||
update_duration: Histogram,
|
||||
update_size: Histogram,
|
||||
height: Gauge,
|
||||
db_size: Gauge,
|
||||
}
|
||||
|
||||
impl Stats {
|
||||
@ -34,6 +35,7 @@ impl Stats {
|
||||
metrics::default_size_buckets(),
|
||||
),
|
||||
height: metrics.gauge("index_height", "Latest indexed block height"),
|
||||
db_size: metrics.gauge("index_db_size", "Index DB size (bytes)"),
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -89,7 +91,8 @@ impl Index {
|
||||
};
|
||||
|
||||
let stats = Stats::new(metrics);
|
||||
stats.height.set(chain.height());
|
||||
stats.height.set(chain.height() as f64);
|
||||
stats.db_size.set(store.get_size()? as f64);
|
||||
|
||||
Ok(Index {
|
||||
store,
|
||||
@ -166,6 +169,7 @@ impl Index {
|
||||
}
|
||||
|
||||
pub(crate) fn sync(&mut self, daemon: &Daemon, exit_flag: &ExitFlag) -> Result<()> {
|
||||
self.stats.db_size.set(self.store.get_size()? as f64);
|
||||
loop {
|
||||
let new_headers =
|
||||
self.observe_duration("headers", || daemon.get_new_headers(&self.chain))?;
|
||||
@ -194,7 +198,7 @@ impl Index {
|
||||
self.observe_duration("block", || {
|
||||
index_single_block(block, height).extend(&mut batch)
|
||||
});
|
||||
self.stats.height.set(height);
|
||||
self.stats.height.set(height as f64);
|
||||
})?;
|
||||
let heights: Vec<_> = heights.collect();
|
||||
assert!(
|
||||
@ -205,6 +209,7 @@ impl Index {
|
||||
batch.sort();
|
||||
self.report_stats(&batch);
|
||||
self.observe_duration("write", || self.store.write(batch));
|
||||
self.stats.db_size.set(self.store.get_size()? as f64);
|
||||
}
|
||||
self.chain.update(new_headers);
|
||||
}
|
||||
|
@ -74,8 +74,8 @@ mod metrics_impl {
|
||||
}
|
||||
|
||||
impl Gauge {
|
||||
pub fn set(&self, value: usize) {
|
||||
self.gauge.set(value as f64)
|
||||
pub fn set(&self, value: f64) {
|
||||
self.gauge.set(value)
|
||||
}
|
||||
}
|
||||
|
||||
@ -136,7 +136,7 @@ mod metrics_fake {
|
||||
pub struct Gauge {}
|
||||
|
||||
impl Gauge {
|
||||
pub fn set(&self, _value: usize) {}
|
||||
pub fn set(&self, _value: f64) {}
|
||||
}
|
||||
|
||||
#[derive(Clone)]
|
||||
|
Loading…
Reference in New Issue
Block a user