blockchain_db: add "raw" blobdata getters for block and transaction
This speeds up operations such as serving blocks to syncing peers
This commit is contained in:
parent
3f171b931f
commit
0288310e3b
|
@ -200,6 +200,45 @@ void BlockchainDB::remove_transaction(const crypto::hash& tx_hash)
|
||||||
remove_transaction_data(tx_hash, tx);
|
remove_transaction_data(tx_hash, tx);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
block BlockchainDB::get_block_from_height(const uint64_t& height) const
|
||||||
|
{
|
||||||
|
blobdata bd = get_block_blob_from_height(height);
|
||||||
|
block b;
|
||||||
|
if (!parse_and_validate_block_from_blob(bd, b))
|
||||||
|
throw new DB_ERROR("Failed to parse block from blob retrieved from the db");
|
||||||
|
|
||||||
|
return b;
|
||||||
|
}
|
||||||
|
|
||||||
|
block BlockchainDB::get_block(const crypto::hash& h) const
|
||||||
|
{
|
||||||
|
blobdata bd = get_block_blob(h);
|
||||||
|
block b;
|
||||||
|
if (!parse_and_validate_block_from_blob(bd, b))
|
||||||
|
throw new DB_ERROR("Failed to parse block from blob retrieved from the db");
|
||||||
|
|
||||||
|
return b;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool BlockchainDB::get_tx(const crypto::hash& h, cryptonote::transaction &tx) const
|
||||||
|
{
|
||||||
|
blobdata bd;
|
||||||
|
if (!get_tx_blob(h, bd))
|
||||||
|
return false;
|
||||||
|
if (!parse_and_validate_tx_from_blob(bd, tx))
|
||||||
|
throw new DB_ERROR("Failed to parse transaction from blob retrieved from the db");
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
transaction BlockchainDB::get_tx(const crypto::hash& h) const
|
||||||
|
{
|
||||||
|
transaction tx;
|
||||||
|
if (!get_tx(h, tx))
|
||||||
|
throw new TX_DNE(std::string("tx with hash ").append(epee::string_tools::pod_to_hex(h)).append(" not found in db").c_str());
|
||||||
|
return tx;
|
||||||
|
}
|
||||||
|
|
||||||
void BlockchainDB::reset_stats()
|
void BlockchainDB::reset_stats()
|
||||||
{
|
{
|
||||||
num_calls = 0;
|
num_calls = 0;
|
||||||
|
|
|
@ -34,6 +34,7 @@
|
||||||
#include <string>
|
#include <string>
|
||||||
#include <exception>
|
#include <exception>
|
||||||
#include "crypto/hash.h"
|
#include "crypto/hash.h"
|
||||||
|
#include "cryptonote_protocol/blobdatatype.h"
|
||||||
#include "cryptonote_basic/cryptonote_basic.h"
|
#include "cryptonote_basic/cryptonote_basic.h"
|
||||||
#include "cryptonote_basic/difficulty.h"
|
#include "cryptonote_basic/difficulty.h"
|
||||||
#include "cryptonote_basic/hardfork.h"
|
#include "cryptonote_basic/hardfork.h"
|
||||||
|
@ -754,7 +755,20 @@ public:
|
||||||
*
|
*
|
||||||
* @return the block requested
|
* @return the block requested
|
||||||
*/
|
*/
|
||||||
virtual block get_block(const crypto::hash& h) const = 0;
|
virtual cryptonote::blobdata get_block_blob(const crypto::hash& h) const = 0;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief fetches the block with the given hash
|
||||||
|
*
|
||||||
|
* Returns the requested block.
|
||||||
|
*
|
||||||
|
* If the block does not exist, the subclass should throw BLOCK_DNE
|
||||||
|
*
|
||||||
|
* @param h the hash to look for
|
||||||
|
*
|
||||||
|
* @return the block requested
|
||||||
|
*/
|
||||||
|
block get_block(const crypto::hash& h) const;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief gets the height of the block with a given hash
|
* @brief gets the height of the block with a given hash
|
||||||
|
@ -784,7 +798,7 @@ public:
|
||||||
virtual block_header get_block_header(const crypto::hash& h) const = 0;
|
virtual block_header get_block_header(const crypto::hash& h) const = 0;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief fetch a block by height
|
* @brief fetch a block blob by height
|
||||||
*
|
*
|
||||||
* The subclass should return the block at the given height.
|
* The subclass should return the block at the given height.
|
||||||
*
|
*
|
||||||
|
@ -793,9 +807,21 @@ public:
|
||||||
*
|
*
|
||||||
* @param height the height to look for
|
* @param height the height to look for
|
||||||
*
|
*
|
||||||
|
* @return the block blob
|
||||||
|
*/
|
||||||
|
virtual cryptonote::blobdata get_block_blob_from_height(const uint64_t& height) const = 0;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief fetch a block by height
|
||||||
|
*
|
||||||
|
* If the block does not exist, that is to say if the blockchain is not
|
||||||
|
* that high, then the subclass should throw BLOCK_DNE
|
||||||
|
*
|
||||||
|
* @param height the height to look for
|
||||||
|
*
|
||||||
* @return the block
|
* @return the block
|
||||||
*/
|
*/
|
||||||
virtual block get_block_from_height(const uint64_t& height) const = 0;
|
block get_block_from_height(const uint64_t& height) const;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief fetch a block's timestamp
|
* @brief fetch a block's timestamp
|
||||||
|
@ -1009,20 +1035,28 @@ public:
|
||||||
/**
|
/**
|
||||||
* @brief fetches the transaction with the given hash
|
* @brief fetches the transaction with the given hash
|
||||||
*
|
*
|
||||||
* The subclass should return the transaction stored which has the given
|
|
||||||
* hash.
|
|
||||||
*
|
|
||||||
* If the transaction does not exist, the subclass should throw TX_DNE.
|
* If the transaction does not exist, the subclass should throw TX_DNE.
|
||||||
*
|
*
|
||||||
* @param h the hash to look for
|
* @param h the hash to look for
|
||||||
*
|
*
|
||||||
* @return the transaction with the given hash
|
* @return the transaction with the given hash
|
||||||
*/
|
*/
|
||||||
virtual transaction get_tx(const crypto::hash& h) const = 0;
|
transaction get_tx(const crypto::hash& h) const;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief fetches the transaction with the given hash
|
* @brief fetches the transaction with the given hash
|
||||||
*
|
*
|
||||||
|
* If the transaction does not exist, the subclass should return false.
|
||||||
|
*
|
||||||
|
* @param h the hash to look for
|
||||||
|
*
|
||||||
|
* @return true iff the transaction was found
|
||||||
|
*/
|
||||||
|
bool get_tx(const crypto::hash& h, transaction &tx) const;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief fetches the transaction blob with the given hash
|
||||||
|
*
|
||||||
* The subclass should return the transaction stored which has the given
|
* The subclass should return the transaction stored which has the given
|
||||||
* hash.
|
* hash.
|
||||||
*
|
*
|
||||||
|
@ -1032,7 +1066,7 @@ public:
|
||||||
*
|
*
|
||||||
* @return true iff the transaction was found
|
* @return true iff the transaction was found
|
||||||
*/
|
*/
|
||||||
virtual bool get_tx(const crypto::hash& h, transaction &tx) const = 0;
|
virtual bool get_tx_blob(const crypto::hash& h, cryptonote::blobdata &tx) const = 0;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief fetches the total number of transactions ever
|
* @brief fetches the total number of transactions ever
|
||||||
|
|
|
@ -1429,12 +1429,12 @@ bool BlockchainLMDB::block_exists(const crypto::hash& h, uint64_t *height) const
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
block BlockchainLMDB::get_block(const crypto::hash& h) const
|
cryptonote::blobdata BlockchainLMDB::get_block_blob(const crypto::hash& h) const
|
||||||
{
|
{
|
||||||
LOG_PRINT_L3("BlockchainLMDB::" << __func__);
|
LOG_PRINT_L3("BlockchainLMDB::" << __func__);
|
||||||
check_open();
|
check_open();
|
||||||
|
|
||||||
return get_block_from_height(get_block_height(h));
|
return get_block_blob_from_height(get_block_height(h));
|
||||||
}
|
}
|
||||||
|
|
||||||
uint64_t BlockchainLMDB::get_block_height(const crypto::hash& h) const
|
uint64_t BlockchainLMDB::get_block_height(const crypto::hash& h) const
|
||||||
|
@ -1467,7 +1467,7 @@ block_header BlockchainLMDB::get_block_header(const crypto::hash& h) const
|
||||||
return get_block(h);
|
return get_block(h);
|
||||||
}
|
}
|
||||||
|
|
||||||
block BlockchainLMDB::get_block_from_height(const uint64_t& height) const
|
cryptonote::blobdata BlockchainLMDB::get_block_blob_from_height(const uint64_t& height) const
|
||||||
{
|
{
|
||||||
LOG_PRINT_L3("BlockchainLMDB::" << __func__);
|
LOG_PRINT_L3("BlockchainLMDB::" << __func__);
|
||||||
check_open();
|
check_open();
|
||||||
|
@ -1488,13 +1488,9 @@ block BlockchainLMDB::get_block_from_height(const uint64_t& height) const
|
||||||
blobdata bd;
|
blobdata bd;
|
||||||
bd.assign(reinterpret_cast<char*>(result.mv_data), result.mv_size);
|
bd.assign(reinterpret_cast<char*>(result.mv_data), result.mv_size);
|
||||||
|
|
||||||
block b;
|
|
||||||
if (!parse_and_validate_block_from_blob(bd, b))
|
|
||||||
throw0(DB_ERROR("Failed to parse block from blob retrieved from the db"));
|
|
||||||
|
|
||||||
TXN_POSTFIX_RDONLY();
|
TXN_POSTFIX_RDONLY();
|
||||||
|
|
||||||
return b;
|
return bd;
|
||||||
}
|
}
|
||||||
|
|
||||||
uint64_t BlockchainLMDB::get_block_timestamp(const uint64_t& height) const
|
uint64_t BlockchainLMDB::get_block_timestamp(const uint64_t& height) const
|
||||||
|
@ -1809,7 +1805,7 @@ uint64_t BlockchainLMDB::get_tx_unlock_time(const crypto::hash& h) const
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool BlockchainLMDB::get_tx(const crypto::hash& h, transaction &tx) const
|
bool BlockchainLMDB::get_tx_blob(const crypto::hash& h, cryptonote::blobdata &bd) const
|
||||||
{
|
{
|
||||||
LOG_PRINT_L3("BlockchainLMDB::" << __func__);
|
LOG_PRINT_L3("BlockchainLMDB::" << __func__);
|
||||||
check_open();
|
check_open();
|
||||||
|
@ -1832,26 +1828,13 @@ bool BlockchainLMDB::get_tx(const crypto::hash& h, transaction &tx) const
|
||||||
else if (get_result)
|
else if (get_result)
|
||||||
throw0(DB_ERROR(lmdb_error("DB error attempting to fetch tx from hash", get_result).c_str()));
|
throw0(DB_ERROR(lmdb_error("DB error attempting to fetch tx from hash", get_result).c_str()));
|
||||||
|
|
||||||
blobdata bd;
|
|
||||||
bd.assign(reinterpret_cast<char*>(result.mv_data), result.mv_size);
|
bd.assign(reinterpret_cast<char*>(result.mv_data), result.mv_size);
|
||||||
|
|
||||||
if (!parse_and_validate_tx_from_blob(bd, tx))
|
|
||||||
throw0(DB_ERROR("Failed to parse tx from blob retrieved from the db"));
|
|
||||||
|
|
||||||
TXN_POSTFIX_RDONLY();
|
TXN_POSTFIX_RDONLY();
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
transaction BlockchainLMDB::get_tx(const crypto::hash& h) const
|
|
||||||
{
|
|
||||||
transaction tx;
|
|
||||||
|
|
||||||
if (!get_tx(h, tx))
|
|
||||||
throw1(TX_DNE(std::string("tx with hash ").append(epee::string_tools::pod_to_hex(h)).append(" not found in db").c_str()));
|
|
||||||
return tx;
|
|
||||||
}
|
|
||||||
|
|
||||||
uint64_t BlockchainLMDB::get_tx_count() const
|
uint64_t BlockchainLMDB::get_tx_count() const
|
||||||
{
|
{
|
||||||
LOG_PRINT_L3("BlockchainLMDB::" << __func__);
|
LOG_PRINT_L3("BlockchainLMDB::" << __func__);
|
||||||
|
|
|
@ -170,13 +170,13 @@ public:
|
||||||
|
|
||||||
virtual bool block_exists(const crypto::hash& h, uint64_t *height = NULL) const;
|
virtual bool block_exists(const crypto::hash& h, uint64_t *height = NULL) const;
|
||||||
|
|
||||||
virtual block get_block(const crypto::hash& h) const;
|
|
||||||
|
|
||||||
virtual uint64_t get_block_height(const crypto::hash& h) const;
|
virtual uint64_t get_block_height(const crypto::hash& h) const;
|
||||||
|
|
||||||
virtual block_header get_block_header(const crypto::hash& h) const;
|
virtual block_header get_block_header(const crypto::hash& h) const;
|
||||||
|
|
||||||
virtual block get_block_from_height(const uint64_t& height) const;
|
virtual cryptonote::blobdata get_block_blob(const crypto::hash& h) const;
|
||||||
|
|
||||||
|
virtual cryptonote::blobdata get_block_blob_from_height(const uint64_t& height) const;
|
||||||
|
|
||||||
virtual uint64_t get_block_timestamp(const uint64_t& height) const;
|
virtual uint64_t get_block_timestamp(const uint64_t& height) const;
|
||||||
|
|
||||||
|
@ -207,9 +207,7 @@ public:
|
||||||
|
|
||||||
virtual uint64_t get_tx_unlock_time(const crypto::hash& h) const;
|
virtual uint64_t get_tx_unlock_time(const crypto::hash& h) const;
|
||||||
|
|
||||||
virtual transaction get_tx(const crypto::hash& h) const;
|
virtual bool get_tx_blob(const crypto::hash& h, cryptonote::blobdata &tx) const;
|
||||||
|
|
||||||
virtual bool get_tx(const crypto::hash& h, transaction &tx) const;
|
|
||||||
|
|
||||||
virtual uint64_t get_tx_count() const;
|
virtual uint64_t get_tx_count() const;
|
||||||
|
|
||||||
|
|
|
@ -1431,7 +1431,7 @@ bool Blockchain::handle_alternative_block(const block& b, const crypto::hash& id
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
//------------------------------------------------------------------
|
//------------------------------------------------------------------
|
||||||
bool Blockchain::get_blocks(uint64_t start_offset, size_t count, std::list<block>& blocks, std::list<transaction>& txs) const
|
bool Blockchain::get_blocks(uint64_t start_offset, size_t count, std::list<std::pair<cryptonote::blobdata,block>>& blocks, std::list<cryptonote::blobdata>& txs) const
|
||||||
{
|
{
|
||||||
LOG_PRINT_L3("Blockchain::" << __func__);
|
LOG_PRINT_L3("Blockchain::" << __func__);
|
||||||
CRITICAL_REGION_LOCAL(m_blockchain_lock);
|
CRITICAL_REGION_LOCAL(m_blockchain_lock);
|
||||||
|
@ -1443,17 +1443,17 @@ bool Blockchain::get_blocks(uint64_t start_offset, size_t count, std::list<block
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
for(const block& blk : blocks)
|
for(const auto& blk : blocks)
|
||||||
{
|
{
|
||||||
std::list<crypto::hash> missed_ids;
|
std::list<crypto::hash> missed_ids;
|
||||||
get_transactions(blk.tx_hashes, txs, missed_ids);
|
get_transactions_blobs(blk.second.tx_hashes, txs, missed_ids);
|
||||||
CHECK_AND_ASSERT_MES(!missed_ids.size(), false, "has missed transactions in own block in main blockchain");
|
CHECK_AND_ASSERT_MES(!missed_ids.size(), false, "has missed transactions in own block in main blockchain");
|
||||||
}
|
}
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
//------------------------------------------------------------------
|
//------------------------------------------------------------------
|
||||||
bool Blockchain::get_blocks(uint64_t start_offset, size_t count, std::list<block>& blocks) const
|
bool Blockchain::get_blocks(uint64_t start_offset, size_t count, std::list<std::pair<cryptonote::blobdata,block>>& blocks) const
|
||||||
{
|
{
|
||||||
LOG_PRINT_L3("Blockchain::" << __func__);
|
LOG_PRINT_L3("Blockchain::" << __func__);
|
||||||
CRITICAL_REGION_LOCAL(m_blockchain_lock);
|
CRITICAL_REGION_LOCAL(m_blockchain_lock);
|
||||||
|
@ -1462,7 +1462,12 @@ bool Blockchain::get_blocks(uint64_t start_offset, size_t count, std::list<block
|
||||||
|
|
||||||
for(size_t i = start_offset; i < start_offset + count && i < m_db->height();i++)
|
for(size_t i = start_offset; i < start_offset + count && i < m_db->height();i++)
|
||||||
{
|
{
|
||||||
blocks.push_back(m_db->get_block_from_height(i));
|
blocks.push_back(std::make_pair(m_db->get_block_blob_from_height(i), block()));
|
||||||
|
if (!parse_and_validate_block_from_blob(blocks.back().first, blocks.back().second))
|
||||||
|
{
|
||||||
|
LOG_ERROR("Invalid block");
|
||||||
|
return false;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
@ -1480,22 +1485,22 @@ bool Blockchain::handle_get_objects(NOTIFY_REQUEST_GET_OBJECTS::request& arg, NO
|
||||||
CRITICAL_REGION_LOCAL(m_blockchain_lock);
|
CRITICAL_REGION_LOCAL(m_blockchain_lock);
|
||||||
m_db->block_txn_start(true);
|
m_db->block_txn_start(true);
|
||||||
rsp.current_blockchain_height = get_current_blockchain_height();
|
rsp.current_blockchain_height = get_current_blockchain_height();
|
||||||
std::list<block> blocks;
|
std::list<std::pair<cryptonote::blobdata,block>> blocks;
|
||||||
get_blocks(arg.blocks, blocks, rsp.missed_ids);
|
get_blocks(arg.blocks, blocks, rsp.missed_ids);
|
||||||
|
|
||||||
for (const auto& bl: blocks)
|
for (const auto& bl: blocks)
|
||||||
{
|
{
|
||||||
std::list<crypto::hash> missed_tx_ids;
|
std::list<crypto::hash> missed_tx_ids;
|
||||||
std::list<transaction> txs;
|
std::list<cryptonote::blobdata> txs;
|
||||||
|
|
||||||
// FIXME: s/rsp.missed_ids/missed_tx_id/ ? Seems like rsp.missed_ids
|
// FIXME: s/rsp.missed_ids/missed_tx_id/ ? Seems like rsp.missed_ids
|
||||||
// is for missed blocks, not missed transactions as well.
|
// is for missed blocks, not missed transactions as well.
|
||||||
get_transactions(bl.tx_hashes, txs, missed_tx_ids);
|
get_transactions_blobs(bl.second.tx_hashes, txs, missed_tx_ids);
|
||||||
|
|
||||||
if (missed_tx_ids.size() != 0)
|
if (missed_tx_ids.size() != 0)
|
||||||
{
|
{
|
||||||
LOG_ERROR("Error retrieving blocks, missed " << missed_tx_ids.size()
|
LOG_ERROR("Error retrieving blocks, missed " << missed_tx_ids.size()
|
||||||
<< " transactions for block with hash: " << get_block_hash(bl)
|
<< " transactions for block with hash: " << get_block_hash(bl.second)
|
||||||
<< std::endl
|
<< std::endl
|
||||||
);
|
);
|
||||||
|
|
||||||
|
@ -1510,17 +1515,17 @@ bool Blockchain::handle_get_objects(NOTIFY_REQUEST_GET_OBJECTS::request& arg, NO
|
||||||
rsp.blocks.push_back(block_complete_entry());
|
rsp.blocks.push_back(block_complete_entry());
|
||||||
block_complete_entry& e = rsp.blocks.back();
|
block_complete_entry& e = rsp.blocks.back();
|
||||||
//pack block
|
//pack block
|
||||||
e.block = t_serializable_object_to_blob(bl);
|
e.block = bl.first;
|
||||||
//pack transactions
|
//pack transactions
|
||||||
for (transaction& tx: txs)
|
for (const cryptonote::blobdata& tx: txs)
|
||||||
e.txs.push_back(t_serializable_object_to_blob(tx));
|
e.txs.push_back(tx);
|
||||||
}
|
}
|
||||||
//get another transactions, if need
|
//get another transactions, if need
|
||||||
std::list<transaction> txs;
|
std::list<cryptonote::blobdata> txs;
|
||||||
get_transactions(arg.txs, txs, rsp.missed_ids);
|
get_transactions_blobs(arg.txs, txs, rsp.missed_ids);
|
||||||
//pack aside transactions
|
//pack aside transactions
|
||||||
for (const auto& tx: txs)
|
for (const auto& tx: txs)
|
||||||
rsp.txs.push_back(t_serializable_object_to_blob(tx));
|
rsp.txs.push_back(tx);
|
||||||
|
|
||||||
m_db->block_txn_stop();
|
m_db->block_txn_stop();
|
||||||
return true;
|
return true;
|
||||||
|
@ -1889,7 +1894,12 @@ bool Blockchain::get_blocks(const t_ids_container& block_ids, t_blocks_container
|
||||||
{
|
{
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
blocks.push_back(m_db->get_block(block_hash));
|
blocks.push_back(std::make_pair(m_db->get_block_blob(block_hash), block()));
|
||||||
|
if (!parse_and_validate_block_from_blob(blocks.back().first, blocks.back().second))
|
||||||
|
{
|
||||||
|
LOG_ERROR("Invalid block");
|
||||||
|
return false;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
catch (const BLOCK_DNE& e)
|
catch (const BLOCK_DNE& e)
|
||||||
{
|
{
|
||||||
|
@ -1906,6 +1916,30 @@ bool Blockchain::get_blocks(const t_ids_container& block_ids, t_blocks_container
|
||||||
//TODO: return type should be void, throw on exception
|
//TODO: return type should be void, throw on exception
|
||||||
// alternatively, return true only if no transactions missed
|
// alternatively, return true only if no transactions missed
|
||||||
template<class t_ids_container, class t_tx_container, class t_missed_container>
|
template<class t_ids_container, class t_tx_container, class t_missed_container>
|
||||||
|
bool Blockchain::get_transactions_blobs(const t_ids_container& txs_ids, t_tx_container& txs, t_missed_container& missed_txs) const
|
||||||
|
{
|
||||||
|
LOG_PRINT_L3("Blockchain::" << __func__);
|
||||||
|
CRITICAL_REGION_LOCAL(m_blockchain_lock);
|
||||||
|
|
||||||
|
for (const auto& tx_hash : txs_ids)
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
cryptonote::blobdata tx;
|
||||||
|
if (m_db->get_tx_blob(tx_hash, tx))
|
||||||
|
txs.push_back(std::move(tx));
|
||||||
|
else
|
||||||
|
missed_txs.push_back(tx_hash);
|
||||||
|
}
|
||||||
|
catch (const std::exception& e)
|
||||||
|
{
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
//------------------------------------------------------------------
|
||||||
|
template<class t_ids_container, class t_tx_container, class t_missed_container>
|
||||||
bool Blockchain::get_transactions(const t_ids_container& txs_ids, t_tx_container& txs, t_missed_container& missed_txs) const
|
bool Blockchain::get_transactions(const t_ids_container& txs_ids, t_tx_container& txs, t_missed_container& missed_txs) const
|
||||||
{
|
{
|
||||||
LOG_PRINT_L3("Blockchain::" << __func__);
|
LOG_PRINT_L3("Blockchain::" << __func__);
|
||||||
|
@ -1915,9 +1949,16 @@ bool Blockchain::get_transactions(const t_ids_container& txs_ids, t_tx_container
|
||||||
{
|
{
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
transaction tx;
|
cryptonote::blobdata tx;
|
||||||
if (m_db->get_tx(tx_hash, tx))
|
if (m_db->get_tx_blob(tx_hash, tx))
|
||||||
txs.push_back(std::move(tx));
|
{
|
||||||
|
txs.push_back(transaction());
|
||||||
|
if (!parse_and_validate_tx_from_blob(tx, txs.back()))
|
||||||
|
{
|
||||||
|
LOG_ERROR("Invalid transaction");
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
else
|
else
|
||||||
missed_txs.push_back(tx_hash);
|
missed_txs.push_back(tx_hash);
|
||||||
}
|
}
|
||||||
|
@ -1999,7 +2040,7 @@ bool Blockchain::find_blockchain_supplement(const std::list<crypto::hash>& qbloc
|
||||||
// find split point between ours and foreign blockchain (or start at
|
// find split point between ours and foreign blockchain (or start at
|
||||||
// blockchain height <req_start_block>), and return up to max_count FULL
|
// blockchain height <req_start_block>), and return up to max_count FULL
|
||||||
// blocks by reference.
|
// blocks by reference.
|
||||||
bool Blockchain::find_blockchain_supplement(const uint64_t req_start_block, const std::list<crypto::hash>& qblock_ids, std::list<std::pair<block, std::list<transaction> > >& blocks, uint64_t& total_height, uint64_t& start_height, size_t max_count) const
|
bool Blockchain::find_blockchain_supplement(const uint64_t req_start_block, const std::list<crypto::hash>& qblock_ids, std::list<std::pair<cryptonote::blobdata, std::list<cryptonote::blobdata> > >& blocks, uint64_t& total_height, uint64_t& start_height, size_t max_count) const
|
||||||
{
|
{
|
||||||
LOG_PRINT_L3("Blockchain::" << __func__);
|
LOG_PRINT_L3("Blockchain::" << __func__);
|
||||||
CRITICAL_REGION_LOCAL(m_blockchain_lock);
|
CRITICAL_REGION_LOCAL(m_blockchain_lock);
|
||||||
|
@ -2027,9 +2068,11 @@ bool Blockchain::find_blockchain_supplement(const uint64_t req_start_block, cons
|
||||||
for(size_t i = start_height; i < total_height && count < max_count; i++, count++)
|
for(size_t i = start_height; i < total_height && count < max_count; i++, count++)
|
||||||
{
|
{
|
||||||
blocks.resize(blocks.size()+1);
|
blocks.resize(blocks.size()+1);
|
||||||
blocks.back().first = m_db->get_block_from_height(i);
|
blocks.back().first = m_db->get_block_blob_from_height(i);
|
||||||
|
block b;
|
||||||
|
CHECK_AND_ASSERT_MES(parse_and_validate_block_from_blob(blocks.back().first, b), false, "internal error, invalid block");
|
||||||
std::list<crypto::hash> mis;
|
std::list<crypto::hash> mis;
|
||||||
get_transactions(blocks.back().first.tx_hashes, blocks.back().second, mis);
|
get_transactions_blobs(b.tx_hashes, blocks.back().second, mis);
|
||||||
CHECK_AND_ASSERT_MES(!mis.size(), false, "internal error, transaction from block not found");
|
CHECK_AND_ASSERT_MES(!mis.size(), false, "internal error, transaction from block not found");
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
|
@ -4011,3 +4054,7 @@ bool Blockchain::for_all_outputs(std::function<bool(uint64_t amount, const crypt
|
||||||
{
|
{
|
||||||
return m_db->for_all_outputs(f);;
|
return m_db->for_all_outputs(f);;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
namespace cryptonote {
|
||||||
|
template bool Blockchain::get_transactions(const std::vector<crypto::hash>&, std::list<transaction>&, std::list<crypto::hash>&) const;
|
||||||
|
}
|
||||||
|
|
|
@ -153,7 +153,7 @@ namespace cryptonote
|
||||||
*
|
*
|
||||||
* @return false if start_offset > blockchain height, else true
|
* @return false if start_offset > blockchain height, else true
|
||||||
*/
|
*/
|
||||||
bool get_blocks(uint64_t start_offset, size_t count, std::list<block>& blocks, std::list<transaction>& txs) const;
|
bool get_blocks(uint64_t start_offset, size_t count, std::list<std::pair<cryptonote::blobdata,block>>& blocks, std::list<cryptonote::blobdata>& txs) const;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief get blocks from blocks based on start height and count
|
* @brief get blocks from blocks based on start height and count
|
||||||
|
@ -164,7 +164,7 @@ namespace cryptonote
|
||||||
*
|
*
|
||||||
* @return false if start_offset > blockchain height, else true
|
* @return false if start_offset > blockchain height, else true
|
||||||
*/
|
*/
|
||||||
bool get_blocks(uint64_t start_offset, size_t count, std::list<block>& blocks) const;
|
bool get_blocks(uint64_t start_offset, size_t count, std::list<std::pair<cryptonote::blobdata,block>>& blocks) const;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief compiles a list of all blocks stored as alternative chains
|
* @brief compiles a list of all blocks stored as alternative chains
|
||||||
|
@ -407,7 +407,7 @@ namespace cryptonote
|
||||||
*
|
*
|
||||||
* @return true if a block found in common or req_start_block specified, else false
|
* @return true if a block found in common or req_start_block specified, else false
|
||||||
*/
|
*/
|
||||||
bool find_blockchain_supplement(const uint64_t req_start_block, const std::list<crypto::hash>& qblock_ids, std::list<std::pair<block, std::list<transaction> > >& blocks, uint64_t& total_height, uint64_t& start_height, size_t max_count) const;
|
bool find_blockchain_supplement(const uint64_t req_start_block, const std::list<crypto::hash>& qblock_ids, std::list<std::pair<cryptonote::blobdata, std::list<cryptonote::blobdata> > >& blocks, uint64_t& total_height, uint64_t& start_height, size_t max_count) const;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief retrieves a set of blocks and their transactions, and possibly other transactions
|
* @brief retrieves a set of blocks and their transactions, and possibly other transactions
|
||||||
|
@ -621,9 +621,10 @@ namespace cryptonote
|
||||||
* @return false if an unexpected exception occurs, else true
|
* @return false if an unexpected exception occurs, else true
|
||||||
*/
|
*/
|
||||||
template<class t_ids_container, class t_tx_container, class t_missed_container>
|
template<class t_ids_container, class t_tx_container, class t_missed_container>
|
||||||
|
bool get_transactions_blobs(const t_ids_container& txs_ids, t_tx_container& txs, t_missed_container& missed_txs) const;
|
||||||
|
template<class t_ids_container, class t_tx_container, class t_missed_container>
|
||||||
bool get_transactions(const t_ids_container& txs_ids, t_tx_container& txs, t_missed_container& missed_txs) const;
|
bool get_transactions(const t_ids_container& txs_ids, t_tx_container& txs, t_missed_container& missed_txs) const;
|
||||||
|
|
||||||
|
|
||||||
//debug functions
|
//debug functions
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -195,15 +195,31 @@ namespace cryptonote
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
//-----------------------------------------------------------------------------------------------
|
//-----------------------------------------------------------------------------------------------
|
||||||
bool core::get_blocks(uint64_t start_offset, size_t count, std::list<block>& blocks, std::list<transaction>& 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
|
||||||
{
|
{
|
||||||
return m_blockchain_storage.get_blocks(start_offset, count, blocks, txs);
|
return m_blockchain_storage.get_blocks(start_offset, count, blocks, txs);
|
||||||
}
|
}
|
||||||
//-----------------------------------------------------------------------------------------------
|
//-----------------------------------------------------------------------------------------------
|
||||||
bool core::get_blocks(uint64_t start_offset, size_t count, std::list<block>& blocks) const
|
bool core::get_blocks(uint64_t start_offset, size_t count, std::list<std::pair<cryptonote::blobdata,block>>& blocks) const
|
||||||
{
|
{
|
||||||
return m_blockchain_storage.get_blocks(start_offset, count, blocks);
|
return m_blockchain_storage.get_blocks(start_offset, count, blocks);
|
||||||
} //-----------------------------------------------------------------------------------------------
|
}
|
||||||
|
//-----------------------------------------------------------------------------------------------
|
||||||
|
bool core::get_blocks(uint64_t start_offset, size_t count, std::list<block>& blocks) const
|
||||||
|
{
|
||||||
|
std::list<std::pair<cryptonote::blobdata, cryptonote::block>> bs;
|
||||||
|
if (!m_blockchain_storage.get_blocks(start_offset, count, bs))
|
||||||
|
return false;
|
||||||
|
for (const auto &b: bs)
|
||||||
|
blocks.push_back(b.second);
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
//-----------------------------------------------------------------------------------------------
|
||||||
|
bool core::get_transactions(const std::vector<crypto::hash>& txs_ids, std::list<cryptonote::blobdata>& txs, std::list<crypto::hash>& missed_txs) const
|
||||||
|
{
|
||||||
|
return m_blockchain_storage.get_transactions_blobs(txs_ids, txs, missed_txs);
|
||||||
|
}
|
||||||
|
//-----------------------------------------------------------------------------------------------
|
||||||
bool core::get_transactions(const std::vector<crypto::hash>& txs_ids, std::list<transaction>& txs, std::list<crypto::hash>& missed_txs) const
|
bool core::get_transactions(const std::vector<crypto::hash>& txs_ids, std::list<transaction>& txs, std::list<crypto::hash>& missed_txs) const
|
||||||
{
|
{
|
||||||
return m_blockchain_storage.get_transactions(txs_ids, txs, missed_txs);
|
return m_blockchain_storage.get_transactions(txs_ids, txs, missed_txs);
|
||||||
|
@ -799,7 +815,7 @@ namespace cryptonote
|
||||||
return m_blockchain_storage.find_blockchain_supplement(qblock_ids, resp);
|
return m_blockchain_storage.find_blockchain_supplement(qblock_ids, resp);
|
||||||
}
|
}
|
||||||
//-----------------------------------------------------------------------------------------------
|
//-----------------------------------------------------------------------------------------------
|
||||||
bool core::find_blockchain_supplement(const uint64_t req_start_block, const std::list<crypto::hash>& qblock_ids, std::list<std::pair<block, std::list<transaction> > >& blocks, uint64_t& total_height, uint64_t& start_height, size_t max_count) const
|
bool core::find_blockchain_supplement(const uint64_t req_start_block, const std::list<crypto::hash>& qblock_ids, std::list<std::pair<cryptonote::blobdata, std::list<cryptonote::blobdata> > >& blocks, uint64_t& total_height, uint64_t& start_height, size_t max_count) const
|
||||||
{
|
{
|
||||||
return m_blockchain_storage.find_blockchain_supplement(req_start_block, qblock_ids, blocks, total_height, start_height, max_count);
|
return m_blockchain_storage.find_blockchain_supplement(req_start_block, qblock_ids, blocks, total_height, start_height, max_count);
|
||||||
}
|
}
|
||||||
|
@ -867,8 +883,8 @@ namespace cryptonote
|
||||||
arg.hop = 0;
|
arg.hop = 0;
|
||||||
arg.current_blockchain_height = m_blockchain_storage.get_current_blockchain_height();
|
arg.current_blockchain_height = m_blockchain_storage.get_current_blockchain_height();
|
||||||
std::list<crypto::hash> missed_txs;
|
std::list<crypto::hash> missed_txs;
|
||||||
std::list<transaction> txs;
|
std::list<cryptonote::blobdata> txs;
|
||||||
m_blockchain_storage.get_transactions(b.tx_hashes, txs, missed_txs);
|
m_blockchain_storage.get_transactions_blobs(b.tx_hashes, txs, missed_txs);
|
||||||
if(missed_txs.size() && m_blockchain_storage.get_block_id_by_height(get_block_height(b)) != get_block_hash(b))
|
if(missed_txs.size() && m_blockchain_storage.get_block_id_by_height(get_block_height(b)) != get_block_hash(b))
|
||||||
{
|
{
|
||||||
LOG_PRINT_L1("Block found but, seems that reorganize just happened after that, do not relay this block");
|
LOG_PRINT_L1("Block found but, seems that reorganize just happened after that, do not relay this block");
|
||||||
|
@ -880,7 +896,7 @@ namespace cryptonote
|
||||||
block_to_blob(b, arg.b.block);
|
block_to_blob(b, arg.b.block);
|
||||||
//pack transactions
|
//pack transactions
|
||||||
for(auto& tx: txs)
|
for(auto& tx: txs)
|
||||||
arg.b.txs.push_back(t_serializable_object_to_blob(tx));
|
arg.b.txs.push_back(tx);
|
||||||
|
|
||||||
m_pprotocol->relay_block(arg, exclude_context);
|
m_pprotocol->relay_block(arg, exclude_context);
|
||||||
}
|
}
|
||||||
|
|
|
@ -287,16 +287,23 @@ namespace cryptonote
|
||||||
bool get_blockchain_top(uint64_t& height, crypto::hash& top_id) const;
|
bool get_blockchain_top(uint64_t& height, crypto::hash& top_id) const;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @copydoc Blockchain::get_blocks(uint64_t, size_t, std::list<block>&, std::list<transaction>&) const
|
* @copydoc Blockchain::get_blocks(uint64_t, size_t, std::list<std::pair<cryptonote::blobdata,block>>&, std::list<transaction>&) const
|
||||||
*
|
*
|
||||||
* @note see Blockchain::get_blocks(uint64_t, size_t, std::list<block>&, std::list<transaction>&) const
|
* @note see Blockchain::get_blocks(uint64_t, size_t, std::list<std::pair<cryptonote::blobdata,block>>&, std::list<transaction>&) const
|
||||||
*/
|
*/
|
||||||
bool get_blocks(uint64_t start_offset, size_t count, std::list<block>& blocks, std::list<transaction>& txs) const;
|
bool get_blocks(uint64_t start_offset, size_t count, std::list<std::pair<cryptonote::blobdata,block>>& blocks, std::list<cryptonote::blobdata>& txs) const;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @copydoc Blockchain::get_blocks(uint64_t, size_t, std::list<block>&) const
|
* @copydoc Blockchain::get_blocks(uint64_t, size_t, std::list<std::pair<cryptonote::blobdata,block>>&) const
|
||||||
*
|
*
|
||||||
* @note see Blockchain::get_blocks(uint64_t, size_t, std::list<block>&) const
|
* @note see Blockchain::get_blocks(uint64_t, size_t, std::list<std::pair<cryptonote::blobdata,block>>&) const
|
||||||
|
*/
|
||||||
|
bool get_blocks(uint64_t start_offset, size_t count, std::list<std::pair<cryptonote::blobdata,block>>& blocks) const;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @copydoc Blockchain::get_blocks(uint64_t, size_t, std::list<std::pair<cryptonote::blobdata,block>>&) const
|
||||||
|
*
|
||||||
|
* @note see Blockchain::get_blocks(uint64_t, size_t, std::list<std::pair<cryptonote::blobdata,block>>&) const
|
||||||
*/
|
*/
|
||||||
bool get_blocks(uint64_t start_offset, size_t count, std::list<block>& blocks) const;
|
bool get_blocks(uint64_t start_offset, size_t count, std::list<block>& blocks) const;
|
||||||
|
|
||||||
|
@ -318,6 +325,13 @@ namespace cryptonote
|
||||||
*/
|
*/
|
||||||
crypto::hash get_block_id_by_height(uint64_t height) const;
|
crypto::hash get_block_id_by_height(uint64_t height) const;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @copydoc Blockchain::get_transactions
|
||||||
|
*
|
||||||
|
* @note see Blockchain::get_transactions
|
||||||
|
*/
|
||||||
|
bool get_transactions(const std::vector<crypto::hash>& txs_ids, std::list<cryptonote::blobdata>& txs, std::list<crypto::hash>& missed_txs) const;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @copydoc Blockchain::get_transactions
|
* @copydoc Blockchain::get_transactions
|
||||||
*
|
*
|
||||||
|
@ -431,11 +445,11 @@ namespace cryptonote
|
||||||
bool find_blockchain_supplement(const std::list<crypto::hash>& qblock_ids, NOTIFY_RESPONSE_CHAIN_ENTRY::request& resp) const;
|
bool find_blockchain_supplement(const std::list<crypto::hash>& qblock_ids, NOTIFY_RESPONSE_CHAIN_ENTRY::request& resp) const;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @copydoc Blockchain::find_blockchain_supplement(const uint64_t, const std::list<crypto::hash>&, std::list<std::pair<block, std::list<transaction> > >&, uint64_t&, uint64_t&, size_t) const
|
* @copydoc Blockchain::find_blockchain_supplement(const uint64_t, const std::list<crypto::hash>&, std::list<std::pair<cryptonote::blobdata, std::list<cryptonote::blobdata> > >&, uint64_t&, uint64_t&, size_t) const
|
||||||
*
|
*
|
||||||
* @note see Blockchain::find_blockchain_supplement(const uint64_t, const std::list<crypto::hash>&, std::list<std::pair<block, std::list<transaction> > >&, uint64_t&, uint64_t&, size_t) const
|
* @note see Blockchain::find_blockchain_supplement(const uint64_t, const std::list<crypto::hash>&, std::list<std::pair<cryptonote::blobdata, std::list<transaction> > >&, uint64_t&, uint64_t&, size_t) const
|
||||||
*/
|
*/
|
||||||
bool find_blockchain_supplement(const uint64_t req_start_block, const std::list<crypto::hash>& qblock_ids, std::list<std::pair<block, std::list<transaction> > >& blocks, uint64_t& total_height, uint64_t& start_height, size_t max_count) const;
|
bool find_blockchain_supplement(const uint64_t req_start_block, const std::list<crypto::hash>& qblock_ids, std::list<std::pair<cryptonote::blobdata, std::list<cryptonote::blobdata> > >& blocks, uint64_t& total_height, uint64_t& start_height, size_t max_count) const;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief gets some stats about the daemon
|
* @brief gets some stats about the daemon
|
||||||
|
|
|
@ -634,6 +634,9 @@ namespace cryptonote
|
||||||
int t_cryptonote_protocol_handler<t_core>::handle_request_fluffy_missing_tx(int command, NOTIFY_REQUEST_FLUFFY_MISSING_TX::request& arg, cryptonote_connection_context& context)
|
int t_cryptonote_protocol_handler<t_core>::handle_request_fluffy_missing_tx(int command, NOTIFY_REQUEST_FLUFFY_MISSING_TX::request& arg, cryptonote_connection_context& context)
|
||||||
{
|
{
|
||||||
MLOG_P2P_MESSAGE("Received NOTIFY_REQUEST_FLUFFY_MISSING_TX (" << arg.missing_tx_indices.size() << " txes), block hash " << arg.block_hash);
|
MLOG_P2P_MESSAGE("Received NOTIFY_REQUEST_FLUFFY_MISSING_TX (" << arg.missing_tx_indices.size() << " txes), block hash " << arg.block_hash);
|
||||||
|
|
||||||
|
std::list<std::pair<cryptonote::blobdata, block>> local_blocks;
|
||||||
|
std::list<cryptonote::blobdata> local_txs;
|
||||||
|
|
||||||
block b;
|
block b;
|
||||||
if (!m_core.get_block_by_hash(arg.block_hash, b))
|
if (!m_core.get_block_by_hash(arg.block_hash, b))
|
||||||
|
|
|
@ -151,7 +151,7 @@ namespace cryptonote
|
||||||
bool core_rpc_server::on_get_blocks(const COMMAND_RPC_GET_BLOCKS_FAST::request& req, COMMAND_RPC_GET_BLOCKS_FAST::response& res)
|
bool core_rpc_server::on_get_blocks(const COMMAND_RPC_GET_BLOCKS_FAST::request& req, COMMAND_RPC_GET_BLOCKS_FAST::response& res)
|
||||||
{
|
{
|
||||||
CHECK_CORE_BUSY();
|
CHECK_CORE_BUSY();
|
||||||
std::list<std::pair<block, std::list<transaction> > > bs;
|
std::list<std::pair<cryptonote::blobdata, std::list<cryptonote::blobdata> > > bs;
|
||||||
|
|
||||||
if(!m_core.find_blockchain_supplement(req.start_height, req.block_ids, bs, res.current_height, res.start_height, COMMAND_RPC_GET_BLOCKS_FAST_MAX_COUNT))
|
if(!m_core.find_blockchain_supplement(req.start_height, req.block_ids, bs, res.current_height, res.start_height, COMMAND_RPC_GET_BLOCKS_FAST_MAX_COUNT))
|
||||||
{
|
{
|
||||||
|
@ -159,24 +159,30 @@ namespace cryptonote
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
for(auto& b: bs)
|
for(auto& bd: bs)
|
||||||
{
|
{
|
||||||
res.blocks.resize(res.blocks.size()+1);
|
res.blocks.resize(res.blocks.size()+1);
|
||||||
res.blocks.back().block = block_to_blob(b.first);
|
res.blocks.back().block = bd.first;
|
||||||
res.output_indices.push_back(COMMAND_RPC_GET_BLOCKS_FAST::block_output_indices());
|
res.output_indices.push_back(COMMAND_RPC_GET_BLOCKS_FAST::block_output_indices());
|
||||||
res.output_indices.back().indices.push_back(COMMAND_RPC_GET_BLOCKS_FAST::tx_output_indices());
|
res.output_indices.back().indices.push_back(COMMAND_RPC_GET_BLOCKS_FAST::tx_output_indices());
|
||||||
bool r = m_core.get_tx_outputs_gindexs(get_transaction_hash(b.first.miner_tx), res.output_indices.back().indices.back().indices);
|
block b;
|
||||||
|
if (!parse_and_validate_block_from_blob(bd.first, b))
|
||||||
|
{
|
||||||
|
res.status = "Invalid block";
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
bool r = m_core.get_tx_outputs_gindexs(get_transaction_hash(b.miner_tx), res.output_indices.back().indices.back().indices);
|
||||||
if (!r)
|
if (!r)
|
||||||
{
|
{
|
||||||
res.status = "Failed";
|
res.status = "Failed";
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
size_t txidx = 0;
|
size_t txidx = 0;
|
||||||
for(auto& t: b.second)
|
for(const auto& t: bd.second)
|
||||||
{
|
{
|
||||||
res.blocks.back().txs.push_back(tx_to_blob(t));
|
res.blocks.back().txs.push_back(t);
|
||||||
res.output_indices.back().indices.push_back(COMMAND_RPC_GET_BLOCKS_FAST::tx_output_indices());
|
res.output_indices.back().indices.push_back(COMMAND_RPC_GET_BLOCKS_FAST::tx_output_indices());
|
||||||
bool r = m_core.get_tx_outputs_gindexs(b.first.tx_hashes[txidx++], res.output_indices.back().indices.back().indices);
|
bool r = m_core.get_tx_outputs_gindexs(b.tx_hashes[txidx++], res.output_indices.back().indices.back().indices);
|
||||||
if (!r)
|
if (!r)
|
||||||
{
|
{
|
||||||
res.status = "Failed";
|
res.status = "Failed";
|
||||||
|
|
|
@ -91,7 +91,7 @@ namespace tests
|
||||||
virtual void on_transaction_relayed(const cryptonote::blobdata& tx) {}
|
virtual void on_transaction_relayed(const cryptonote::blobdata& tx) {}
|
||||||
bool get_testnet() const { return false; }
|
bool get_testnet() const { return false; }
|
||||||
bool get_pool_transaction(const crypto::hash& id, cryptonote::transaction& tx) const { return false; }
|
bool get_pool_transaction(const crypto::hash& id, cryptonote::transaction& tx) const { return false; }
|
||||||
bool get_blocks(uint64_t start_offset, size_t count, std::list<cryptonote::block>& blocks, std::list<cryptonote::transaction>& txs) const { return false; }
|
bool get_blocks(uint64_t start_offset, size_t count, std::list<std::pair<cryptonote::blobdata, cryptonote::block>>& blocks, std::list<cryptonote::blobdata>& txs) const { return false; }
|
||||||
bool get_transactions(const std::vector<crypto::hash>& txs_ids, std::list<cryptonote::transaction>& txs, std::list<crypto::hash>& missed_txs) const { return false; }
|
bool get_transactions(const std::vector<crypto::hash>& txs_ids, std::list<cryptonote::transaction>& txs, std::list<crypto::hash>& missed_txs) const { return false; }
|
||||||
bool get_block_by_hash(const crypto::hash &h, cryptonote::block &blk, bool *orphan = NULL) const { return false; }
|
bool get_block_by_hash(const crypto::hash &h, cryptonote::block &blk, bool *orphan = NULL) const { return false; }
|
||||||
};
|
};
|
||||||
|
|
|
@ -66,7 +66,7 @@ public:
|
||||||
virtual void on_transaction_relayed(const cryptonote::blobdata& tx) {}
|
virtual void on_transaction_relayed(const cryptonote::blobdata& tx) {}
|
||||||
bool get_testnet() const { return false; }
|
bool get_testnet() const { return false; }
|
||||||
bool get_pool_transaction(const crypto::hash& id, cryptonote::transaction& tx) const { return false; }
|
bool get_pool_transaction(const crypto::hash& id, cryptonote::transaction& tx) const { return false; }
|
||||||
bool get_blocks(uint64_t start_offset, size_t count, std::list<cryptonote::block>& blocks, std::list<cryptonote::transaction>& txs) const { return false; }
|
bool get_blocks(uint64_t start_offset, size_t count, std::list<std::pair<cryptonote::blobdata, cryptonote::block>>& blocks, std::list<cryptonote::blobdata>& txs) const { return false; }
|
||||||
bool get_transactions(const std::vector<crypto::hash>& txs_ids, std::list<cryptonote::transaction>& txs, std::list<crypto::hash>& missed_txs) const { return false; }
|
bool get_transactions(const std::vector<crypto::hash>& txs_ids, std::list<cryptonote::transaction>& txs, std::list<crypto::hash>& missed_txs) const { return false; }
|
||||||
bool get_block_by_hash(const crypto::hash &h, cryptonote::block &blk, bool *orphan = NULL) const { return false; }
|
bool get_block_by_hash(const crypto::hash &h, cryptonote::block &blk, bool *orphan = NULL) const { return false; }
|
||||||
};
|
};
|
||||||
|
|
|
@ -59,7 +59,9 @@ public:
|
||||||
virtual void block_txn_abort() {}
|
virtual void block_txn_abort() {}
|
||||||
virtual void drop_hard_fork_info() {}
|
virtual void drop_hard_fork_info() {}
|
||||||
virtual bool block_exists(const crypto::hash& h, uint64_t *height) const { return false; }
|
virtual bool block_exists(const crypto::hash& h, uint64_t *height) const { return false; }
|
||||||
virtual block get_block(const crypto::hash& h) const { return block(); }
|
virtual blobdata get_block_blob_from_height(const uint64_t& height) const { return blobdata(); }
|
||||||
|
virtual blobdata get_block_blob(const crypto::hash& h) const { return blobdata(); }
|
||||||
|
virtual bool get_tx_blob(const crypto::hash& h, cryptonote::blobdata &tx) const { return false; }
|
||||||
virtual uint64_t get_block_height(const crypto::hash& h) const { return 0; }
|
virtual uint64_t get_block_height(const crypto::hash& h) const { return 0; }
|
||||||
virtual block_header get_block_header(const crypto::hash& h) const { return block_header(); }
|
virtual block_header get_block_header(const crypto::hash& h) const { return block_header(); }
|
||||||
virtual uint64_t get_block_timestamp(const uint64_t& height) const { return 0; }
|
virtual uint64_t get_block_timestamp(const uint64_t& height) const { return 0; }
|
||||||
|
|
Loading…
Reference in New Issue