aboutsummaryrefslogtreecommitdiff
path: root/src/cryptonote_core
diff options
context:
space:
mode:
authorRiccardo Spagni <ric@spagni.net>2017-09-25 16:52:27 +0200
committerRiccardo Spagni <ric@spagni.net>2017-09-25 16:52:27 +0200
commitc2346c6c599211a7e9fa8d39f0750fb059cf71b2 (patch)
tree6dfa55c8096c6bda4783f481a03e71642eda7d3f /src/cryptonote_core
parentMerge pull request #2443 (diff)
parenttx_pool: pre-init tvc.m_verifivation_failed before processing (diff)
downloadmonero-c2346c6c599211a7e9fa8d39f0750fb059cf71b2.tar.xz
Merge pull request #2424
28b72b6e tx_pool: pre-init tvc.m_verifivation_failed before processing (moneromooo-monero) 50a629b2 core_tests: catch (impossible in practice) tx extra api failure (moneromooo-monero) fee15ef1 wallet2: catch failure to parse address (moneromooo-monero) 1399e26d net_peerlist: remove dead code (moneromooo-monero) 50e09698 tx_pool: guard against failure getting tx hash (moneromooo-monero) 54cc209a wallet_rpc_server: catch failure to create directory (moneromooo-monero) 3e55099c wallet_rpc_server: init m_vm to NULL in ctor (moneromooo-monero) 7d0dde5e wallet_args: remove redundant default value for --log-file (moneromooo-monero) ed4a3350 wallet2: catch failure to save keys file (moneromooo-monero) 44434c8a wallet2_api: check whether dynamic_cast returns NULL (moneromooo-monero) 92f2f687 core: check return value from parse_hexstr_to_binbuff (moneromooo-monero) 5475692e wallet2_api: remove an unused, uninitialized, field (moneromooo-monero) a7ba3de1 libwallet_api_tests: initialize newblock_triggered on reset (moneromooo-monero) b2763ace wallet2_api: init error code to "no error" in the ctor (moneromooo-monero) b5faac53 get_blockchain_top now returns void (moneromooo-monero) 2e44d8f2 wallet_rpc_server: guard against exceptions (moneromooo-monero) 4230876b simplewallet: guard against I/O exceptions (moneromooo-monero) 06c1e057 daemon: initialize decode_as_json in RPC request (moneromooo-monero) 11f71af5 http_base: init size_t in http_request_info ctor (moneromooo-monero)
Diffstat (limited to 'src/cryptonote_core')
-rw-r--r--src/cryptonote_core/cryptonote_core.cpp3
-rw-r--r--src/cryptonote_core/cryptonote_core.h4
-rw-r--r--src/cryptonote_core/cryptonote_tx_utils.cpp5
-rw-r--r--src/cryptonote_core/tx_pool.cpp9
4 files changed, 10 insertions, 11 deletions
diff --git a/src/cryptonote_core/cryptonote_core.cpp b/src/cryptonote_core/cryptonote_core.cpp
index 56485aedf..14e37d580 100644
--- a/src/cryptonote_core/cryptonote_core.cpp
+++ b/src/cryptonote_core/cryptonote_core.cpp
@@ -211,10 +211,9 @@ namespace cryptonote
return m_blockchain_storage.get_current_blockchain_height();
}
//-----------------------------------------------------------------------------------------------
- bool core::get_blockchain_top(uint64_t& height, crypto::hash& top_id) const
+ void core::get_blockchain_top(uint64_t& height, crypto::hash& top_id) const
{
top_id = m_blockchain_storage.get_tail_id(height);
- return true;
}
//-----------------------------------------------------------------------------------------------
bool core::get_blocks(uint64_t start_offset, size_t count, std::list<std::pair<cryptonote::blobdata,block>>& blocks, std::list<cryptonote::blobdata>& txs) const
diff --git a/src/cryptonote_core/cryptonote_core.h b/src/cryptonote_core/cryptonote_core.h
index 4ea33dbe1..1aed86b25 100644
--- a/src/cryptonote_core/cryptonote_core.h
+++ b/src/cryptonote_core/cryptonote_core.h
@@ -299,10 +299,8 @@ namespace cryptonote
*
* @param height return-by-reference height of the block
* @param top_id return-by-reference hash of the block
- *
- * @return true
*/
- bool get_blockchain_top(uint64_t& height, crypto::hash& top_id) const;
+ void get_blockchain_top(uint64_t& height, crypto::hash& top_id) const;
/**
* @copydoc Blockchain::get_blocks(uint64_t, size_t, std::list<std::pair<cryptonote::blobdata,block>>&, std::list<transaction>&) const
diff --git a/src/cryptonote_core/cryptonote_tx_utils.cpp b/src/cryptonote_core/cryptonote_tx_utils.cpp
index 9b442029a..d2a7eedf5 100644
--- a/src/cryptonote_core/cryptonote_tx_utils.cpp
+++ b/src/cryptonote_core/cryptonote_tx_utils.cpp
@@ -510,8 +510,9 @@ namespace cryptonote
std::string genesis_coinbase_tx_hex = config::GENESIS_TX;
blobdata tx_bl;
- string_tools::parse_hexstr_to_binbuff(genesis_coinbase_tx_hex, tx_bl);
- bool r = parse_and_validate_tx_from_blob(tx_bl, bl.miner_tx);
+ bool r = string_tools::parse_hexstr_to_binbuff(genesis_coinbase_tx_hex, tx_bl);
+ CHECK_AND_ASSERT_MES(r, false, "failed to parse coinbase tx from hard coded blob");
+ r = parse_and_validate_tx_from_blob(tx_bl, bl.miner_tx);
CHECK_AND_ASSERT_MES(r, false, "failed to parse coinbase tx from hard coded blob");
bl.major_version = CURRENT_BLOCK_MAJOR_VERSION;
bl.minor_version = CURRENT_BLOCK_MINOR_VERSION;
diff --git a/src/cryptonote_core/tx_pool.cpp b/src/cryptonote_core/tx_pool.cpp
index c31441a99..0485f731f 100644
--- a/src/cryptonote_core/tx_pool.cpp
+++ b/src/cryptonote_core/tx_pool.cpp
@@ -202,6 +202,9 @@ namespace cryptonote
return false;
}
+ // assume failure during verification steps until success is certain
+ tvc.m_verifivation_failed = true;
+
time_t receive_time = time(nullptr);
crypto::hash max_used_block_id = null_hash;
@@ -285,9 +288,6 @@ namespace cryptonote
tvc.m_should_be_relayed = true;
}
- // assume failure during verification steps until success is certain
- tvc.m_verifivation_failed = true;
-
tvc.m_verifivation_failed = false;
MINFO("Transaction added to pool: txid " << id << " bytes: " << blob_size << " fee/byte: " << (fee / (double)blob_size));
@@ -298,7 +298,8 @@ namespace cryptonote
{
crypto::hash h = null_hash;
size_t blob_size = 0;
- get_transaction_hash(tx, h, blob_size);
+ if (!get_transaction_hash(tx, h, blob_size) || blob_size == 0)
+ return false;
return add_tx(tx, h, blob_size, tvc, keeped_by_block, relayed, do_not_relay, version);
}
//---------------------------------------------------------------------------------