From 3220b005697a535c69cbfe5c212f3422e2876c56 Mon Sep 17 00:00:00 2001 From: MoneroOcean Date: Sun, 25 Mar 2018 14:43:28 +0200 Subject: [PATCH] Removed bb stuff --- src/cryptonote_core/cryptonote_basic.h | 142 ------------------ .../cryptonote_format_utils.cpp | 34 ----- src/cryptonote_core/cryptonote_format_utils.h | 12 -- 3 files changed, 188 deletions(-) diff --git a/src/cryptonote_core/cryptonote_basic.h b/src/cryptonote_core/cryptonote_basic.h index fe1ceba..3a2afdb 100644 --- a/src/cryptonote_core/cryptonote_basic.h +++ b/src/cryptonote_core/cryptonote_basic.h @@ -68,17 +68,6 @@ namespace cryptonote crypto::public_key key; }; - #pragma pack(push, 1) - struct bb_txout_to_key - { - bb_txout_to_key() { } - bb_txout_to_key(const crypto::public_key &_key) : key(_key) { } - crypto::public_key key; - uint8_t mix_attr; - }; - #pragma pack(pop) - - /* inputs */ struct txin_gen @@ -135,7 +124,6 @@ namespace cryptonote typedef boost::variant txin_v; typedef boost::variant txout_target_v; - typedef boost::variant bb_txout_target_v; //typedef std::pair out_t; struct tx_out @@ -148,16 +136,6 @@ namespace cryptonote FIELD(target) END_SERIALIZE() }; - struct bb_tx_out - { - uint64_t amount; - bb_txout_target_v target; - - BEGIN_SERIALIZE_OBJECT() - VARINT_FIELD(amount) - FIELD(target) - END_SERIALIZE() - }; class transaction_prefix { @@ -255,50 +233,6 @@ namespace cryptonote static size_t get_signature_size(const txin_v& tx_in); }; - class bb_transaction_prefix - { - - public: - // tx information - size_t version; - uint64_t unlock_time; //number of block (or time), used as a limitation like: spend this tx not early then block/time - - std::vector vin; - std::vector vout; - //extra - std::vector extra; - - BEGIN_SERIALIZE() - VARINT_FIELD(version) - VARINT_FIELD(unlock_time) - FIELD(vin) - FIELD(vout) - FIELD(extra) - END_SERIALIZE() - - - protected: - bb_transaction_prefix(){} - }; - - class bb_transaction: public bb_transaction_prefix - { - public: - std::vector > signatures; //count signatures always the same as inputs count - - bb_transaction(); - virtual ~bb_transaction(); - void set_null(); - - BEGIN_SERIALIZE_OBJECT() - FIELDS(*static_cast(this)) - FIELD(signatures) - END_SERIALIZE() - - static size_t get_signature_size(const txin_v& tx_in); - }; - - inline transaction::transaction() { @@ -336,45 +270,6 @@ namespace cryptonote return boost::apply_visitor(txin_signature_size_visitor(), tx_in); } - inline - bb_transaction::bb_transaction() - { - set_null(); - } - - inline - bb_transaction::~bb_transaction() - { - //set_null(); - } - - inline - void bb_transaction::set_null() - { - version = 0; - unlock_time = 0; - vin.clear(); - vout.clear(); - extra.clear(); - signatures.clear(); - } - - inline - size_t bb_transaction::get_signature_size(const txin_v& tx_in) - { - struct txin_signature_size_visitor : public boost::static_visitor - { - size_t operator()(const txin_gen& txin) const{return 0;} - size_t operator()(const txin_to_script& txin) const{return 0;} - size_t operator()(const txin_to_scripthash& txin) const{return 0;} - size_t operator()(const txin_to_key& txin) const {return txin.key_offsets.size();} - }; - - return boost::apply_visitor(txin_signature_size_visitor(), tx_in); - } - - - /************************************************************************/ /* */ /************************************************************************/ @@ -513,39 +408,6 @@ namespace cryptonote return serializable_bytecoin_block(block_ref.parent_block, block_ref.timestamp, hashing_serialization, header_only); } - - struct bb_block_header - { - uint8_t major_version; - uint8_t minor_version; - uint64_t timestamp; - crypto::hash prev_id; - uint64_t nonce; - uint8_t flags; - - BEGIN_SERIALIZE() - FIELD(major_version) - FIELD(nonce) - FIELD(prev_id) - VARINT_FIELD(minor_version) - VARINT_FIELD(timestamp) - FIELD(flags) - END_SERIALIZE() - }; - - struct bb_block: public bb_block_header - { - bb_transaction miner_tx; - std::vector tx_hashes; - - BEGIN_SERIALIZE() - FIELDS(*static_cast(this)) - FIELD(miner_tx) - FIELD(tx_hashes) - END_SERIALIZE() - }; - - /************************************************************************/ /* */ /************************************************************************/ @@ -597,7 +459,6 @@ namespace cryptonote } BLOB_SERIALIZER(cryptonote::txout_to_key); -BLOB_SERIALIZER(cryptonote::bb_txout_to_key); BLOB_SERIALIZER(cryptonote::txout_to_scripthash); VARIANT_TAG(binary_archive, cryptonote::txin_gen, 0xff); @@ -607,7 +468,6 @@ VARIANT_TAG(binary_archive, cryptonote::txin_to_key, 0x2); VARIANT_TAG(binary_archive, cryptonote::txout_to_script, 0x0); VARIANT_TAG(binary_archive, cryptonote::txout_to_scripthash, 0x1); VARIANT_TAG(binary_archive, cryptonote::txout_to_key, 0x2); -VARIANT_TAG(binary_archive, cryptonote::bb_txout_to_key, 0x2); VARIANT_TAG(binary_archive, cryptonote::transaction, 0xcc); VARIANT_TAG(binary_archive, cryptonote::block, 0xbb); @@ -618,7 +478,6 @@ VARIANT_TAG(json_archive, cryptonote::txin_to_key, "key"); 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::bb_txout_to_key, "key"); VARIANT_TAG(json_archive, cryptonote::transaction, "tx"); VARIANT_TAG(json_archive, cryptonote::block, "block"); @@ -629,6 +488,5 @@ VARIANT_TAG(debug_archive, cryptonote::txin_to_key, "key"); 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::bb_txout_to_key, "key"); VARIANT_TAG(debug_archive, cryptonote::transaction, "tx"); VARIANT_TAG(debug_archive, cryptonote::block, "block"); diff --git a/src/cryptonote_core/cryptonote_format_utils.cpp b/src/cryptonote_core/cryptonote_format_utils.cpp index 49f42c3..dc496de 100644 --- a/src/cryptonote_core/cryptonote_format_utils.cpp +++ b/src/cryptonote_core/cryptonote_format_utils.cpp @@ -365,12 +365,6 @@ namespace cryptonote return get_object_hash(t, res, blob_size); } - bool get_transaction_hash(const bb_transaction& t, crypto::hash& res) - { - size_t blob_size = 0; - return get_object_hash(static_cast(t), res, blob_size); - } - //--------------------------------------------------------------- bool get_transaction_hash(const transaction& t, crypto::hash& res, size_t* blob_size) { @@ -447,15 +441,6 @@ namespace cryptonote auto sbb = make_serializable_bytecoin_block(b, true, true); return t_serializable_object_to_blob(sbb, blob); } - - blobdata get_block_hashing_blob(const bb_block& b) - { - blobdata blob = t_serializable_object_to_blob(static_cast(b)); - crypto::hash tree_root_hash = get_tx_tree_hash(b); - blob.append((const char*)&tree_root_hash, sizeof(tree_root_hash )); - blob.append(tools::get_varint_data(b.tx_hashes.size()+1)); - return blob; - } //--------------------------------------------------------------- bool get_block_hash(const block& b, crypto::hash& res) { @@ -546,15 +531,6 @@ namespace cryptonote CHECK_AND_ASSERT_MES(r, false, "Failed to parse block from blob"); return true; } - bool parse_and_validate_block_from_blob(const blobdata& b_blob, bb_block& b) - { - std::stringstream ss; - ss << b_blob; - binary_archive ba(ss); - bool r = ::serialization::serialize(ba, b); - CHECK_AND_ASSERT_MES(r, false, "Failed to parse block from blob"); - return true; - } //--------------------------------------------------------------- blobdata block_to_blob(const block& b) { @@ -599,15 +575,5 @@ namespace cryptonote txs_ids.push_back(th); return get_tx_tree_hash(txs_ids); } - crypto::hash get_tx_tree_hash(const bb_block& b) - { - std::vector txs_ids; - crypto::hash h = null_hash; - get_transaction_hash(b.miner_tx, h); - txs_ids.push_back(h); - BOOST_FOREACH(auto& th, b.tx_hashes) - txs_ids.push_back(th); - return get_tx_tree_hash(txs_ids); - } //--------------------------------------------------------------- } diff --git a/src/cryptonote_core/cryptonote_format_utils.h b/src/cryptonote_core/cryptonote_format_utils.h index 0ce77d2..915e487 100644 --- a/src/cryptonote_core/cryptonote_format_utils.h +++ b/src/cryptonote_core/cryptonote_format_utils.h @@ -19,7 +19,6 @@ namespace cryptonote crypto::hash get_transaction_prefix_hash(const transaction_prefix& tx); bool parse_and_validate_tx_from_blob(const blobdata& tx_blob, transaction& tx, crypto::hash& tx_hash, crypto::hash& tx_prefix_hash); bool parse_and_validate_tx_from_blob(const blobdata& tx_blob, transaction& tx); - //bool construct_miner_tx(size_t height, size_t median_size, uint64_t already_generated_coins, size_t current_block_size, uint64_t fee, const account_public_address &miner_address, transaction& tx, const blobdata& extra_nonce = blobdata(), size_t max_outs = 1); struct tx_source_entry { @@ -80,22 +79,17 @@ namespace cryptonote bool get_transaction_hash(const transaction& t, crypto::hash& res, size_t* blob_size); bool get_block_hashing_blob(const block& b, blobdata& blob); bool get_bytecoin_block_hashing_blob(const block& b, blobdata& blob); - blobdata get_block_hashing_blob(const bb_block& b); bool get_block_hash(const block& b, crypto::hash& res); crypto::hash get_block_hash(const block& b); bool get_block_header_hash(const block& b, crypto::hash& res); bool get_block_longhash(const block& b, crypto::hash& res, uint64_t height); crypto::hash get_block_longhash(const block& b, uint64_t height); bool get_bytecoin_block_longhash(const block& blk, crypto::hash& res); - //bool generate_genesis_block(block& bl); - //bool get_genesis_block_hash(crypto::hash& h); bool parse_and_validate_block_from_blob(const blobdata& b_blob, block& b); - bool parse_and_validate_block_from_blob(const blobdata& b_blob, bb_block& b); bool get_inputs_money_amount(const transaction& tx, uint64_t& money); uint64_t get_outs_money_amount(const transaction& tx); bool check_inputs_types_supported(const transaction& tx); bool check_outs_valid(const transaction& tx); - //bool parse_amount(uint64_t& amount, const std::string& str_amount); bool check_money_overflow(const transaction& tx); bool check_outs_overflow(const transaction& tx); @@ -103,7 +97,6 @@ namespace cryptonote uint64_t get_block_height(const block& b); std::vector relative_output_offsets_to_absolute(const std::vector& off); std::vector absolute_output_offsets_to_relative(const std::vector& off); - //std::string print_money(uint64_t amount); //--------------------------------------------------------------- template bool t_serializable_object_to_blob(const t_object& to, blobdata& b_blob) @@ -205,11 +198,6 @@ namespace cryptonote void get_tx_tree_hash(const std::vector& tx_hashes, crypto::hash& h); crypto::hash get_tx_tree_hash(const std::vector& tx_hashes); crypto::hash get_tx_tree_hash(const block& b); - crypto::hash get_tx_tree_hash(const bb_block& b); - - //bool check_proof_of_work_v1(const block& bl, difficulty_type current_diffic, crypto::hash& proof_of_work); - //bool check_proof_of_work_v2(const block& bl, difficulty_type current_diffic, crypto::hash& proof_of_work); - //bool check_proof_of_work(const block& bl, difficulty_type current_diffic, crypto::hash& proof_of_work); #define CHECKED_GET_SPECIFIC_VARIANT(variant_var, specific_type, variable_name, fail_return_val) \ CHECK_AND_ASSERT_MES(variant_var.type() == typeid(specific_type), fail_return_val, "wrong variant type: " << variant_var.type().name() << ", expected " << typeid(specific_type).name()); \