pub fn verify_input_scripts(&self,
                                tx_index: &mut TxIndex,
                                tx_store: &mut store::Transactions,
                                tx_ptr:   TxPtr,
                                stats:    &mut TransactionStats) -> TransactionResult<()> {

        if self.is_coinbase() {
            return Ok(())
        }

        for (index, input) in self.txs_in.iter().enumerate() {

            let p0 = Instant::now();

            let output = tx_index.get_or_set(input.prev_tx_out,
                                                     tx_ptr.to_input(index as u16 ));

            let p1 = Instant::now();
            stats.read_tx_idx += p1 - p0;

            let output = match output {
                None => {

                    // We can't find the transaction this input is pointing to
                    // Oddly, this is perfectly fine; we just postpone script validation
                    // until that transaction comes in.
                    // The spent-tree ensures that this transaction will never be connected
                    // before this happens
                    //
                    // ^^ get_or_set has placed appropriate guards in the hash_index

                    continue;
                },
                Some(o) => o
            };


            let previous_out_vec = tx_store.read_output(output, input.prev_tx_out_idx)
                .ok_or(TransactionError::OutputIndexNotFound)?;

            let previous_tx_out = TxOutput::parse(&mut Buffer::new(&previous_out_vec))
                .expect("Corrupt output data in store");

            let p2 = Instant::now();
            stats.read_tx += p2 - p1;

            ffi::verify_script(previous_tx_out.pk_script, self.to_raw(), index as u32)
                .expect("TODO: Handle script error more gracefully");

            let p3 = Instant::now();
            stats.script += p3 - p2;

            // TODO: verify_amount here
        }

        Ok(())
    }
/// Finds the outputs corresponding to the inputs and verify the scripts
Finds the outputs corresponding to the inputs and verify the scripts
Finds the outputs corresponding to the inputs and verify the scripts
pub fn verify_input_scripts(&self,
                                tx_index: &mut TxIndex,
                                tx_store: &mut store::Transactions,
                                tx_ptr:   TxPtr,
                                stats:    &mut TransactionStats) -> TransactionResult<()> {
        if self.is_coinbase() {
            return Ok(())
        }
        for (index, input) in self.txs_in.iter().enumerate() {
            let p0 = Instant::now();
            let output = tx_index.get_or_set(input.prev_tx_out,
                                                     tx_ptr.to_input(index as u16 ));
            let p1 = Instant::now();
            stats.read_tx_idx += p1 - p0;
            let output = match output {
                None => {
                    // We can't find the transaction this input is pointing to
                    // Oddly, this is perfectly fine; we just postpone script validation
                    // until that transaction comes in.
                    // The spent-tree ensures that this transaction will never be connected
                    // before this happens
                    //
                    // ^^ get_or_set has placed appropriate guards in the hash_index
                    continue;
                },
                Some(o) => o
            };
            let previous_out_vec = tx_store.read_output(output, input.prev_tx_out_idx)
                .ok_or(TransactionError::OutputIndexNotFound)?;
            let previous_tx_out = TxOutput::parse(&mut Buffer::new(&previous_out_vec))
                .expect("Corrupt output data in store");
            let p2 = Instant::now();
            stats.read_tx += p2 - p1;
            ffi::verify_script(previous_tx_out.pk_script, self.to_raw(), index as u32)
                .expect("TODO: Handle script error more gracefully");
            let p3 = Instant::now();
            stats.script += p3 - p2;
            // TODO: verify_amount here
        }
        Ok(())
    }
pub fn verify_input_scripts ( & self , tx_index : & mut TxIndex , tx_store : & mut store :: Transactions , tx_ptr : TxPtr , stats : & mut TransactionStats ) -> TransactionResult < ( ) > { if self . is_coinbase ( ) { return Ok ( ( ) ) } for ( index , input ) in self . txs_in . iter ( ) . enumerate ( ) { let p0 = Instant :: now ( ) ; let output = tx_index . get_or_set ( input . prev_tx_out , tx_ptr . to_input ( index as u16 ) ) ; let p1 = Instant :: now ( ) ; stats . read_tx_idx += p1 - p0 ; let output = match output { None => { // We can't find the transaction this input is pointing to // Oddly, this is perfectly fine; we just postpone script validation // until that transaction comes in. // The spent-tree ensures that this transaction will never be connected // before this happens // // ^^ get_or_set has placed appropriate guards in the hash_index continue ; } , Some ( o ) => o } ; let previous_out_vec = tx_store . read_output ( output , input . prev_tx_out_idx ) . ok_or ( TransactionError :: OutputIndexNotFound ) ? ; let previous_tx_out = TxOutput :: parse ( & mut Buffer :: new ( & previous_out_vec ) ) . expect ( " " ) ; let p2 = Instant :: now ( ) ; stats . read_tx += p2 - p1 ; ffi :: verify_script ( previous_tx_out . pk_script , self . to_raw ( ) , index as u32 ) . expect ( " " ) ; let p3 = Instant :: now ( ) ; stats . script += p3 - p2 ; // TODO: verify_amount here } Ok ( ( ) ) }
Finds the outputs corresponding to the inputs and verify the scripts
Finds the outputs corresponding to the inputs and verify the scripts
&self
tx_index
&mut TxIndex
tx_store
&mut store::Transactions
tx_ptr
TxPtr
stats
&mut TransactionStats
&self
tx_index
&mut TxIndex
tx_store
&mut store::Transactions
tx_ptr
TxPtr
stats
&mut TransactionStats