108 available_dbs =
"available: " + available_dbs;
114 po::options_description desc_cmd_only(
"Command line options");
115 po::options_description desc_cmd_sett(
"Command line options and settings options");
118 "database", available_dbs.c_str(), default_db_type
134 po::options_description desc_options(
"Allowed options");
135 desc_options.add(desc_cmd_only).add(desc_cmd_sett);
137 po::variables_map vm;
140 auto parser = po::command_line_parser(argc, argv).options(desc_options);
141 po::store(parser.run(), vm);
151 std::cout << desc_options << std::endl;
173 std::cerr <<
"Invalid database type: " << db_type << std::endl;
179 LOG_PRINT_L0(
"Initializing source blockchain (BlockchainDB)");
180 std::unique_ptr<Blockchain> core_storage;
182 core_storage.reset(
new Blockchain(m_mempool));
186 LOG_ERROR(
"Attempted to use non-existent database type: " << db_type);
187 throw std::runtime_error(
"Attempting to use non-existent database type");
192 LOG_PRINT_L0(
"Loading blockchain from folder " << filename <<
" ...");
196 db->
open(filename, 0);
198 catch (
const std::exception& e)
203 r = core_storage->
init(db, net_type);
206 LOG_PRINT_L0(
"Source blockchain storage initialized OK");
208 std::map<uint64_t, uint64_t> known_spent_outputs;
211 std::map<uint64_t, std::pair<uint64_t, uint64_t>> outputs;
215 const bool miner_tx = tx.
vin.size() == 1 && tx.
vin[0].type() ==
typeid(
txin_gen);
216 for (
const auto &in: tx.
vin)
220 const auto &txin = boost::get<txin_to_key>(
in);
221 if (txin.amount == 0)
224 outputs[txin.amount].second++;
227 for (
const auto &out: tx.
vout)
233 outputs[amount].first++;
238 for (
const auto &i: outputs)
240 known_spent_outputs[i.first] = i.second.second;
246 known_spent_outputs = load_outputs(input);
251 bool stop_requested =
false;
253 stop_requested =
true;
258 size_t num_total_outputs = 0, num_prunable_outputs = 0, num_known_spent_outputs = 0, num_eligible_outputs = 0, num_eligible_known_spent_outputs = 0;
259 for (
auto i = known_spent_outputs.begin(); i != known_spent_outputs.end(); ++i)
262 num_total_outputs += num_outputs;
263 num_known_spent_outputs += i->second;
267 MINFO(
"Ignoring output value " << i->first <<
", with " << num_outputs <<
" outputs");
270 num_eligible_outputs += num_outputs;
271 num_eligible_known_spent_outputs += i->second;
273 MINFO(i->first <<
": " << i->second <<
"/" << num_outputs);
274 if (num_outputs > i->second)
276 if (num_outputs && num_outputs < i->second)
278 MERROR(
"More outputs are spent than known for amount " << i->first <<
", not touching");
282 MINFO(
"Pruning data for " << num_outputs <<
" outputs");
285 num_prunable_outputs += i->second;
290 MINFO(
"Total outputs: " << num_total_outputs);
291 MINFO(
"Known spent outputs: " << num_known_spent_outputs);
292 MINFO(
"Eligible outputs: " << num_eligible_outputs);
293 MINFO(
"Eligible known spent outputs: " << num_eligible_known_spent_outputs);
294 MINFO(
"Prunable outputs: " << num_prunable_outputs);
const char *const ELECTRONEUM_RELEASE_NAME
virtual std::string get_db_name() const =0
gets the name of the folder the BlockchainDB's file(s) should be in
#define CHECK_AND_ASSERT_MES(expr, fail_ret_val, message)
void mlog_set_log(const char *log)
#define CATCH_ENTRY(location, return_val)
std::string mlog_get_default_log_path(const char *default_filename)
void mlog_configure(const std::string &filename_base, bool console, const std::size_t max_log_file_size=MAX_LOG_FILE_SIZE, const std::size_t max_log_files=MAX_LOG_FILES)
const command_line::arg_descriptor< bool, false > arg_stagenet_on
const arg_descriptor< bool > arg_help
std::string blockchain_db_types(const std::string &sep)
virtual bool for_all_transactions(std::function< bool(const crypto::hash &, const cryptonote::transaction &)>, bool pruned) const =0
runs a function over all transactions stored
virtual uint64_t get_num_outputs(const uint64_t &amount) const =0
fetches the number of outputs of a given amount
virtual void open(const std::string &filename, const int db_flags=0)=0
open a db, or create it if necessary.
std::vector< tx_out > vout
const char *const ELECTRONEUM_VERSION_FULL
bool blockchain_valid_db_type(const std::string &db_type)
std::vector< txin_v > vin
bool is_valid_decomposed_amount(uint64_t amount)
const command_line::arg_descriptor< bool, false > arg_testnet_on
BlockchainDB * new_db(const std::string &db_type)
bool handle_error_helper(const boost::program_options::options_description &desc, F parser)
const command_line::arg_descriptor< std::string > arg_log_level
virtual void prune_outputs(uint64_t amount)=0
prune output data for the given amount
unsigned __int64 uint64_t
const command_line::arg_descriptor< std::string, false, true, 2 > arg_data_dir
virtual void batch_stop()=0
ends a batch transaction
void add_arg(boost::program_options::options_description &description, const arg_descriptor< T, required, dependent, NUM_DEPS > &arg, bool unique=true)
Transaction pool, handles transactions which are not part of a block.
The BlockchainDB backing store interface declaration/contract.
T get_arg(const boost::program_options::variables_map &vm, const arg_descriptor< T, false, true > &arg)
bool init(BlockchainDB *db, const network_type nettype=MAINNET, bool offline=false, const cryptonote::test_options *test_options=NULL, difficulty_type fixed_difficulty=0, const GetCheckpointsCallback &get_checkpoints=nullptr, bool ignore_bsig=false, bool fallback_to_pow=false)
Initialize the Blockchain state.
std::string to_string(t_connection_type type)
bool is_arg_defaulted(const boost::program_options::variables_map &vm, const arg_descriptor< T, required, dependent, NUM_DEPS > &arg)
bool deinit()
Uninitializes the blockchain state.
virtual bool batch_start(uint64_t batch_num_blocks=0, uint64_t batch_bytes=0)=0
tells the BlockchainDB to start a new "batch" of blocks