80{
82
84
85 std::string default_db_type = "lmdb";
86
88 available_dbs = "available: " + available_dbs;
89
91
93
94 boost::filesystem::path output_file_path;
95
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
101 };
104
112
113 po::options_description desc_options("Allowed options");
114 desc_options.add(desc_cmd_only).add(desc_cmd_sett);
115
116 po::positional_options_description positional_options;
117 positional_options.add(arg_input.name, -1);
118
119 po::variables_map vm;
121 {
122 auto parser = po::command_line_parser(argc, argv).options(desc_options).positional(positional_options);
123 po::store(parser.run(), vm);
124 po::notify(vm);
125 return true;
126 });
127 if (! r)
128 return 1;
129
131 {
133 std::cout << desc_options << std::endl;
134 return 1;
135 }
136
140 else
141 mlog_set_log(std::string(std::to_string(log_level) +
",bcutil:INFO").c_str());
142
144
149
152 {
153 std::cerr << "Invalid database type: " << db_type << std::endl;
154 return 1;
155 }
156
157
158
159
160
161
162
163
164
165
166
167
168 LOG_PRINT_L0(
"Initializing source blockchain (BlockchainDB)");
170 std::unique_ptr<Blockchain> core_storage;
172 core_storage.reset(
new Blockchain(m_mempool));
174 if (db == NULL)
175 {
176 LOG_ERROR(
"Attempted to use non-existent database type: " << db_type);
177 throw std::runtime_error("Attempting to use non-existent database type");
178 }
180
181 const std::string filename = input;
182 LOG_PRINT_L0(
"Loading blockchain from folder " << filename <<
" ...");
183
184 try
185 {
187 }
188 catch (const std::exception& e)
189 {
191 return 1;
192 }
193 r = core_storage->init(db, net_type);
194
196 LOG_PRINT_L0(
"Source blockchain storage initialized OK");
197
199
200 size_t done = 0;
201 std::unordered_map<output_data, std::list<reference>> outputs;
202 std::unordered_map<uint64_t,uint64_t> indices;
203
206 {
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);
209
210
211 for (
const auto &out: tx.
vout)
212 {
213 if (opt_rct_only &&
out.amount)
214 continue;
217 auto itb = outputs.emplace(od, std::list<reference>());
218 itb.first->first.info(coinbase,
height);
219 }
220
221 for (
const auto &in: tx.
vin)
222 {
224 continue;
225 const auto &txin = boost::get<txin_to_key>(in);
226 if (opt_rct_only && txin.amount != 0)
227 continue;
228
230 for (size_t n = 0; n < txin.key_offsets.size(); ++n)
231 {
234 }
235 }
236 return true;
237 }, true);
238
239 std::unordered_map<uint64_t, uint64_t> counts;
240 size_t total = 0;
241 for (const auto &out: outputs)
242 {
243 counts[
out.second.size()]++;
244 total++;
245 }
246 if (total > 0)
247 {
248 for (const auto &c: counts)
249 {
250 float percent = 100.f * c.second / total;
251 MINFO(std::to_string(c.second) <<
" outputs used " << c.first <<
" times (" << percent <<
"%)");
252 }
253 }
254 else
255 {
256 MINFO(
"No outputs to process");
257 }
258
260 return 0;
261
263}
The BlockchainDB backing store interface declaration/contract.
virtual void open(const std::string &filename, const int db_flags=0)=0
open a db, or create it if necessary.
std::vector< txin_v > vin
std::vector< tx_out > vout
Transaction pool, handles transactions which are not part of a block.
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)
#define CATCH_ENTRY(location, return_val)
std::string mlog_get_default_log_path(const char *default_filename)
void mlog_set_log(const char *log)
#define CHECK_AND_ASSERT_MES(expr, fail_ret_val, message)
void add_arg(boost::program_options::options_description &description, const arg_descriptor< T, required, dependent, NUM_DEPS > &arg, bool unique=true)
const arg_descriptor< bool > arg_help
bool is_arg_defaulted(const boost::program_options::variables_map &vm, const arg_descriptor< T, required, dependent, NUM_DEPS > &arg)
bool handle_error_helper(const boost::program_options::options_description &desc, F parser)
T get_arg(const boost::program_options::variables_map &vm, const arg_descriptor< T, false, true > &arg)
std::vector< uint64_t > relative_output_offsets_to_absolute(const std::vector< uint64_t > &off)
const command_line::arg_descriptor< bool, false > arg_testnet_on
BlockchainDB * new_db(const std::string &db_type)
bool blockchain_valid_db_type(const std::string &db_type)
const command_line::arg_descriptor< bool, false > arg_stagenet_on
std::string blockchain_db_types(const std::string &sep)
const command_line::arg_descriptor< std::string > arg_log_level
unsigned __int64 uint64_t
const char *const ELECTRONEUM_RELEASE_NAME
const char *const ELECTRONEUM_VERSION_FULL