|
|
|
@ -724,7 +724,7 @@ namespace cryptonote
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
//-----------------------------------------------------------------------------------------------
|
|
|
|
|
bool core::handle_incoming_tx_pre(const blobdata& tx_blob, tx_verification_context& tvc, cryptonote::transaction &tx, crypto::hash &tx_hash, crypto::hash &tx_prefixt_hash, bool keeped_by_block, bool relayed, bool do_not_relay)
|
|
|
|
|
bool core::handle_incoming_tx_pre(const blobdata& tx_blob, tx_verification_context& tvc, cryptonote::transaction &tx, crypto::hash &tx_hash, bool keeped_by_block, bool relayed, bool do_not_relay)
|
|
|
|
|
{
|
|
|
|
|
tvc = boost::value_initialized<tx_verification_context>();
|
|
|
|
|
|
|
|
|
@ -737,9 +737,8 @@ namespace cryptonote
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
tx_hash = crypto::null_hash;
|
|
|
|
|
tx_prefixt_hash = crypto::null_hash;
|
|
|
|
|
|
|
|
|
|
if(!parse_tx_from_blob(tx, tx_hash, tx_prefixt_hash, tx_blob))
|
|
|
|
|
if(!parse_tx_from_blob(tx, tx_hash, tx_blob))
|
|
|
|
|
{
|
|
|
|
|
LOG_PRINT_L1("WRONG TRANSACTION BLOB, Failed to parse, rejected");
|
|
|
|
|
tvc.m_verifivation_failed = true;
|
|
|
|
@ -772,7 +771,7 @@ namespace cryptonote
|
|
|
|
|
return true;
|
|
|
|
|
}
|
|
|
|
|
//-----------------------------------------------------------------------------------------------
|
|
|
|
|
bool core::handle_incoming_tx_post(const blobdata& tx_blob, tx_verification_context& tvc, cryptonote::transaction &tx, crypto::hash &tx_hash, crypto::hash &tx_prefixt_hash, bool keeped_by_block, bool relayed, bool do_not_relay)
|
|
|
|
|
bool core::handle_incoming_tx_post(const blobdata& tx_blob, tx_verification_context& tvc, cryptonote::transaction &tx, crypto::hash &tx_hash, bool keeped_by_block, bool relayed, bool do_not_relay)
|
|
|
|
|
{
|
|
|
|
|
if(!check_tx_syntax(tx))
|
|
|
|
|
{
|
|
|
|
@ -906,7 +905,7 @@ namespace cryptonote
|
|
|
|
|
TRY_ENTRY();
|
|
|
|
|
CRITICAL_REGION_LOCAL(m_incoming_tx_lock);
|
|
|
|
|
|
|
|
|
|
struct result { bool res; cryptonote::transaction tx; crypto::hash hash; crypto::hash prefix_hash; };
|
|
|
|
|
struct result { bool res; cryptonote::transaction tx; crypto::hash hash; };
|
|
|
|
|
std::vector<result> results(tx_blobs.size());
|
|
|
|
|
|
|
|
|
|
tvc.resize(tx_blobs.size());
|
|
|
|
@ -917,7 +916,7 @@ namespace cryptonote
|
|
|
|
|
tpool.submit(&waiter, [&, i, it] {
|
|
|
|
|
try
|
|
|
|
|
{
|
|
|
|
|
results[i].res = handle_incoming_tx_pre(*it, tvc[i], results[i].tx, results[i].hash, results[i].prefix_hash, keeped_by_block, relayed, do_not_relay);
|
|
|
|
|
results[i].res = handle_incoming_tx_pre(*it, tvc[i], results[i].tx, results[i].hash, keeped_by_block, relayed, do_not_relay);
|
|
|
|
|
}
|
|
|
|
|
catch (const std::exception &e)
|
|
|
|
|
{
|
|
|
|
@ -947,7 +946,7 @@ namespace cryptonote
|
|
|
|
|
tpool.submit(&waiter, [&, i, it] {
|
|
|
|
|
try
|
|
|
|
|
{
|
|
|
|
|
results[i].res = handle_incoming_tx_post(*it, tvc[i], results[i].tx, results[i].hash, results[i].prefix_hash, keeped_by_block, relayed, do_not_relay);
|
|
|
|
|
results[i].res = handle_incoming_tx_post(*it, tvc[i], results[i].tx, results[i].hash, keeped_by_block, relayed, do_not_relay);
|
|
|
|
|
}
|
|
|
|
|
catch (const std::exception &e)
|
|
|
|
|
{
|
|
|
|
@ -983,7 +982,7 @@ namespace cryptonote
|
|
|
|
|
continue;
|
|
|
|
|
|
|
|
|
|
const size_t weight = get_transaction_weight(results[i].tx, it->size());
|
|
|
|
|
ok &= add_new_tx(results[i].tx, results[i].hash, tx_blobs[i], results[i].prefix_hash, weight, tvc[i], keeped_by_block, relayed, do_not_relay);
|
|
|
|
|
ok &= add_new_tx(results[i].tx, results[i].hash, tx_blobs[i], weight, tvc[i], keeped_by_block, relayed, do_not_relay);
|
|
|
|
|
if(tvc[i].m_verifivation_failed)
|
|
|
|
|
{MERROR_VER("Transaction verification failed: " << results[i].hash);}
|
|
|
|
|
else if(tvc[i].m_verifivation_impossible)
|
|
|
|
@ -1197,11 +1196,10 @@ namespace cryptonote
|
|
|
|
|
bool core::add_new_tx(transaction& tx, tx_verification_context& tvc, bool keeped_by_block, bool relayed, bool do_not_relay)
|
|
|
|
|
{
|
|
|
|
|
crypto::hash tx_hash = get_transaction_hash(tx);
|
|
|
|
|
crypto::hash tx_prefix_hash = get_transaction_prefix_hash(tx);
|
|
|
|
|
blobdata bl;
|
|
|
|
|
t_serializable_object_to_blob(tx, bl);
|
|
|
|
|
size_t tx_weight = get_transaction_weight(tx, bl.size());
|
|
|
|
|
return add_new_tx(tx, tx_hash, bl, tx_prefix_hash, tx_weight, tvc, keeped_by_block, relayed, do_not_relay);
|
|
|
|
|
return add_new_tx(tx, tx_hash, bl, tx_weight, tvc, keeped_by_block, relayed, do_not_relay);
|
|
|
|
|
}
|
|
|
|
|
//-----------------------------------------------------------------------------------------------
|
|
|
|
|
size_t core::get_blockchain_total_transactions() const
|
|
|
|
@ -1209,7 +1207,7 @@ namespace cryptonote
|
|
|
|
|
return m_blockchain_storage.get_total_transactions();
|
|
|
|
|
}
|
|
|
|
|
//-----------------------------------------------------------------------------------------------
|
|
|
|
|
bool core::add_new_tx(transaction& tx, const crypto::hash& tx_hash, const cryptonote::blobdata &blob, const crypto::hash& tx_prefix_hash, size_t tx_weight, tx_verification_context& tvc, bool keeped_by_block, bool relayed, bool do_not_relay)
|
|
|
|
|
bool core::add_new_tx(transaction& tx, const crypto::hash& tx_hash, const cryptonote::blobdata &blob, size_t tx_weight, tx_verification_context& tvc, bool keeped_by_block, bool relayed, bool do_not_relay)
|
|
|
|
|
{
|
|
|
|
|
if(m_mempool.have_tx(tx_hash))
|
|
|
|
|
{
|
|
|
|
@ -1250,8 +1248,8 @@ namespace cryptonote
|
|
|
|
|
{
|
|
|
|
|
std::vector<std::pair<crypto::hash, cryptonote::blobdata>> txs;
|
|
|
|
|
cryptonote::transaction tx;
|
|
|
|
|
crypto::hash tx_hash, tx_prefix_hash;
|
|
|
|
|
if (!parse_and_validate_tx_from_blob(tx_blob, tx, tx_hash, tx_prefix_hash))
|
|
|
|
|
crypto::hash tx_hash;
|
|
|
|
|
if (!parse_and_validate_tx_from_blob(tx_blob, tx, tx_hash))
|
|
|
|
|
{
|
|
|
|
|
LOG_ERROR("Failed to parse relayed transaction");
|
|
|
|
|
return;
|
|
|
|
@ -1466,9 +1464,9 @@ namespace cryptonote
|
|
|
|
|
return m_blockchain_storage.have_block(id);
|
|
|
|
|
}
|
|
|
|
|
//-----------------------------------------------------------------------------------------------
|
|
|
|
|
bool core::parse_tx_from_blob(transaction& tx, crypto::hash& tx_hash, crypto::hash& tx_prefix_hash, const blobdata& blob) const
|
|
|
|
|
bool core::parse_tx_from_blob(transaction& tx, crypto::hash& tx_hash, const blobdata& blob) const
|
|
|
|
|
{
|
|
|
|
|
return parse_and_validate_tx_from_blob(blob, tx, tx_hash, tx_prefix_hash);
|
|
|
|
|
return parse_and_validate_tx_from_blob(blob, tx, tx_hash);
|
|
|
|
|
}
|
|
|
|
|
//-----------------------------------------------------------------------------------------------
|
|
|
|
|
bool core::check_tx_syntax(const transaction& tx) const
|
|
|
|
|