46{
48
50
51 std::string default_db_type = "lmdb";
52
54 available_dbs = "available: " + available_dbs;
55
58 bool blocks_dat = false;
59
61
62 boost::filesystem::path output_file_path;
63
64 po::options_description desc_cmd_only("Command line options");
65 po::options_description desc_cmd_sett("Command line options and settings options");
70 "database", available_dbs.c_str(), default_db_type
71 };
73
74
83
85
86 po::options_description desc_options("Allowed options");
87 desc_options.add(desc_cmd_only).add(desc_cmd_sett);
88
89 po::variables_map vm;
91 {
92 po::store(po::parse_command_line(argc, argv, desc_options), vm);
93 po::notify(vm);
94 return true;
95 });
96 if (! r)
97 return 1;
98
100 {
102 std::cout << desc_options << std::endl;
103 return 1;
104 }
105
109 else
110 mlog_set_log(std::string(std::to_string(log_level) +
",bcutil:INFO").c_str());
112
114
117 if (opt_testnet && opt_stagenet)
118 {
119 std::cerr << "Can't specify more than one of --testnet and --stagenet" << std::endl;
120 return 1;
121 }
123
124 std::string m_config_folder;
125
127
130 {
131 std::cerr << "Invalid database type: " << db_type << std::endl;
132 return 1;
133 }
134
137 else
138 output_file_path = boost::filesystem::path(m_config_folder) /
"export" /
BLOCKCHAIN_RAW;
139 LOG_PRINT_L0(
"Export output file: " << output_file_path.string());
140
141
142
143
144
145
146
147
148
149
150
151
152 LOG_PRINT_L0(
"Initializing source blockchain (BlockchainDB)");
156
158 if (db == NULL)
159 {
160 LOG_ERROR(
"Attempted to use non-existent database type: " << db_type);
161 throw std::runtime_error("Attempting to use non-existent database type");
162 }
164
165 boost::filesystem::path folder(m_config_folder);
167 const std::string filename = folder.string();
168
169 LOG_PRINT_L0(
"Loading blockchain from folder " << filename <<
" ...");
170 try
171 {
173 }
174 catch (const std::exception& e)
175 {
177 return 1;
178 }
180
182 {
184 return 1;
185 }
186
188 LOG_PRINT_L0(
"Source blockchain storage initialized OK");
190
191 if (opt_blocks_dat)
192 {
195 }
196 else
197 {
199 r =
bootstrap.store_blockchain_raw(core_storage, NULL, output_file_path, block_stop);
200 }
203 return 0;
204
206}
bool store_blockchain_raw(cryptonote::Blockchain *cs, cryptonote::tx_memory_pool *txp, boost::filesystem::path &output_file, uint64_t use_block_height=0)
The BlockchainDB backing store interface declaration/contract.
virtual std::string get_db_name() const =0
gets the name of the folder the BlockchainDB's file(s) should be in
virtual void open(const std::string &filename, const int db_flags=0)=0
open a db, or create it if necessary.
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.
uint32_t get_blockchain_pruning_seed() const
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)
std::enable_if<!std::is_same< T, bool >::value, bool >::type has_arg(const boost::program_options::variables_map &vm, const arg_descriptor< T, required, dependent, NUM_DEPS > &arg)
T get_arg(const boost::program_options::variables_map &vm, const arg_descriptor< T, false, true > &arg)
const command_line::arg_descriptor< std::string, false, true, 2 > arg_data_dir
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