add logs to verification
This commit is contained in:
parent
2f7b940794
commit
7d7498b35c
|
@ -16,6 +16,7 @@ pub struct ChainAcceptor<'a> {
|
|||
|
||||
impl<'a> ChainAcceptor<'a> {
|
||||
pub fn new(store: &'a SharedStore, network: Magic, block: CanonBlock<'a>, height: u32) -> Self {
|
||||
trace!(target: "verification", "Block verification {}", block.hash().to_reversed_str());
|
||||
let prevouts = DuplexTransactionOutputProvider::new(store.as_previous_transaction_output_provider(), block.raw());
|
||||
ChainAcceptor {
|
||||
block: BlockAcceptor::new(store.as_previous_transaction_output_provider(), network, block, height),
|
||||
|
|
|
@ -32,6 +32,7 @@ impl<'a> TransactionAcceptor<'a> {
|
|||
height: u32,
|
||||
time: u32,
|
||||
) -> Self {
|
||||
trace!(target: "verification", "Tx verification {}", transaction.hash.to_reversed_str());
|
||||
let params = network.consensus_params();
|
||||
TransactionAcceptor {
|
||||
bip30: TransactionBip30::new_for_sync(transaction, meta_store, params.clone(), block_hash, height),
|
||||
|
@ -91,6 +92,7 @@ impl<'a> MemoryPoolTransactionAcceptor<'a> {
|
|||
height: u32,
|
||||
time: u32,
|
||||
) -> Self {
|
||||
trace!(target: "verification", "Mempool-Tx verification {}", transaction.hash.to_reversed_str());
|
||||
let params = network.consensus_params();
|
||||
MemoryPoolTransactionAcceptor {
|
||||
bip30: TransactionBip30::new_for_mempool(transaction, meta_store),
|
||||
|
@ -378,17 +380,14 @@ impl<'a> TransactionDoubleSpend<'a> {
|
|||
|
||||
impl<'a> TransactionRule for TransactionDoubleSpend<'a> {
|
||||
fn check(&self) -> Result<(), TransactionError> {
|
||||
let double_spent_input = self.transaction.raw.inputs.iter()
|
||||
.find(|input| self.store.is_spent(&input.previous_output).unwrap_or(false));
|
||||
|
||||
match double_spent_input {
|
||||
Some(input) => {
|
||||
Err(TransactionError::UsingSpentOutput(
|
||||
for input in &self.transaction.raw.inputs {
|
||||
if self.store.is_spent(&input.previous_output).unwrap_or(false) {
|
||||
return Err(TransactionError::UsingSpentOutput(
|
||||
input.previous_output.hash.clone(),
|
||||
input.previous_output.index
|
||||
))
|
||||
},
|
||||
None => Ok(())
|
||||
}
|
||||
}
|
||||
Ok(())
|
||||
}
|
||||
}
|
||||
|
|
|
@ -14,6 +14,7 @@ pub struct ChainVerifier<'a> {
|
|||
|
||||
impl<'a> ChainVerifier<'a> {
|
||||
pub fn new(block: &'a IndexedBlock, network: Magic, current_time: u32) -> Self {
|
||||
trace!(target: "verification", "Block pre-verification {}", block.hash().to_reversed_str());
|
||||
ChainVerifier {
|
||||
block: BlockVerifier::new(block),
|
||||
header: HeaderVerifier::new(&block.header, network, current_time),
|
||||
|
|
|
@ -13,6 +13,7 @@ pub struct TransactionVerifier<'a> {
|
|||
|
||||
impl<'a> TransactionVerifier<'a> {
|
||||
pub fn new(transaction: &'a IndexedTransaction) -> Self {
|
||||
trace!(target: "verification", "Tx pre-verification {}", transaction.hash.to_reversed_str());
|
||||
TransactionVerifier {
|
||||
empty: TransactionEmpty::new(transaction),
|
||||
null_non_coinbase: TransactionNullNonCoinbase::new(transaction),
|
||||
|
@ -38,6 +39,7 @@ pub struct MemoryPoolTransactionVerifier<'a> {
|
|||
|
||||
impl<'a> MemoryPoolTransactionVerifier<'a> {
|
||||
pub fn new(transaction: &'a IndexedTransaction) -> Self {
|
||||
trace!(target: "verification", "Mempool-Tx pre-verification {}", transaction.hash.to_reversed_str());
|
||||
MemoryPoolTransactionVerifier {
|
||||
empty: TransactionEmpty::new(transaction),
|
||||
null_non_coinbase: TransactionNullNonCoinbase::new(transaction),
|
||||
|
|
Loading…
Reference in New Issue