Changeset View
Changeset View
Standalone View
Standalone View
chronik/chronik-indexer/src/query/util.rs
// Copyright (c) 2023 The Bitcoin developers | // Copyright (c) 2023 The Bitcoin developers | ||||
// Distributed under the MIT software license, see the accompanying | // Distributed under the MIT software license, see the accompanying | ||||
// file COPYING or http://www.opensource.org/licenses/mit-license.php. | // file COPYING or http://www.opensource.org/licenses/mit-license.php. | ||||
use std::collections::{hash_map::Entry, BTreeMap, HashMap}; | use std::collections::{hash_map::Entry, BTreeMap, HashMap}; | ||||
use abc_rust_error::Result; | use abc_rust_error::Result; | ||||
use bitcoinsuite_core::tx::{OutPoint, SpentBy, Tx, TxId}; | use bitcoinsuite_core::{ | ||||
ser::BitcoinSer, | |||||
tx::{OutPoint, SpentBy, Tx, TxId}, | |||||
}; | |||||
use chronik_db::io::{DbBlock, SpentByEntry, SpentByReader, TxNum, TxReader}; | use chronik_db::io::{DbBlock, SpentByEntry, SpentByReader, TxNum, TxReader}; | ||||
use chronik_proto::proto; | use chronik_proto::proto; | ||||
use thiserror::Error; | use thiserror::Error; | ||||
use crate::avalanche::Avalanche; | use crate::avalanche::Avalanche; | ||||
/// Errors indicating something went wrong with reading txs. | /// Errors indicating something went wrong with reading txs. | ||||
#[derive(Debug, Error, PartialEq)] | #[derive(Debug, Error, PartialEq)] | ||||
▲ Show 20 Lines • Show All 59 Lines • ▼ Show 20 Lines | proto::Tx { | ||||
lock_time: tx.locktime, | lock_time: tx.locktime, | ||||
block: block.map(|block| proto::BlockMetadata { | block: block.map(|block| proto::BlockMetadata { | ||||
hash: block.hash.to_vec(), | hash: block.hash.to_vec(), | ||||
height: block.height, | height: block.height, | ||||
timestamp: block.timestamp, | timestamp: block.timestamp, | ||||
is_final: avalanche.is_final_height(block.height), | is_final: avalanche.is_final_height(block.height), | ||||
}), | }), | ||||
time_first_seen, | time_first_seen, | ||||
size: tx.ser_len() as u32, | |||||
is_coinbase, | is_coinbase, | ||||
} | } | ||||
} | } | ||||
pub(crate) fn make_outpoint_proto(outpoint: &OutPoint) -> proto::OutPoint { | pub(crate) fn make_outpoint_proto(outpoint: &OutPoint) -> proto::OutPoint { | ||||
proto::OutPoint { | proto::OutPoint { | ||||
txid: outpoint.txid.to_vec(), | txid: outpoint.txid.to_vec(), | ||||
out_idx: outpoint.out_idx, | out_idx: outpoint.out_idx, | ||||
▲ Show 20 Lines • Show All 76 Lines • Show Last 20 Lines |