mirror of
https://github.com/bitcoinresearchkit/brk.git
synced 2026-04-24 06:39:58 -07:00
global: snapshot
This commit is contained in:
@@ -194,9 +194,7 @@ impl ClientInner {
|
||||
.previous_block_hash
|
||||
.map(|s| s.parse::<bitcoin::BlockHash>())
|
||||
.transpose()
|
||||
.map_err(|_| {
|
||||
corepc_client::client_sync::Error::UnexpectedStructure
|
||||
})?;
|
||||
.map_err(|_| corepc_client::client_sync::Error::UnexpectedStructure)?;
|
||||
Ok(BlockHeaderInfo {
|
||||
height: r.height as usize,
|
||||
confirmations: r.confirmations,
|
||||
@@ -224,10 +222,8 @@ impl ClientInner {
|
||||
|
||||
match r {
|
||||
Some(r) => {
|
||||
let script_pub_key =
|
||||
bitcoin::ScriptBuf::from_hex(&r.script_pub_key.hex).map_err(|_| {
|
||||
corepc_client::client_sync::Error::UnexpectedStructure
|
||||
})?;
|
||||
let script_pub_key = bitcoin::ScriptBuf::from_hex(&r.script_pub_key.hex)
|
||||
.map_err(|_| corepc_client::client_sync::Error::UnexpectedStructure)?;
|
||||
let sats = (r.value * 100_000_000.0).round() as u64;
|
||||
Ok(Some(TxOutInfo {
|
||||
coinbase: r.coinbase,
|
||||
@@ -243,9 +239,8 @@ impl ClientInner {
|
||||
let r = self.call_with_retry(|c| c.get_raw_mempool())?;
|
||||
r.0.iter()
|
||||
.map(|s| {
|
||||
s.parse::<bitcoin::Txid>().map_err(|_| {
|
||||
corepc_client::client_sync::Error::UnexpectedStructure.into()
|
||||
})
|
||||
s.parse::<bitcoin::Txid>()
|
||||
.map_err(|_| corepc_client::client_sync::Error::UnexpectedStructure.into())
|
||||
})
|
||||
.collect()
|
||||
}
|
||||
@@ -254,16 +249,15 @@ impl ClientInner {
|
||||
let r = self.call_with_retry(|c| c.get_raw_mempool_verbose())?;
|
||||
r.0.into_iter()
|
||||
.map(|(txid_str, entry)| {
|
||||
let txid = txid_str.parse::<bitcoin::Txid>().map_err(|_| {
|
||||
corepc_client::client_sync::Error::UnexpectedStructure
|
||||
})?;
|
||||
let txid = txid_str
|
||||
.parse::<bitcoin::Txid>()
|
||||
.map_err(|_| corepc_client::client_sync::Error::UnexpectedStructure)?;
|
||||
let depends = entry
|
||||
.depends
|
||||
.iter()
|
||||
.map(|s| {
|
||||
s.parse::<bitcoin::Txid>().map_err(|_| {
|
||||
corepc_client::client_sync::Error::UnexpectedStructure
|
||||
})
|
||||
s.parse::<bitcoin::Txid>()
|
||||
.map_err(|_| corepc_client::client_sync::Error::UnexpectedStructure)
|
||||
})
|
||||
.collect::<Result<Vec<_>, _>>()?;
|
||||
Ok((
|
||||
|
||||
@@ -75,9 +75,7 @@ impl Client {
|
||||
where
|
||||
H: Into<u64> + Copy,
|
||||
{
|
||||
self.0
|
||||
.get_block_hash(height.into())
|
||||
.map(BlockHash::from)
|
||||
self.0.get_block_hash(height.into()).map(BlockHash::from)
|
||||
}
|
||||
|
||||
pub fn get_block_header<'a, H>(&self, hash: &'a H) -> Result<bitcoin::block::Header>
|
||||
@@ -192,16 +190,18 @@ impl Client {
|
||||
let result = self.0.get_raw_mempool_verbose()?;
|
||||
Ok(result
|
||||
.into_iter()
|
||||
.map(|(txid, entry): (bitcoin::Txid, backend::RawMempoolEntry)| MempoolEntryInfo {
|
||||
txid: txid.into(),
|
||||
vsize: entry.vsize,
|
||||
weight: entry.weight,
|
||||
fee: Sats::from(entry.base_fee_sats),
|
||||
ancestor_count: entry.ancestor_count,
|
||||
ancestor_size: entry.ancestor_size,
|
||||
ancestor_fee: Sats::from(entry.ancestor_fee_sats),
|
||||
depends: entry.depends.into_iter().map(Txid::from).collect(),
|
||||
})
|
||||
.map(
|
||||
|(txid, entry): (bitcoin::Txid, backend::RawMempoolEntry)| MempoolEntryInfo {
|
||||
txid: txid.into(),
|
||||
vsize: entry.vsize,
|
||||
weight: entry.weight,
|
||||
fee: Sats::from(entry.base_fee_sats),
|
||||
ancestor_count: entry.ancestor_count,
|
||||
ancestor_size: entry.ancestor_size,
|
||||
ancestor_fee: Sats::from(entry.ancestor_fee_sats),
|
||||
depends: entry.depends.into_iter().map(Txid::from).collect(),
|
||||
},
|
||||
)
|
||||
.collect())
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user