Commit a33768da authored by kenshin-samourai's avatar kenshin-samourai
Browse files

remove support of metrics from query.rs

parent f7444940
......@@ -59,7 +59,7 @@ fn run_server(config: &Config) -> Result<()> {
let app = App::new(store, index, daemon, &config)?;
let tx_cache = TransactionCache::new(config.tx_cache_size, &metrics);
let query = Query::new(app.clone(), &metrics, tx_cache, config.txid_limit);
let query = Query::new(app.clone(), tx_cache, config.txid_limit);
let mut server = None; // Electrum RPC server
loop {
......
......@@ -13,7 +13,6 @@ use crate::cache::TransactionCache;
use crate::errors::*;
use crate::index::{compute_script_hash, TxInRow, TxOutRow, TxRow};
use crate::mempool::Tracker;
use crate::metrics::{HistogramOpts, HistogramVec, Metrics};
use crate::store::{ReadStore, Row};
use crate::util::{FullHash, HashPrefix, HeaderEntry};
......@@ -123,13 +122,11 @@ pub struct Query {
tracker: RwLock<Tracker>,
tx_cache: TransactionCache,
txid_limit: usize,
duration: HistogramVec,
}
impl Query {
pub fn new(
app: Arc<App>,
metrics: &Metrics,
tx_cache: TransactionCache,
txid_limit: usize,
) -> Arc<Query> {
......@@ -138,13 +135,6 @@ impl Query {
tracker: RwLock::new(Tracker::new()),
tx_cache,
txid_limit,
duration: metrics.histogram_vec(
HistogramOpts::new(
"electrs_query_duration",
"Time to update mempool (in seconds)",
),
&["type"],
),
})
}
......@@ -176,7 +166,9 @@ impl Query {
store,
txids_by_funding_output(store, &funding.txn_id, funding.output_index),
)?;
let mut spending_inputs = vec![];
for t in &spending_txns {
for input in t.txn.input.iter() {
if input.previous_output.txid == funding.txn_id
......@@ -191,6 +183,7 @@ impl Query {
}
}
}
assert!(spending_inputs.len() <= 1);
Ok(if spending_inputs.len() == 1 {
Some(spending_inputs.remove(0))
......@@ -263,23 +256,13 @@ impl Query {
}
pub fn status(&self, script_hash: &[u8]) -> Result<Status> {
let timer = self
.duration
.with_label_values(&["confirmed_status"])
.start_timer();
let confirmed = self
.confirmed_status(script_hash)
.chain_err(|| "failed to get confirmed status")?;
timer.observe_duration();
let timer = self
.duration
.with_label_values(&["mempool_status"])
.start_timer();
let mempool = self
.mempool_status(script_hash, &confirmed.0)
.chain_err(|| "failed to get mempool status")?;
timer.observe_duration();
Ok(Status { confirmed, mempool })
}
......@@ -313,7 +296,6 @@ impl Query {
// Internal API for transaction retrieval
fn load_txn(&self, txid: &Sha256dHash, block_height: Option<u32>) -> Result<Transaction> {
let _timer = self.duration.with_label_values(&["load_txn"]).start_timer();
self.tx_cache.get_or_else(&txid, || {
let blockhash = self.lookup_confirmed_blockhash(txid, block_height)?;
let value: Value = self
......@@ -331,10 +313,6 @@ impl Query {
}
pub fn update_mempool(&self) -> Result<()> {
let _timer = self
.duration
.with_label_values(&["update_mempool"])
.start_timer();
self.tracker.write().unwrap().update(self.app.daemon())
}
}
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment