Electroneum
Loading...
Searching...
No Matches
core_proxy.h
Go to the documentation of this file.
1// Copyrights(c) 2017-2021, The Electroneum Project
2// Copyrights(c) 2014-2019, The Monero Project
3//
4// All rights reserved.
5//
6// Redistribution and use in source and binary forms, with or without modification, are
7// permitted provided that the following conditions are met:
8//
9// 1. Redistributions of source code must retain the above copyright notice, this list of
10// conditions and the following disclaimer.
11//
12// 2. Redistributions in binary form must reproduce the above copyright notice, this list
13// of conditions and the following disclaimer in the documentation and/or other
14// materials provided with the distribution.
15//
16// 3. Neither the name of the copyright holder nor the names of its contributors may be
17// used to endorse or promote products derived from this software without specific
18// prior written permission.
19//
20// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY
21// EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
22// MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL
23// THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
24// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
25// PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
26// INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
27// STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF
28// THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
29//
30// Parts of this file are originally copyright (c) 2012-2013 The Cryptonote developers
31
32#pragma once
33
34#include <boost/program_options/variables_map.hpp>
35
38#include <unordered_map>
39
40namespace tests
41{
42 struct block_index {
43 size_t height;
48 std::list<cryptonote::transaction> txes;
49
50 block_index() : height(0), id(crypto::null_hash), longhash(crypto::null_hash) { }
51 block_index(size_t _height, const crypto::hash &_id, const crypto::hash &_longhash, const cryptonote::block &_blk, const cryptonote::blobdata &_blob, const std::list<cryptonote::transaction> &_txes)
52 : height(_height), id(_id), longhash(_longhash), blk(_blk), blob(_blob), txes(_txes) { }
53 };
54
56 {
57 cryptonote::block m_genesis;
58 std::list<crypto::hash> m_known_block_list;
59 std::unordered_map<crypto::hash, block_index> m_hash2blkidx;
60
61 crypto::hash m_lastblk;
62 std::list<cryptonote::transaction> txes;
63
64 bool add_block(const crypto::hash &_id, const crypto::hash &_longhash, const cryptonote::block &_blk, const cryptonote::blobdata &_blob);
65 void build_short_history(std::list<crypto::hash> &m_history, const crypto::hash &m_start);
66
67
68 public:
70 void safesyncmode(const bool){}
73 bool init(const boost::program_options::variables_map& vm);
74 bool deinit(){return true;}
75 bool get_short_chain_history(std::list<crypto::hash>& ids);
76 bool get_stat_info(cryptonote::core_stat_info& st_inf){return true;}
77 bool have_block(const crypto::hash& id);
79 bool handle_incoming_tx(const cryptonote::blobdata& tx_blob, cryptonote::tx_verification_context& tvc, bool keeped_by_block, bool relayed, bool do_not_relay);
80 bool handle_incoming_txs(const std::vector<cryptonote::blobdata>& tx_blobs, std::vector<cryptonote::tx_verification_context>& tvc, bool keeped_by_block, bool relayed, bool do_not_relay);
81 bool handle_incoming_block(const cryptonote::blobdata& block_blob, const cryptonote::block *block, cryptonote::block_verification_context& bvc, bool update_miner_blocktemplate = true);
82 void pause_mine(){}
83 void resume_mine(){}
84 bool on_idle(){return true;}
85 bool find_blockchain_supplement(const std::list<crypto::hash>& qblock_ids, cryptonote::NOTIFY_RESPONSE_CHAIN_ENTRY::request& resp){return true;}
87 cryptonote::Blockchain &get_blockchain_storage() { throw std::runtime_error("Called invalid member function: please never call get_blockchain_storage on the TESTING class proxy_core."); }
88 bool get_test_drop_download() {return true;}
89 bool get_test_drop_download_height() {return true;}
90 bool prepare_handle_incoming_blocks(const std::vector<cryptonote::block_complete_entry> &blocks_entry, std::vector<cryptonote::block> &blocks) { return true; }
91 bool cleanup_handle_incoming_blocks(bool force_sync = false) { return true; }
96 bool get_pool_transaction(const crypto::hash& id, cryptonote::blobdata& tx_blob) const { return false; }
97 bool pool_has_tx(const crypto::hash &txid) const { return false; }
98 bool get_blocks(uint64_t start_offset, size_t count, std::vector<std::pair<cryptonote::blobdata, cryptonote::block>>& blocks, std::vector<cryptonote::blobdata>& txs) const { return false; }
99 bool get_transactions(const std::vector<crypto::hash>& txs_ids, std::vector<cryptonote::transaction>& txs, std::vector<crypto::hash>& missed_txs) const { return false; }
100 bool get_block_by_hash(const crypto::hash &h, cryptonote::block &blk, bool *orphan = NULL) const { return false; }
106 bool fluffy_blocks_enabled() const { return false; }
107 uint64_t prevalidate_block_hashes(uint64_t height, const std::vector<crypto::hash> &hashes) { return 0; }
108 bool pad_transactions() const { return false; }
110 bool prune_blockchain(uint32_t pruning_seed) const { return true; }
113 bool isValidatorsListValid() { return true; }
114 std::string get_validators_list() { return ""; }
115 };
116}
uint64_t height
uint8_t version
void set_target_blockchain_height(uint64_t)
Definition core_proxy.h:72
bool get_transactions(const std::vector< crypto::hash > &txs_ids, std::vector< cryptonote::transaction > &txs, std::vector< crypto::hash > &missed_txs) const
Definition core_proxy.h:99
uint64_t get_current_blockchain_height()
Definition core_proxy.h:71
bool handle_incoming_tx(const cryptonote::blobdata &tx_blob, cryptonote::tx_verification_context &tvc, bool keeped_by_block, bool relayed, bool do_not_relay)
bool fluffy_blocks_enabled() const
Definition core_proxy.h:106
bool isValidatorsListValid()
Definition core_proxy.h:113
bool get_test_drop_download_height()
Definition core_proxy.h:89
uint8_t get_ideal_hard_fork_version(uint64_t height) const
Definition core_proxy.h:102
uint8_t get_hard_fork_version(uint64_t height) const
Definition core_proxy.h:103
bool get_stat_info(cryptonote::core_stat_info &st_inf)
Definition core_proxy.h:76
bool get_block_by_hash(const crypto::hash &h, cryptonote::block &blk, bool *orphan=NULL) const
Definition core_proxy.h:100
bool prepare_handle_incoming_blocks(const std::vector< cryptonote::block_complete_entry > &blocks_entry, std::vector< cryptonote::block > &blocks)
Definition core_proxy.h:90
bool cleanup_handle_incoming_blocks(bool force_sync=false)
Definition core_proxy.h:91
electroneum::basic::list_update_outcome set_validators_list(std::string v_list, bool isEmergencyUpdate=false)
Definition core_proxy.h:112
void get_blockchain_top(uint64_t &height, crypto::hash &top_id)
bool init(const boost::program_options::variables_map &vm)
void on_synchronized()
Definition core_proxy.h:69
bool handle_get_objects(cryptonote::NOTIFY_REQUEST_GET_OBJECTS::request &arg, cryptonote::NOTIFY_RESPONSE_GET_OBJECTS::request &rsp, cryptonote::cryptonote_connection_context &context)
Definition core_proxy.h:86
bool get_blocks(uint64_t start_offset, size_t count, std::vector< std::pair< cryptonote::blobdata, cryptonote::block > > &blocks, std::vector< cryptonote::blobdata > &txs) const
Definition core_proxy.h:98
cryptonote::network_type get_nettype() const
Definition core_proxy.h:95
bool handle_incoming_txs(const std::vector< cryptonote::blobdata > &tx_blobs, std::vector< cryptonote::tx_verification_context > &tvc, bool keeped_by_block, bool relayed, bool do_not_relay)
size_t get_block_sync_size(uint64_t height) const
Definition core_proxy.h:93
bool pool_has_tx(const crypto::hash &txid) const
Definition core_proxy.h:97
bool handle_incoming_block(const cryptonote::blobdata &block_blob, const cryptonote::block *block, cryptonote::block_verification_context &bvc, bool update_miner_blocktemplate=true)
cryptonote::difficulty_type get_block_cumulative_difficulty(uint64_t height) const
Definition core_proxy.h:105
bool get_test_drop_download()
Definition core_proxy.h:88
std::string get_validators_list()
Definition core_proxy.h:114
uint64_t prevalidate_block_hashes(uint64_t height, const std::vector< crypto::hash > &hashes)
Definition core_proxy.h:107
bool get_short_chain_history(std::list< crypto::hash > &ids)
bool get_pool_transaction(const crypto::hash &id, cryptonote::blobdata &tx_blob) const
Definition core_proxy.h:96
cryptonote::Blockchain & get_blockchain_storage()
Definition core_proxy.h:87
uint64_t get_target_blockchain_height() const
Definition core_proxy.h:92
bool find_blockchain_supplement(const std::list< crypto::hash > &qblock_ids, cryptonote::NOTIFY_RESPONSE_CHAIN_ENTRY::request &resp)
Definition core_proxy.h:85
uint8_t get_ideal_hard_fork_version() const
Definition core_proxy.h:101
uint64_t get_earliest_ideal_height_for_version(uint8_t version) const
Definition core_proxy.h:104
bool pad_transactions() const
Definition core_proxy.h:108
void set_block_cumulative_difficulty(uint64_t height, cryptonote::difficulty_type diff)
Definition core_proxy.h:111
void safesyncmode(const bool)
Definition core_proxy.h:70
virtual void on_transaction_relayed(const cryptonote::blobdata &tx)
Definition core_proxy.h:94
bool prune_blockchain(uint32_t pruning_seed) const
Definition core_proxy.h:110
uint32_t get_blockchain_pruning_seed() const
Definition core_proxy.h:109
bool have_block(const crypto::hash &id)
#define BLOCKS_SYNCHRONIZING_DEFAULT_COUNT
crypto namespace.
Definition crypto.cpp:58
POD_CLASS hash
Definition hash.h:50
boost::multiprecision::uint128_t difficulty_type
Definition difficulty.h:43
std::string blobdata
epee::misc_utils::struct_init< core_stat_info_t > core_stat_info
unsigned int uint32_t
Definition stdint.h:126
unsigned char uint8_t
Definition stdint.h:124
unsigned __int64 uint64_t
Definition stdint.h:136
epee::misc_utils::struct_init< request_t > request
epee::misc_utils::struct_init< request_t > request
epee::misc_utils::struct_init< request_t > request
crypto::hash id
Definition core_proxy.h:44
crypto::hash longhash
Definition core_proxy.h:45
cryptonote::blobdata blob
Definition core_proxy.h:47
cryptonote::block blk
Definition core_proxy.h:46
std::list< cryptonote::transaction > txes
Definition core_proxy.h:48
block_index(size_t _height, const crypto::hash &_id, const crypto::hash &_longhash, const cryptonote::block &_blk, const cryptonote::blobdata &_blob, const std::list< cryptonote::transaction > &_txes)
Definition core_proxy.h:51
struct hash_func hashes[]