From 3b5542e94a71a7fba4972786bd2d980a57743e15 Mon Sep 17 00:00:00 2001 From: MoneroOcean Date: Thu, 4 Aug 2022 06:15:11 +0000 Subject: [PATCH] Removed stuff' --- src/cryptonote_core/cryptonote_basic.h | 32 ---- src/cryptonote_core/cryptonote_format_utils.h | 10 -- src/ringct/rctTypes.h | 36 ----- src/serialization/debug_archive.h | 28 ---- src/serialization/json_archive.h | 145 ------------------ src/serialization/json_utils.h | 21 --- 6 files changed, 272 deletions(-) delete mode 100644 src/serialization/debug_archive.h delete mode 100644 src/serialization/json_archive.h delete mode 100644 src/serialization/json_utils.h diff --git a/src/cryptonote_core/cryptonote_basic.h b/src/cryptonote_core/cryptonote_basic.h index e22d6e0..9a30fe5 100644 --- a/src/cryptonote_core/cryptonote_basic.h +++ b/src/cryptonote_core/cryptonote_basic.h @@ -14,8 +14,6 @@ #include "serialization/variant.h" #include "serialization/vector.h" #include "serialization/binary_archive.h" -#include "serialization/json_archive.h" -#include "serialization/debug_archive.h" #include "serialization/crypto.h" #include "serialization/pricing_record.h" #include "serialization/keyvalue_serialization.h" // eepe named serialization @@ -658,33 +656,3 @@ VARIANT_TAG(binary_archive, cryptonote::txout_offshore, 0x3); VARIANT_TAG(binary_archive, cryptonote::txout_xasset, 0x5); VARIANT_TAG(binary_archive, cryptonote::transaction, 0xcc); VARIANT_TAG(binary_archive, cryptonote::block, 0xbb); - -VARIANT_TAG(json_archive, cryptonote::txin_gen, "gen"); -VARIANT_TAG(json_archive, cryptonote::txin_to_script, "script"); -VARIANT_TAG(json_archive, cryptonote::txin_to_scripthash, "scripthash"); -VARIANT_TAG(json_archive, cryptonote::txin_to_key, "key"); -VARIANT_TAG(json_archive, cryptonote::txin_offshore, "offshore"); -VARIANT_TAG(json_archive, cryptonote::txin_onshore, "onshore"); -VARIANT_TAG(json_archive, cryptonote::txin_xasset, "xasset"); -VARIANT_TAG(json_archive, cryptonote::txout_to_script, "script"); -VARIANT_TAG(json_archive, cryptonote::txout_to_scripthash, "scripthash"); -VARIANT_TAG(json_archive, cryptonote::txout_to_key, "key"); -VARIANT_TAG(json_archive, cryptonote::txout_offshore, "offshore"); -VARIANT_TAG(json_archive, cryptonote::txout_xasset, "xasset"); -VARIANT_TAG(json_archive, cryptonote::transaction, "tx"); -VARIANT_TAG(json_archive, cryptonote::block, "block"); - -VARIANT_TAG(debug_archive, cryptonote::txin_gen, "gen"); -VARIANT_TAG(debug_archive, cryptonote::txin_to_script, "script"); -VARIANT_TAG(debug_archive, cryptonote::txin_to_scripthash, "scripthash"); -VARIANT_TAG(debug_archive, cryptonote::txin_to_key, "key"); -VARIANT_TAG(debug_archive, cryptonote::txin_offshore, "offshore"); -VARIANT_TAG(debug_archive, cryptonote::txin_onshore, "onshore"); -VARIANT_TAG(debug_archive, cryptonote::txin_xasset, "xasset"); -VARIANT_TAG(debug_archive, cryptonote::txout_to_script, "script"); -VARIANT_TAG(debug_archive, cryptonote::txout_to_scripthash, "scripthash"); -VARIANT_TAG(debug_archive, cryptonote::txout_to_key, "key"); -VARIANT_TAG(debug_archive, cryptonote::txout_offshore, "offshore"); -VARIANT_TAG(debug_archive, cryptonote::txout_xasset, "xasset"); -VARIANT_TAG(debug_archive, cryptonote::transaction, "tx"); -VARIANT_TAG(debug_archive, cryptonote::block, "block"); diff --git a/src/cryptonote_core/cryptonote_format_utils.h b/src/cryptonote_core/cryptonote_format_utils.h index fb49065..6ac24b9 100644 --- a/src/cryptonote_core/cryptonote_format_utils.h +++ b/src/cryptonote_core/cryptonote_format_utils.h @@ -138,16 +138,6 @@ namespace cryptonote return true; } //--------------------------------------------------------------- - template - std::string obj_to_json_str(T& obj) - { - std::stringstream ss; - json_archive ar(ss, true); - bool r = ::serialization::serialize(ar, obj); - CHECK_AND_ASSERT_MES(r, "", "obj_to_json_str failed: serialization::serialize returned false"); - return ss.str(); - } - //--------------------------------------------------------------- // 62387455827 -> 455827 + 7000000 + 80000000 + 300000000 + 2000000000 + 60000000000, where 455827 <= dust_threshold template void decompose_amount_into_digits(uint64_t amount, uint64_t dust_threshold, const chunk_handler_t& chunk_handler, const dust_handler_t& dust_handler) diff --git a/src/ringct/rctTypes.h b/src/ringct/rctTypes.h index 7d60d70..641cd56 100644 --- a/src/ringct/rctTypes.h +++ b/src/ringct/rctTypes.h @@ -50,9 +50,7 @@ extern "C" { #include "span.h" #include "memwipe.h" #include "serialization/vector.h" -#include "serialization/debug_archive.h" #include "serialization/binary_archive.h" -#include "serialization/json_archive.h" //Define this flag when debugging to get additional info on the console @@ -739,23 +737,6 @@ BLOB_SERIALIZER(rct::ctkey); BLOB_SERIALIZER(rct::multisig_kLRki); BLOB_SERIALIZER(rct::boroSig); -VARIANT_TAG(debug_archive, rct::key, "rct::key"); -VARIANT_TAG(debug_archive, rct::key64, "rct::key64"); -VARIANT_TAG(debug_archive, rct::keyV, "rct::keyV"); -VARIANT_TAG(debug_archive, rct::keyM, "rct::keyM"); -VARIANT_TAG(debug_archive, rct::ctkey, "rct::ctkey"); -VARIANT_TAG(debug_archive, rct::ctkeyV, "rct::ctkeyV"); -VARIANT_TAG(debug_archive, rct::ctkeyM, "rct::ctkeyM"); -VARIANT_TAG(debug_archive, rct::ecdhTuple, "rct::ecdhTuple"); -VARIANT_TAG(debug_archive, rct::mgSig, "rct::mgSig"); -VARIANT_TAG(debug_archive, rct::rangeSig, "rct::rangeSig"); -VARIANT_TAG(debug_archive, rct::boroSig, "rct::boroSig"); -VARIANT_TAG(debug_archive, rct::rctSig, "rct::rctSig"); -VARIANT_TAG(debug_archive, rct::Bulletproof, "rct::bulletproof"); -VARIANT_TAG(debug_archive, rct::multisig_kLRki, "rct::multisig_kLRki"); -VARIANT_TAG(debug_archive, rct::multisig_out, "rct::multisig_out"); -VARIANT_TAG(debug_archive, rct::clsag, "rct::clsag"); - VARIANT_TAG(binary_archive, rct::key, 0x90); VARIANT_TAG(binary_archive, rct::key64, 0x91); VARIANT_TAG(binary_archive, rct::keyV, 0x92); @@ -773,21 +754,4 @@ VARIANT_TAG(binary_archive, rct::multisig_kLRki, 0x9d); VARIANT_TAG(binary_archive, rct::multisig_out, 0x9e); VARIANT_TAG(binary_archive, rct::clsag, 0x9f); -VARIANT_TAG(json_archive, rct::key, "rct_key"); -VARIANT_TAG(json_archive, rct::key64, "rct_key64"); -VARIANT_TAG(json_archive, rct::keyV, "rct_keyV"); -VARIANT_TAG(json_archive, rct::keyM, "rct_keyM"); -VARIANT_TAG(json_archive, rct::ctkey, "rct_ctkey"); -VARIANT_TAG(json_archive, rct::ctkeyV, "rct_ctkeyV"); -VARIANT_TAG(json_archive, rct::ctkeyM, "rct_ctkeyM"); -VARIANT_TAG(json_archive, rct::ecdhTuple, "rct_ecdhTuple"); -VARIANT_TAG(json_archive, rct::mgSig, "rct_mgSig"); -VARIANT_TAG(json_archive, rct::rangeSig, "rct_rangeSig"); -VARIANT_TAG(json_archive, rct::boroSig, "rct_boroSig"); -VARIANT_TAG(json_archive, rct::rctSig, "rct_rctSig"); -VARIANT_TAG(json_archive, rct::Bulletproof, "rct_bulletproof"); -VARIANT_TAG(json_archive, rct::multisig_kLRki, "rct_multisig_kLR"); -VARIANT_TAG(json_archive, rct::multisig_out, "rct_multisig_out"); -VARIANT_TAG(json_archive, rct::clsag, "rct_clsag"); - #endif /* RCTTYPES_H */ diff --git a/src/serialization/debug_archive.h b/src/serialization/debug_archive.h deleted file mode 100644 index 08baee0..0000000 --- a/src/serialization/debug_archive.h +++ /dev/null @@ -1,28 +0,0 @@ -// Copyright (c) 2012-2013 The Cryptonote developers -// Distributed under the MIT/X11 software license, see the accompanying -// file COPYING or http://www.opensource.org/licenses/mit-license.php. - -#pragma once - -#include "json_archive.h" -#include "variant.h" - -template -struct debug_archive : public json_archive { - typedef typename json_archive::stream_type stream_type; - - debug_archive(stream_type &s) : json_archive(s) { } -}; - -template -struct serializer, T> -{ - static void serialize(debug_archive &ar, T &v) - { - ar.begin_object(); - ar.tag(variant_serialization_traits, T>::get_tag()); - serializer, T>::serialize(ar, v); - ar.end_object(); - ar.stream() << std::endl; - } -}; diff --git a/src/serialization/json_archive.h b/src/serialization/json_archive.h deleted file mode 100644 index 49ad74d..0000000 --- a/src/serialization/json_archive.h +++ /dev/null @@ -1,145 +0,0 @@ -// Copyright (c) 2012-2013 The Cryptonote developers -// Distributed under the MIT/X11 software license, see the accompanying -// file COPYING or http://www.opensource.org/licenses/mit-license.php. - -/* json_archive.h - * - * JSON archive */ - -#pragma once - -#include "serialization.h" -#include -#include -#include - -template -struct json_archive_base -{ - typedef Stream stream_type; - typedef json_archive_base base_type; - typedef boost::mpl::bool_ is_saving; - - typedef const char *variant_tag_type; - - json_archive_base(stream_type &s, bool indent = false) : stream_(s), indent_(indent), object_begin(false), depth_(0) { } - - void tag(const char *tag) { - if (!object_begin) - stream_ << ", "; - make_indent(); - stream_ << '"' << tag << "\": "; - object_begin = false; - } - - void begin_object() - { - stream_ << "{"; - ++depth_; - object_begin = true; - } - - void end_object() - { - --depth_; - make_indent(); - stream_ << "}"; - } - - void begin_variant() { begin_object(); } - void end_variant() { end_object(); } - Stream &stream() { return stream_; } - -protected: - void make_indent() - { - if (indent_) - { - stream_ << '\n' << std::string(2 * depth_, ' '); - } - } - -protected: - stream_type &stream_; - bool indent_; - bool object_begin; - size_t depth_; -}; - -template -struct json_archive; - -template <> -struct json_archive : public json_archive_base -{ - json_archive(stream_type &s, bool indent = false) : base_type(s, indent) { } - - template - static auto promote_to_printable_integer_type(T v) -> decltype(+v) - { - // Unary operator '+' performs integral promotion on type T [expr.unary.op]. - // If T is signed or unsigned char, it's promoted to int and printed as number. - return +v; - } - - template - void serialize_int(T v) - { - stream_ << std::dec << promote_to_printable_integer_type(v); - } - - void serialize_blob(void *buf, size_t len, const char *delimiter="\"") { - begin_string(delimiter); - for (size_t i = 0; i < len; i++) { - unsigned char c = ((unsigned char *)buf)[i]; - stream_ << std::hex << std::setw(2) << std::setfill('0') << (int)c; - } - end_string(delimiter); - } - - template - void serialize_varint(T &v) - { - stream_ << std::dec << promote_to_printable_integer_type(v); - } - - void begin_string(const char *delimiter="\"") - { - stream_ << delimiter; - } - - void end_string(const char *delimiter="\"") - { - stream_ << delimiter; - } - - void begin_array(size_t s=0) - { - inner_array_size_ = s; - ++depth_; - stream_ << "[ "; - } - - void delimit_array() - { - stream_ << ", "; - } - - void end_array() - { - --depth_; - if (0 < inner_array_size_) - { - make_indent(); - } - stream_ << "]"; - } - - void write_variant_tag(const char *t) - { - tag(t); - } - -private: - size_t inner_array_size_; -}; diff --git a/src/serialization/json_utils.h b/src/serialization/json_utils.h deleted file mode 100644 index 24f5c11..0000000 --- a/src/serialization/json_utils.h +++ /dev/null @@ -1,21 +0,0 @@ -// Copyright (c) 2012-2013 The Cryptonote developers -// Distributed under the MIT/X11 software license, see the accompanying -// file COPYING or http://www.opensource.org/licenses/mit-license.php. - -#pragma once - -#include -#include "json_archive.h" - -namespace serialization { - -template -std::string dump_json(T &v) -{ - std::stringstream ostr; - json_archive oar(ostr); - assert(serialization::serialize(oar, v)); - return ostr.str(); -}; - -} // namespace serialization