79int main(
int argc,
char* argv[])
85 std::string default_db_type =
"lmdb";
88 available_dbs =
"available: " + available_dbs;
94 boost::filesystem::path output_file_path;
96 po::options_description desc_cmd_only(
"Command line options");
97 po::options_description desc_cmd_sett(
"Command line options and settings options");
100 "database", available_dbs.c_str(), default_db_type
113 po::options_description desc_options(
"Allowed options");
114 desc_options.add(desc_cmd_only).add(desc_cmd_sett);
116 po::positional_options_description positional_options;
117 positional_options.add(arg_input.name, -1);
119 po::variables_map vm;
122 auto parser = po::command_line_parser(argc, argv).options(desc_options).positional(positional_options);
123 po::store(parser.run(), vm);
133 std::cout << desc_options << std::endl;
141 mlog_set_log(std::string(std::to_string(log_level) +
",bcutil:INFO").c_str());
153 std::cerr <<
"Invalid database type: " << db_type << std::endl;
168 LOG_PRINT_L0(
"Initializing source blockchain (BlockchainDB)");
170 std::unique_ptr<Blockchain> core_storage;
172 core_storage.reset(
new Blockchain(m_mempool));
176 LOG_ERROR(
"Attempted to use non-existent database type: " << db_type);
177 throw std::runtime_error(
"Attempting to use non-existent database type");
181 const std::string filename = input;
182 LOG_PRINT_L0(
"Loading blockchain from folder " << filename <<
" ...");
188 catch (
const std::exception& e)
193 r = core_storage->init(db, net_type);
196 LOG_PRINT_L0(
"Source blockchain storage initialized OK");
201 std::unordered_map<output_data, std::list<reference>> outputs;
202 std::unordered_map<uint64_t,uint64_t> indices;
207 const bool coinbase = tx.
vin.size() == 1 && tx.
vin[0].type() ==
typeid(
txin_gen);
208 const uint64_t height = core_storage->get_db().get_tx_block_height(hash);
211 for (
const auto &out: tx.
vout)
213 if (opt_rct_only && out.amount)
215 uint64_t index = indices[out.amount]++;
217 auto itb = outputs.emplace(od, std::list<reference>());
218 itb.first->first.info(coinbase,
height);
221 for (
const auto &in: tx.
vin)
225 const auto &txin = boost::get<txin_to_key>(in);
226 if (opt_rct_only && txin.amount != 0)
230 for (
size_t n = 0; n < txin.key_offsets.size(); ++n)
239 std::unordered_map<uint64_t, uint64_t> counts;
241 for (
const auto &out: outputs)
243 counts[out.second.size()]++;
248 for (
const auto &c: counts)
250 float percent = 100.f * c.second / total;
251 MINFO(std::to_string(c.second) <<
" outputs used " << c.first <<
" times (" << percent <<
"%)");
256 MINFO(
"No outputs to process");
void add_arg(boost::program_options::options_description &description, const arg_descriptor< T, required, dependent, NUM_DEPS > &arg, bool unique=true)