pub fn write_transaction(db: &mut Db, tx_hash: &[u8;32], tx: &::Transaction, records: Vec<Record>)
                         -> DbResult<ValuePtr>
{
    let input_count = tx.txs_in.len();
    let output_count= tx.txs_out.len();

    // serialize signatures
    let mut buf_sigs = Vec::with_capacity(136 * input_count);
    {
        let mut ser_sigs = Serializer::new(&mut buf_sigs);
        for tx_in in tx.txs_in.iter() {
            ser_sigs.serialize(&tx_in.script)?;
            ser_sigs.serialize(&tx_in.sequence)?;
        }
    }

    // store and get pointer to result
    let sig_ptr = db.sig.set_value(&buf_sigs)?;


    // serialize the rest of the tx
    let mut buf_tx   = Vec::with_capacity(102 * output_count);
    {
        let mut ser_tx = Serializer::new(&mut buf_tx);

        ser_tx.serialize(&(input_count as u32))?;
        ser_tx.serialize(&(output_count as u32))?;
        ser_tx.serialize(& sig_ptr)?;
        for rec in records.into_iter() {
            ser_tx.serialize(&rec.0)?;
        }
        for tx_in in tx.txs_in.iter() {
            ser_tx.serialize(&tx_in.prev_tx_out)?;
        }
        for tx_out in tx.txs_out.iter() {
            ser_tx.serialize(&tx_out.value)?;
            ser_tx.serialize(&tx_out.pk_script)?;
        }

        ser_tx.serialize(&tx.version)?;
        ser_tx.serialize(&tx.lock_time)?;

    }
    // minimum size and align at qword
    let min_size = (output_count+1) as usize * 32;
    while buf_tx.len() < min_size || (buf_tx.len() % 7) > 0 {
        buf_tx.push(0);
    }
    let tx_ptr = db.tx.set(tx_hash, &buf_tx, 0)?;

    Ok(tx_ptr)

}
/// Write the transaction to tx and the signatures to sig
/// This procedure defines the on-disk format
Write the transaction to tx and the signatures to sig
This procedure defines the on-disk format
Write the transaction to tx and the signatures to sig This procedure defines the on - disk format
pub fn write_transaction(db: &mut Db, tx_hash: &[u8;32], tx: &::Transaction, records: Vec<Record>)
                         -> DbResult<ValuePtr>
{
    let input_count = tx.txs_in.len();
    let output_count= tx.txs_out.len();
    // serialize signatures
    let mut buf_sigs = Vec::with_capacity(136 * input_count);
    {
        let mut ser_sigs = Serializer::new(&mut buf_sigs);
        for tx_in in tx.txs_in.iter() {
            ser_sigs.serialize(&tx_in.script)?;
            ser_sigs.serialize(&tx_in.sequence)?;
        }
    }
    // store and get pointer to result
    let sig_ptr = db.sig.set_value(&buf_sigs)?;
    // serialize the rest of the tx
    let mut buf_tx   = Vec::with_capacity(102 * output_count);
    {
        let mut ser_tx = Serializer::new(&mut buf_tx);
        ser_tx.serialize(&(input_count as u32))?;
        ser_tx.serialize(&(output_count as u32))?;
        ser_tx.serialize(& sig_ptr)?;
        for rec in records.into_iter() {
            ser_tx.serialize(&rec.0)?;
        }
        for tx_in in tx.txs_in.iter() {
            ser_tx.serialize(&tx_in.prev_tx_out)?;
        }
        for tx_out in tx.txs_out.iter() {
            ser_tx.serialize(&tx_out.value)?;
            ser_tx.serialize(&tx_out.pk_script)?;
        }
        ser_tx.serialize(&tx.version)?;
        ser_tx.serialize(&tx.lock_time)?;
    }
    // minimum size and align at qword
    let min_size = (output_count+1) as usize * 32;
    while buf_tx.len() < min_size || (buf_tx.len() % 7) > 0 {
        buf_tx.push(0);
    }
    let tx_ptr = db.tx.set(tx_hash, &buf_tx, 0)?;
    Ok(tx_ptr)
}
pub fn write_transaction ( db : & mut Db , tx_hash : & [ u8 ; 32 ] , tx : & :: Transaction , records : Vec < Record > ) -> DbResult < ValuePtr > { let input_count = tx . txs_in . len ( ) ; let output_count = tx . txs_out . len ( ) ; // serialize signatures let mut buf_sigs = Vec :: with_capacity ( 136 * input_count ) ; { let mut ser_sigs = Serializer :: new ( & mut buf_sigs ) ; for tx_in in tx . txs_in . iter ( ) { ser_sigs . serialize ( & tx_in . script ) ? ; ser_sigs . serialize ( & tx_in . sequence ) ? ; } } // store and get pointer to result let sig_ptr = db . sig . set_value ( & buf_sigs ) ? ; // serialize the rest of the tx let mut buf_tx = Vec :: with_capacity ( 102 * output_count ) ; { let mut ser_tx = Serializer :: new ( & mut buf_tx ) ; ser_tx . serialize ( & ( input_count as u32 ) ) ? ; ser_tx . serialize ( & ( output_count as u32 ) ) ? ; ser_tx . serialize ( & sig_ptr ) ? ; for rec in records . into_iter ( ) { ser_tx . serialize ( & rec . 0 ) ? ; } for tx_in in tx . txs_in . iter ( ) { ser_tx . serialize ( & tx_in . prev_tx_out ) ? ; } for tx_out in tx . txs_out . iter ( ) { ser_tx . serialize ( & tx_out . value ) ? ; ser_tx . serialize ( & tx_out . pk_script ) ? ; } ser_tx . serialize ( & tx . version ) ? ; ser_tx . serialize ( & tx . lock_time ) ? ; } // minimum size and align at qword let min_size = ( output_count + 1 ) as usize * 32 ; while buf_tx . len ( ) < min_size || ( buf_tx . len ( ) % 7 ) > 0 { buf_tx . push ( 0 ) ; } let tx_ptr = db . tx . set ( tx_hash , & buf_tx , 0 ) ? ; Ok ( tx_ptr ) }
Write the transaction to tx and the signatures to sig
This procedure defines the on-disk format
Write the transaction to tx and the signatures to sig This procedure defines the on - disk format
db
&mut Db
tx_hash
&[u8;32]
tx
&::Transaction
records
Vec<Record>
db
&mut Db
tx_hash
&[u8;32]
tx
&::Transaction
records
Vec<Record>