mirror of
https://codeberg.org/anoncontributorxmr/monero.git
synced 2024-11-26 09:24:47 +00:00
get_blockchain_top now returns void
It was always returning true, and could not be foreseen to usefully return errors in the future. This silences CID 162652 as well as saves some checking code in a few places.
This commit is contained in:
parent
2e44d8f23c
commit
b5faac5304
6 changed files with 9 additions and 31 deletions
|
@ -211,10 +211,9 @@ namespace cryptonote
|
||||||
return m_blockchain_storage.get_current_blockchain_height();
|
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);
|
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
|
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
|
||||||
|
|
|
@ -299,10 +299,8 @@ namespace cryptonote
|
||||||
*
|
*
|
||||||
* @param height return-by-reference height of the block
|
* @param height return-by-reference height of the block
|
||||||
* @param top_id return-by-reference hash 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
|
* @copydoc Blockchain::get_blocks(uint64_t, size_t, std::list<std::pair<cryptonote::blobdata,block>>&, std::list<transaction>&) const
|
||||||
|
|
|
@ -128,11 +128,7 @@ namespace cryptonote
|
||||||
{
|
{
|
||||||
CHECK_CORE_BUSY();
|
CHECK_CORE_BUSY();
|
||||||
crypto::hash top_hash;
|
crypto::hash top_hash;
|
||||||
if (!m_core.get_blockchain_top(res.height, top_hash))
|
m_core.get_blockchain_top(res.height, top_hash);
|
||||||
{
|
|
||||||
res.status = "Failed";
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
++res.height; // turn top block height into blockchain height
|
++res.height; // turn top block height into blockchain height
|
||||||
res.top_block_hash = string_tools::pod_to_hex(top_hash);
|
res.top_block_hash = string_tools::pod_to_hex(top_hash);
|
||||||
res.target_height = m_core.get_target_blockchain_height();
|
res.target_height = m_core.get_target_blockchain_height();
|
||||||
|
@ -1061,13 +1057,7 @@ namespace cryptonote
|
||||||
}
|
}
|
||||||
uint64_t last_block_height;
|
uint64_t last_block_height;
|
||||||
crypto::hash last_block_hash;
|
crypto::hash last_block_hash;
|
||||||
bool have_last_block_hash = m_core.get_blockchain_top(last_block_height, last_block_hash);
|
m_core.get_blockchain_top(last_block_height, last_block_hash);
|
||||||
if (!have_last_block_hash)
|
|
||||||
{
|
|
||||||
error_resp.code = CORE_RPC_ERROR_CODE_INTERNAL_ERROR;
|
|
||||||
error_resp.message = "Internal error: can't get last block hash.";
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
block last_block;
|
block last_block;
|
||||||
bool have_last_block = m_core.get_block_by_hash(last_block_hash, last_block);
|
bool have_last_block = m_core.get_block_by_hash(last_block_hash, last_block);
|
||||||
if (!have_last_block)
|
if (!have_last_block)
|
||||||
|
@ -1300,11 +1290,7 @@ namespace cryptonote
|
||||||
}
|
}
|
||||||
|
|
||||||
crypto::hash top_hash;
|
crypto::hash top_hash;
|
||||||
if (!m_core.get_blockchain_top(res.height, top_hash))
|
m_core.get_blockchain_top(res.height, top_hash);
|
||||||
{
|
|
||||||
res.status = "Failed";
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
++res.height; // turn top block height into blockchain height
|
++res.height; // turn top block height into blockchain height
|
||||||
res.top_block_hash = string_tools::pod_to_hex(top_hash);
|
res.top_block_hash = string_tools::pod_to_hex(top_hash);
|
||||||
res.target_height = m_core.get_target_blockchain_height();
|
res.target_height = m_core.get_target_blockchain_height();
|
||||||
|
@ -1716,11 +1702,7 @@ namespace cryptonote
|
||||||
}
|
}
|
||||||
|
|
||||||
crypto::hash top_hash;
|
crypto::hash top_hash;
|
||||||
if (!m_core.get_blockchain_top(res.height, top_hash))
|
m_core.get_blockchain_top(res.height, top_hash);
|
||||||
{
|
|
||||||
res.status = "Failed";
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
++res.height; // turn top block height into blockchain height
|
++res.height; // turn top block height into blockchain height
|
||||||
res.target_height = m_core.get_target_blockchain_height();
|
res.target_height = m_core.get_target_blockchain_height();
|
||||||
|
|
||||||
|
|
|
@ -229,10 +229,9 @@ bool tests::proxy_core::get_short_chain_history(std::list<crypto::hash>& ids) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool tests::proxy_core::get_blockchain_top(uint64_t& height, crypto::hash& top_id) {
|
void tests::proxy_core::get_blockchain_top(uint64_t& height, crypto::hash& top_id) {
|
||||||
height = 0;
|
height = 0;
|
||||||
top_id = get_block_hash(m_genesis);
|
top_id = get_block_hash(m_genesis);
|
||||||
return true;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
bool tests::proxy_core::init(const boost::program_options::variables_map& /*vm*/) {
|
bool tests::proxy_core::init(const boost::program_options::variables_map& /*vm*/) {
|
||||||
|
|
|
@ -74,7 +74,7 @@ namespace tests
|
||||||
bool get_short_chain_history(std::list<crypto::hash>& ids);
|
bool get_short_chain_history(std::list<crypto::hash>& ids);
|
||||||
bool get_stat_info(cryptonote::core_stat_info& st_inf){return true;}
|
bool get_stat_info(cryptonote::core_stat_info& st_inf){return true;}
|
||||||
bool have_block(const crypto::hash& id);
|
bool have_block(const crypto::hash& id);
|
||||||
bool get_blockchain_top(uint64_t& height, crypto::hash& top_id);
|
void get_blockchain_top(uint64_t& height, crypto::hash& top_id);
|
||||||
bool handle_incoming_tx(const cryptonote::blobdata& tx_blob, cryptonote::tx_verification_context& tvc, bool keeped_by_block, bool relayed, bool do_not_relay);
|
bool handle_incoming_tx(const cryptonote::blobdata& tx_blob, cryptonote::tx_verification_context& tvc, bool keeped_by_block, bool relayed, bool do_not_relay);
|
||||||
bool handle_incoming_txs(const std::list<cryptonote::blobdata>& tx_blobs, std::vector<cryptonote::tx_verification_context>& tvc, bool keeped_by_block, bool relayed, bool do_not_relay);
|
bool handle_incoming_txs(const std::list<cryptonote::blobdata>& tx_blobs, std::vector<cryptonote::tx_verification_context>& tvc, bool keeped_by_block, bool relayed, bool do_not_relay);
|
||||||
bool handle_incoming_block(const cryptonote::blobdata& block_blob, cryptonote::block_verification_context& bvc, bool update_miner_blocktemplate = true);
|
bool handle_incoming_block(const cryptonote::blobdata& block_blob, cryptonote::block_verification_context& bvc, bool update_miner_blocktemplate = true);
|
||||||
|
|
|
@ -51,7 +51,7 @@ public:
|
||||||
bool get_short_chain_history(std::list<crypto::hash>& ids) const { return true; }
|
bool get_short_chain_history(std::list<crypto::hash>& ids) const { return true; }
|
||||||
bool get_stat_info(cryptonote::core_stat_info& st_inf) const {return true;}
|
bool get_stat_info(cryptonote::core_stat_info& st_inf) const {return true;}
|
||||||
bool have_block(const crypto::hash& id) const {return true;}
|
bool have_block(const crypto::hash& id) const {return true;}
|
||||||
bool get_blockchain_top(uint64_t& height, crypto::hash& top_id)const{height=0;top_id=cryptonote::null_hash;return true;}
|
void get_blockchain_top(uint64_t& height, crypto::hash& top_id)const{height=0;top_id=cryptonote::null_hash;}
|
||||||
bool handle_incoming_tx(const cryptonote::blobdata& tx_blob, cryptonote::tx_verification_context& tvc, bool keeped_by_block, bool relayed, bool do_not_relay) { return true; }
|
bool handle_incoming_tx(const cryptonote::blobdata& tx_blob, cryptonote::tx_verification_context& tvc, bool keeped_by_block, bool relayed, bool do_not_relay) { return true; }
|
||||||
bool handle_incoming_txs(const std::list<cryptonote::blobdata>& tx_blob, std::vector<cryptonote::tx_verification_context>& tvc, bool keeped_by_block, bool relayed, bool do_not_relay) { return true; }
|
bool handle_incoming_txs(const std::list<cryptonote::blobdata>& tx_blob, std::vector<cryptonote::tx_verification_context>& tvc, bool keeped_by_block, bool relayed, bool do_not_relay) { return true; }
|
||||||
bool handle_incoming_block(const cryptonote::blobdata& block_blob, cryptonote::block_verification_context& bvc, bool update_miner_blocktemplate = true) { return true; }
|
bool handle_incoming_block(const cryptonote::blobdata& block_blob, cryptonote::block_verification_context& bvc, bool update_miner_blocktemplate = true) { return true; }
|
||||||
|
|
Loading…
Reference in a new issue