mirror of
https://github.com/bitcoinresearchkit/brk.git
synced 2026-05-24 16:54:47 -07:00
global: MASSIVE snapshot
This commit is contained in:
@@ -1,23 +1,14 @@
|
||||
use std::ops::Deref;
|
||||
|
||||
use brk_types::{AddressBytes, AddressMempoolStats, Transaction, Txid};
|
||||
use derive_more::Deref;
|
||||
use rustc_hash::{FxHashMap, FxHashSet};
|
||||
|
||||
/// Per-address stats with associated transaction set.
|
||||
pub type AddressStats = (AddressMempoolStats, FxHashSet<Txid>);
|
||||
|
||||
/// Tracks per-address mempool statistics.
|
||||
#[derive(Default)]
|
||||
#[derive(Default, Deref)]
|
||||
pub struct AddressTracker(FxHashMap<AddressBytes, AddressStats>);
|
||||
|
||||
impl Deref for AddressTracker {
|
||||
type Target = FxHashMap<AddressBytes, AddressStats>;
|
||||
|
||||
fn deref(&self) -> &Self::Target {
|
||||
&self.0
|
||||
}
|
||||
}
|
||||
|
||||
impl AddressTracker {
|
||||
/// Add a transaction to address tracking.
|
||||
pub fn add_tx(&mut self, tx: &Transaction, txid: &Txid) {
|
||||
|
||||
@@ -10,7 +10,7 @@ use std::{
|
||||
use brk_error::Result;
|
||||
use brk_rpc::Client;
|
||||
use brk_types::{MempoolEntryInfo, MempoolInfo, TxWithHex, Txid, TxidPrefix};
|
||||
use derive_deref::Deref;
|
||||
use derive_more::Deref;
|
||||
use log::error;
|
||||
use parking_lot::{RwLock, RwLockReadGuard};
|
||||
use rustc_hash::FxHashMap;
|
||||
|
||||
@@ -1,20 +1,11 @@
|
||||
use std::ops::Deref;
|
||||
|
||||
use brk_types::{TxWithHex, Txid};
|
||||
use derive_more::Deref;
|
||||
use rustc_hash::FxHashMap;
|
||||
|
||||
/// Store of full transaction data for API access.
|
||||
#[derive(Default)]
|
||||
#[derive(Default, Deref)]
|
||||
pub struct TxStore(FxHashMap<Txid, TxWithHex>);
|
||||
|
||||
impl Deref for TxStore {
|
||||
type Target = FxHashMap<Txid, TxWithHex>;
|
||||
|
||||
fn deref(&self) -> &Self::Target {
|
||||
&self.0
|
||||
}
|
||||
}
|
||||
|
||||
impl TxStore {
|
||||
/// Check if a transaction exists.
|
||||
pub fn contains(&self, txid: &Txid) -> bool {
|
||||
|
||||
Reference in New Issue
Block a user