Add zcash.mempool.size.transactions and zcash.mempool.size.bytes metrics
This commit is contained in:
parent
b274ee4066
commit
6734a01aa7
|
@ -26,6 +26,10 @@ pub struct VerifiedSet {
|
||||||
/// The set of verified transactions in the mempool.
|
/// The set of verified transactions in the mempool.
|
||||||
transactions: VecDeque<UnminedTx>,
|
transactions: VecDeque<UnminedTx>,
|
||||||
|
|
||||||
|
/// The total size of the transactions in the mempool if they were
|
||||||
|
/// serialized.
|
||||||
|
transactions_serialized_size: usize,
|
||||||
|
|
||||||
/// The set of spent out points by the verified transactions.
|
/// The set of spent out points by the verified transactions.
|
||||||
spent_outpoints: HashSet<transparent::OutPoint>,
|
spent_outpoints: HashSet<transparent::OutPoint>,
|
||||||
|
|
||||||
|
@ -65,6 +69,8 @@ impl VerifiedSet {
|
||||||
self.sprout_nullifiers.clear();
|
self.sprout_nullifiers.clear();
|
||||||
self.sapling_nullifiers.clear();
|
self.sapling_nullifiers.clear();
|
||||||
self.orchard_nullifiers.clear();
|
self.orchard_nullifiers.clear();
|
||||||
|
self.transactions_serialized_size = 0;
|
||||||
|
self.update_metrics();
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Insert a `transaction` into the set.
|
/// Insert a `transaction` into the set.
|
||||||
|
@ -80,8 +86,11 @@ impl VerifiedSet {
|
||||||
}
|
}
|
||||||
|
|
||||||
self.cache_outputs_from(&transaction.transaction);
|
self.cache_outputs_from(&transaction.transaction);
|
||||||
|
self.transactions_serialized_size += transaction.size;
|
||||||
self.transactions.push_front(transaction);
|
self.transactions.push_front(transaction);
|
||||||
|
|
||||||
|
self.update_metrics();
|
||||||
|
|
||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -134,8 +143,11 @@ impl VerifiedSet {
|
||||||
.remove(transaction_index)
|
.remove(transaction_index)
|
||||||
.expect("invalid transaction index");
|
.expect("invalid transaction index");
|
||||||
|
|
||||||
|
self.transactions_serialized_size -= removed_tx.size;
|
||||||
self.remove_outputs(&removed_tx);
|
self.remove_outputs(&removed_tx);
|
||||||
|
|
||||||
|
self.update_metrics();
|
||||||
|
|
||||||
removed_tx
|
removed_tx
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -196,4 +208,15 @@ impl VerifiedSet {
|
||||||
set.remove(&item);
|
set.remove(&item);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fn update_metrics(&mut self) {
|
||||||
|
metrics::gauge!(
|
||||||
|
"zcash.mempool.size.transactions",
|
||||||
|
self.transaction_count() as _
|
||||||
|
);
|
||||||
|
metrics::gauge!(
|
||||||
|
"zcash.mempool.size.bytes",
|
||||||
|
self.transactions_serialized_size as _
|
||||||
|
);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue