diff options
author | Riccardo Spagni <ric@spagni.net> | 2017-01-15 20:32:57 -0500 |
---|---|---|
committer | Riccardo Spagni <ric@spagni.net> | 2017-01-15 20:32:57 -0500 |
commit | ab69d5b3670cc21a10aab9ad16919afdcc80fdba (patch) | |
tree | f0c009b9b943a570ee505f2881be2243c68e16cd /src/rpc/core_rpc_server.cpp | |
parent | Merge pull request #1522 (diff) | |
parent | specify restore height by YYYY-MM-DD format (diff) | |
download | monero-ab69d5b3670cc21a10aab9ad16919afdcc80fdba.tar.xz |
Merge pull request #1569
16b8b66a specify restore height by YYYY-MM-DD format (kenshi84)
Diffstat (limited to 'src/rpc/core_rpc_server.cpp')
-rw-r--r-- | src/rpc/core_rpc_server.cpp | 30 |
1 files changed, 30 insertions, 0 deletions
diff --git a/src/rpc/core_rpc_server.cpp b/src/rpc/core_rpc_server.cpp index 29c61eca2..1c5c321da 100644 --- a/src/rpc/core_rpc_server.cpp +++ b/src/rpc/core_rpc_server.cpp @@ -190,6 +190,36 @@ namespace cryptonote return true; } //------------------------------------------------------------------------------------------------------------------------------ + bool core_rpc_server::on_get_blocks_by_height(const COMMAND_RPC_GET_BLOCKS_BY_HEIGHT::request& req, COMMAND_RPC_GET_BLOCKS_BY_HEIGHT::response& res) + { + CHECK_CORE_BUSY(); + res.status = "Failed"; + res.blocks.clear(); + res.blocks.reserve(req.heights.size()); + for (uint64_t height : req.heights) + { + block blk; + try + { + blk = m_core.get_blockchain_storage().get_db().get_block_from_height(height); + } + catch (...) + { + res.status = "Error retrieving block at height " + height; + return true; + } + std::list<transaction> txs; + std::list<crypto::hash> missed_txs; + m_core.get_transactions(blk.tx_hashes, txs, missed_txs); + res.blocks.resize(res.blocks.size() + 1); + res.blocks.back().block = block_to_blob(blk); + for (auto& tx : txs) + res.blocks.back().txs.push_back(tx_to_blob(tx)); + } + res.status = CORE_RPC_STATUS_OK; + return true; + } + //------------------------------------------------------------------------------------------------------------------------------ bool core_rpc_server::on_get_hashes(const COMMAND_RPC_GET_HASHES_FAST::request& req, COMMAND_RPC_GET_HASHES_FAST::response& res) { CHECK_CORE_BUSY(); |