aboutsummaryrefslogtreecommitdiff
path: root/src/rpc/core_rpc_server.cpp
diff options
context:
space:
mode:
authorkenshi84 <kenshi84@protonmail.ch>2016-12-25 17:18:15 +0900
committerkenshi84 <kenshi84@protonmail.ch>2017-01-16 10:00:28 +0900
commit16b8b66adcad57983b099fdf3ac1b52519390bc6 (patch)
tree5da228ea1d398d68e9ba0fc3172b748356ed07ec /src/rpc/core_rpc_server.cpp
parentMerge pull request #1578 (diff)
downloadmonero-16b8b66adcad57983b099fdf3ac1b52519390bc6.tar.xz
specify restore height by YYYY-MM-DD format
Diffstat (limited to 'src/rpc/core_rpc_server.cpp')
-rw-r--r--src/rpc/core_rpc_server.cpp30
1 files changed, 30 insertions, 0 deletions
diff --git a/src/rpc/core_rpc_server.cpp b/src/rpc/core_rpc_server.cpp
index 0cec3c26e..a4f8283bd 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();