aboutsummaryrefslogtreecommitdiff
path: root/src/serialization
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/serialization
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/serialization')
-rw-r--r--src/serialization/json_object.cpp19
-rw-r--r--src/serialization/json_object.h3
2 files changed, 22 insertions, 0 deletions
diff --git a/src/serialization/json_object.cpp b/src/serialization/json_object.cpp
index cc52bde58..42d09aa5f 100644
--- a/src/serialization/json_object.cpp
+++ b/src/serialization/json_object.cpp
@@ -627,6 +627,25 @@ void fromJsonValue(const rapidjson::Value& val, cryptonote::connection_info& inf
GET_FROM_JSON_OBJECT(val, info.current_upload, current_upload);
}
+void toJsonValue(rapidjson::Document& doc, const cryptonote::tx_blob_entry& tx, rapidjson::Value& val)
+{
+ val.SetObject();
+
+ INSERT_INTO_JSON_OBJECT(val, doc, blob, tx.blob);
+ INSERT_INTO_JSON_OBJECT(val, doc, prunable_hash, tx.prunable_hash);
+}
+
+void fromJsonValue(const rapidjson::Value& val, cryptonote::tx_blob_entry& tx)
+{
+ if (!val.IsObject())
+ {
+ throw WRONG_TYPE("json object");
+ }
+
+ GET_FROM_JSON_OBJECT(val, tx.blob, blob);
+ GET_FROM_JSON_OBJECT(val, tx.prunable_hash, prunable_hash);
+}
+
void toJsonValue(rapidjson::Document& doc, const cryptonote::block_complete_entry& blk, rapidjson::Value& val)
{
val.SetObject();
diff --git a/src/serialization/json_object.h b/src/serialization/json_object.h
index c804d148b..5ef75b863 100644
--- a/src/serialization/json_object.h
+++ b/src/serialization/json_object.h
@@ -221,6 +221,9 @@ void fromJsonValue(const rapidjson::Value& val, cryptonote::tx_out& txout);
void toJsonValue(rapidjson::Document& doc, const cryptonote::connection_info& info, rapidjson::Value& val);
void fromJsonValue(const rapidjson::Value& val, cryptonote::connection_info& info);
+void toJsonValue(rapidjson::Document& doc, const cryptonote::tx_blob_entry& tx, rapidjson::Value& val);
+void fromJsonValue(const rapidjson::Value& val, cryptonote::tx_blob_entry& tx);
+
void toJsonValue(rapidjson::Document& doc, const cryptonote::block_complete_entry& blk, rapidjson::Value& val);
void fromJsonValue(const rapidjson::Value& val, cryptonote::block_complete_entry& blk);