@ -56,21 +56,37 @@ void BlockchainDB::add_transaction(const crypto::hash& blk_hash, const transacti
tx_hash = * tx_hash_ptr ;
tx_hash = * tx_hash_ptr ;
}
}
add_transaction_data ( blk_hash , tx , tx_hash ) ;
for ( const txin_v & tx_input : tx . vin )
// iterate tx.vout using indices instead of C++11 foreach syntax because
// we need the index
for ( uint64_t i = 0 ; i < tx . vout . size ( ) ; + + i )
{
{
add_output ( tx_hash , tx . vout [ i ] , i , tx . unlock_time ) ;
if ( tx_input . type ( ) = = typeid ( txin_to_key ) )
{
add_spent_key ( boost : : get < txin_to_key > ( tx_input ) . k_image ) ;
}
}
else if ( tx_input . type ( ) = = typeid ( txin_gen ) )
{
/* nothing to do here */
}
else
{
LOG_PRINT_L1 ( " Unsupported input type, removing key images and aborting transaction addition " ) ;
for ( const txin_v & tx_input : tx . vin )
for ( const txin_v & tx_input : tx . vin )
{
{
if ( tx_input . type ( ) = = typeid ( txin_to_key ) )
if ( tx_input . type ( ) = = typeid ( txin_to_key ) )
{
{
add_spent_key ( boost : : get < txin_to_key > ( tx_input ) . k_image ) ;
remove_spent_key ( boost : : get < txin_to_key > ( tx_input ) . k_image ) ;
}
}
}
return ;
}
}
add_transaction_data ( blk_hash , tx , tx_hash ) ;
// iterate tx.vout using indices instead of C++11 foreach syntax because
// we need the index
for ( uint64_t i = 0 ; i < tx . vout . size ( ) ; + + i )
{
add_output ( tx_hash , tx . vout [ i ] , i , tx . unlock_time ) ;
}
}
}
}