@ -715,7 +715,6 @@ block Blockchain::pop_block_from_blockchain()
m_blocks_longhash_table . clear ( ) ;
m_scan_table . clear ( ) ;
m_blocks_txs_check . clear ( ) ;
m_check_txin_table . clear ( ) ;
CHECK_AND_ASSERT_THROW_MES ( update_next_cumulative_weight_limit ( ) , " Error updating next cumulative weight limit " ) ;
uint64_t top_block_height ;
@ -2575,7 +2574,7 @@ void Blockchain::on_new_tx_from_block(const cryptonote::transaction &tx)
// This function overloads its sister function with
// an extra value (hash of highest block that holds an output used as input)
// as a return-by-reference.
bool Blockchain : : check_tx_inputs ( transaction & tx , uint64_t & max_used_block_height , crypto : : hash & max_used_block_id , tx_verification_context & tvc , bool kept_by_block )
bool Blockchain : : check_tx_inputs ( transaction & tx , uint64_t & max_used_block_height , crypto : : hash & max_used_block_id , tx_verification_context & tvc , bool kept_by_block ) const
{
LOG_PRINT_L3 ( " Blockchain:: " < < __func__ ) ;
CRITICAL_REGION_LOCAL ( m_blockchain_lock ) ;
@ -2606,7 +2605,7 @@ bool Blockchain::check_tx_inputs(transaction& tx, uint64_t& max_used_block_heigh
return true ;
}
//------------------------------------------------------------------
bool Blockchain : : check_tx_outputs ( const transaction & tx , tx_verification_context & tvc )
bool Blockchain : : check_tx_outputs ( const transaction & tx , tx_verification_context & tvc ) const
{
LOG_PRINT_L3 ( " Blockchain:: " < < __func__ ) ;
CRITICAL_REGION_LOCAL ( m_blockchain_lock ) ;
@ -2715,7 +2714,7 @@ bool Blockchain::have_tx_keyimges_as_spent(const transaction &tx) const
}
return false ;
}
bool Blockchain : : expand_transaction_2 ( transaction & tx , const crypto : : hash & tx_prefix_hash , const std : : vector < std : : vector < rct : : ctkey > > & pubkeys )
bool Blockchain : : expand_transaction_2 ( transaction & tx , const crypto : : hash & tx_prefix_hash , const std : : vector < std : : vector < rct : : ctkey > > & pubkeys ) const
{
PERF_TIMER ( expand_transaction_2 ) ;
CHECK_AND_ASSERT_MES ( tx . version = = 2 , false , " Transaction version is not 2 " ) ;
@ -2791,7 +2790,7 @@ bool Blockchain::expand_transaction_2(transaction &tx, const crypto::hash &tx_pr
// check_tx_input() rather than here, and use this function simply
// to iterate the inputs as necessary (splitting the task
// using threads, etc.)
bool Blockchain : : check_tx_inputs ( transaction & tx , tx_verification_context & tvc , uint64_t * pmax_used_block_height )
bool Blockchain : : check_tx_inputs ( transaction & tx , tx_verification_context & tvc , uint64_t * pmax_used_block_height ) const
{
PERF_TIMER ( check_tx_inputs ) ;
LOG_PRINT_L3 ( " Blockchain:: " < < __func__ ) ;
@ -2897,13 +2896,6 @@ bool Blockchain::check_tx_inputs(transaction& tx, tx_verification_context &tvc,
}
}
}
auto it = m_check_txin_table . find ( tx_prefix_hash ) ;
if ( it = = m_check_txin_table . end ( ) )
{
m_check_txin_table . emplace ( tx_prefix_hash , std : : unordered_map < crypto : : key_image , bool > ( ) ) ;
it = m_check_txin_table . find ( tx_prefix_hash ) ;
assert ( it ! = m_check_txin_table . end ( ) ) ;
}
std : : vector < std : : vector < rct : : ctkey > > pubkeys ( tx . vin . size ( ) ) ;
std : : vector < uint64_t > results ;
@ -2935,29 +2927,12 @@ bool Blockchain::check_tx_inputs(transaction& tx, tx_verification_context &tvc,
{
// basically, make sure number of inputs == number of signatures
CHECK_AND_ASSERT_MES ( sig_index < tx . signatures . size ( ) , false , " wrong transaction: not signature entry for input with index= " < < sig_index ) ;
# if defined(CACHE_VIN_RESULTS)
auto itk = it - > second . find ( in_to_key . k_image ) ;
if ( itk ! = it - > second . end ( ) )
{
if ( ! itk - > second )
{
MERROR_VER ( " Failed ring signature for tx " < < get_transaction_hash ( tx ) < < " vin key with k_image: " < < in_to_key . k_image < < " sig_index: " < < sig_index ) ;
return false ;
}
// txin has been verified already, skip
sig_index + + ;
continue ;
}
# endif
}
// make sure that output being spent matches up correctly with the
// signature spending it.
if ( ! check_tx_input ( tx . version , in_to_key , tx_prefix_hash , tx . version = = 1 ? tx . signatures [ sig_index ] : std : : vector < crypto : : signature > ( ) , tx . rct_signatures , pubkeys [ sig_index ] , pmax_used_block_height ) )
{
it - > second [ in_to_key . k_image ] = false ;
MERROR_VER ( " Failed to check ring signature for tx " < < get_transaction_hash ( tx ) < < " vin key with k_image: " < < in_to_key . k_image < < " sig_index: " < < sig_index ) ;
if ( pmax_used_block_height ) // a default value of NULL is used when called from Blockchain::handle_block_to_main_chain()
{
@ -2980,7 +2955,6 @@ bool Blockchain::check_tx_inputs(transaction& tx, tx_verification_context &tvc,
check_ring_signature ( tx_prefix_hash , in_to_key . k_image , pubkeys [ sig_index ] , tx . signatures [ sig_index ] , results [ sig_index ] ) ;
if ( ! results [ sig_index ] )
{
it - > second [ in_to_key . k_image ] = false ;
MERROR_VER ( " Failed to check ring signature for tx " < < get_transaction_hash ( tx ) < < " vin key with k_image: " < < in_to_key . k_image < < " sig_index: " < < sig_index ) ;
if ( pmax_used_block_height ) // a default value of NULL is used when called from Blockchain::handle_block_to_main_chain()
@ -2990,7 +2964,6 @@ bool Blockchain::check_tx_inputs(transaction& tx, tx_verification_context &tvc,
return false ;
}
it - > second [ in_to_key . k_image ] = true ;
}
}
@ -3008,7 +2981,6 @@ bool Blockchain::check_tx_inputs(transaction& tx, tx_verification_context &tvc,
for ( size_t i = 0 ; i < tx . vin . size ( ) ; i + + )
{
const txin_to_key & in_to_key = boost : : get < txin_to_key > ( tx . vin [ i ] ) ;
it - > second [ in_to_key . k_image ] = results [ i ] ;
if ( ! failed & & ! results [ i ] )
failed = true ;
}
@ -3182,7 +3154,7 @@ bool Blockchain::check_tx_inputs(transaction& tx, tx_verification_context &tvc,
}
//------------------------------------------------------------------
void Blockchain : : check_ring_signature ( const crypto : : hash & tx_prefix_hash , const crypto : : key_image & key_image , const std : : vector < rct : : ctkey > & pubkeys , const std : : vector < crypto : : signature > & sig , uint64_t & result )
void Blockchain : : check_ring_signature ( const crypto : : hash & tx_prefix_hash , const crypto : : key_image & key_image , const std : : vector < rct : : ctkey > & pubkeys , const std : : vector < crypto : : signature > & sig , uint64_t & result ) const
{
std : : vector < const crypto : : public_key * > p_output_keys ;
p_output_keys . reserve ( pubkeys . size ( ) ) ;
@ -3369,7 +3341,7 @@ bool Blockchain::is_tx_spendtime_unlocked(uint64_t unlock_time) const
// This function locates all outputs associated with a given input (mixins)
// and validates that they exist and are usable. It also checks the ring
// signature for each input.
bool Blockchain : : check_tx_input ( size_t tx_version , const txin_to_key & txin , const crypto : : hash & tx_prefix_hash , const std : : vector < crypto : : signature > & sig , const rct : : rctSig & rct_signatures , std : : vector < rct : : ctkey > & output_keys , uint64_t * pmax_related_block_height )
bool Blockchain : : check_tx_input ( size_t tx_version , const txin_to_key & txin , const crypto : : hash & tx_prefix_hash , const std : : vector < crypto : : signature > & sig , const rct : : rctSig & rct_signatures , std : : vector < rct : : ctkey > & output_keys , uint64_t * pmax_related_block_height ) const
{
LOG_PRINT_L3 ( " Blockchain:: " < < __func__ ) ;
@ -4208,7 +4180,6 @@ bool Blockchain::cleanup_handle_incoming_blocks(bool force_sync)
m_blocks_longhash_table . clear ( ) ;
m_scan_table . clear ( ) ;
m_blocks_txs_check . clear ( ) ;
m_check_txin_table . clear ( ) ;
// when we're well clear of the precomputed hashes, free the memory
if ( ! m_blocks_hash_check . empty ( ) & & m_db - > height ( ) > m_blocks_hash_check . size ( ) + 4096 )
@ -4497,7 +4468,6 @@ bool Blockchain::prepare_handle_incoming_blocks(const std::vector<block_complete
m_fake_pow_calc_time = 0 ;
m_scan_table . clear ( ) ;
m_check_txin_table . clear ( ) ;
TIME_MEASURE_FINISH ( prepare ) ;
m_fake_pow_calc_time = prepare / blocks_entry . size ( ) ;