aboutsummaryrefslogtreecommitdiff
path: root/src/rpc/core_rpc_server.cpp
diff options
context:
space:
mode:
authormoneromooo-monero <moneromooo-monero@users.noreply.github.com>2019-09-16 12:18:34 +0000
committermoneromooo-monero <moneromooo-monero@users.noreply.github.com>2019-09-27 00:10:37 +0000
commit8330e772f1ed680a54833d25c4d17d09a99ab8d6 (patch)
treed536126b06a00fabd56881363daaa9a1fd305c80 /src/rpc/core_rpc_server.cpp
parentMerge pull request #5876 (diff)
downloadmonero-8330e772f1ed680a54833d25c4d17d09a99ab8d6.tar.xz
monerod can now sync from pruned blocks
If the peer (whether pruned or not itself) supports sending pruned blocks to syncing nodes, the pruned version will be sent along with the hash of the pruned data and the block weight. The original tx hashes can be reconstructed from the pruned txes and theur prunable data hash. Those hashes and the block weights are hashes and checked against the set of precompiled hashes, ensuring the data we received is the original data. It is currently not possible to use this system when not using the set of precompiled hashes, since block weights can not otherwise be checked for validity. This is off by default for now, and is enabled by --sync-pruned-blocks
Diffstat (limited to 'src/rpc/core_rpc_server.cpp')
-rw-r--r--src/rpc/core_rpc_server.cpp11
1 files changed, 6 insertions, 5 deletions
diff --git a/src/rpc/core_rpc_server.cpp b/src/rpc/core_rpc_server.cpp
index 7706d2cf7..13ec8c920 100644
--- a/src/rpc/core_rpc_server.cpp
+++ b/src/rpc/core_rpc_server.cpp
@@ -377,6 +377,7 @@ namespace cryptonote
for(auto& bd: bs)
{
res.blocks.resize(res.blocks.size()+1);
+ res.blocks.back().pruned = req.prune;
res.blocks.back().block = bd.first.first;
pruned_size += bd.first.first.size();
unpruned_size += bd.first.first.size();
@@ -389,10 +390,10 @@ namespace cryptonote
for (std::vector<std::pair<crypto::hash, cryptonote::blobdata>>::iterator i = bd.second.begin(); i != bd.second.end(); ++i)
{
unpruned_size += i->second.size();
- res.blocks.back().txs.push_back(std::move(i->second));
+ res.blocks.back().txs.push_back({std::move(i->second), crypto::null_hash});
i->second.clear();
i->second.shrink_to_fit();
- pruned_size += res.blocks.back().txs.back().size();
+ pruned_size += res.blocks.back().txs.back().blob.size();
}
const size_t n_txes_to_lookup = bd.second.size() + (req.no_miner_tx ? 0 : 1);
@@ -474,7 +475,7 @@ namespace cryptonote
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.blocks.back().txs.push_back({tx_to_blob(tx), crypto::null_hash});
}
res.status = CORE_RPC_STATUS_OK;
return true;
@@ -488,7 +489,7 @@ namespace cryptonote
return r;
res.start_height = req.start_height;
- if(!m_core.get_blockchain_storage().find_blockchain_supplement(req.block_ids, res.m_block_ids, res.start_height, res.current_height, false))
+ if(!m_core.get_blockchain_storage().find_blockchain_supplement(req.block_ids, res.m_block_ids, NULL, res.start_height, res.current_height, false))
{
res.status = "Failed";
add_host_fail(ctx);
@@ -912,7 +913,7 @@ namespace cryptonote
cryptonote_connection_context fake_context = AUTO_VAL_INIT(fake_context);
tx_verification_context tvc = AUTO_VAL_INIT(tvc);
- if(!m_core.handle_incoming_tx(tx_blob, tvc, false, false, req.do_not_relay) || tvc.m_verifivation_failed)
+ if(!m_core.handle_incoming_tx({tx_blob, crypto::null_hash}, tvc, false, false, req.do_not_relay) || tvc.m_verifivation_failed)
{
res.status = "Failed";
std::string reason = "";