blockchain_import: Add --drop-hard-fork command

This commit is contained in:
warptangent 2016-02-04 17:15:37 -08:00
parent 412243901d
commit c657e772c4
No known key found for this signature in database
GPG key ID: 0E490BEBFBE4E92D
6 changed files with 32 additions and 0 deletions

View file

@ -2192,6 +2192,11 @@ void BlockchainBDB::check_hard_fork_info()
/* FIXME: Some other time */ /* FIXME: Some other time */
} }
void BlockchainBDB::drop_hard_fork_info()
{
/* TODO */
}
void BlockchainBDB::set_hard_fork_version(uint64_t height, uint8_t version) void BlockchainBDB::set_hard_fork_version(uint64_t height, uint8_t version)
{ {
LOG_PRINT_L3("BlockchainBDB::" << __func__); LOG_PRINT_L3("BlockchainBDB::" << __func__);

View file

@ -376,6 +376,7 @@ private:
virtual void set_hard_fork_version(uint64_t height, uint8_t version); virtual void set_hard_fork_version(uint64_t height, uint8_t version);
virtual uint8_t get_hard_fork_version(uint64_t height) const; virtual uint8_t get_hard_fork_version(uint64_t height) const;
virtual void check_hard_fork_info(); virtual void check_hard_fork_info();
virtual void drop_hard_fork_info();
/** /**
* @brief convert a tx output to a blob for storage * @brief convert a tx output to a blob for storage

View file

@ -503,6 +503,7 @@ public:
virtual void set_hard_fork_version(uint64_t height, uint8_t version) = 0; virtual void set_hard_fork_version(uint64_t height, uint8_t version) = 0;
virtual uint8_t get_hard_fork_version(uint64_t height) const = 0; virtual uint8_t get_hard_fork_version(uint64_t height) const = 0;
virtual void check_hard_fork_info() = 0; virtual void check_hard_fork_info() = 0;
virtual void drop_hard_fork_info() = 0;
virtual bool is_read_only() const = 0; virtual bool is_read_only() const = 0;

View file

@ -2457,6 +2457,19 @@ void BlockchainLMDB::check_hard_fork_info()
TXN_POSTFIX_SUCCESS(); TXN_POSTFIX_SUCCESS();
} }
void BlockchainLMDB::drop_hard_fork_info()
{
LOG_PRINT_L3("BlockchainLMDB::" << __func__);
check_open();
TXN_PREFIX(0);
mdb_drop(*txn_ptr, m_hf_starting_heights, 1);
mdb_drop(*txn_ptr, m_hf_versions, 1);
TXN_POSTFIX_SUCCESS();
}
void BlockchainLMDB::set_hard_fork_starting_height(uint8_t version, uint64_t height) void BlockchainLMDB::set_hard_fork_starting_height(uint8_t version, uint64_t height)
{ {
LOG_PRINT_L3("BlockchainLMDB::" << __func__); LOG_PRINT_L3("BlockchainLMDB::" << __func__);

View file

@ -236,6 +236,7 @@ private:
virtual void set_hard_fork_version(uint64_t height, uint8_t version); virtual void set_hard_fork_version(uint64_t height, uint8_t version);
virtual uint8_t get_hard_fork_version(uint64_t height) const; virtual uint8_t get_hard_fork_version(uint64_t height) const;
virtual void check_hard_fork_info(); virtual void check_hard_fork_info();
virtual void drop_hard_fork_info();
/** /**
* @brief convert a tx output to a blob for storage * @brief convert a tx output to a blob for storage

View file

@ -557,6 +557,7 @@ int main(int argc, char* argv[])
const command_line::arg_descriptor<uint64_t> arg_block_stop = {"block-stop", "Stop at block number", block_stop}; const command_line::arg_descriptor<uint64_t> arg_block_stop = {"block-stop", "Stop at block number", block_stop};
const command_line::arg_descriptor<uint64_t> arg_batch_size = {"batch-size", "", db_batch_size}; const command_line::arg_descriptor<uint64_t> arg_batch_size = {"batch-size", "", db_batch_size};
const command_line::arg_descriptor<uint64_t> arg_pop_blocks = {"pop-blocks", "Remove blocks from end of blockchain", num_blocks}; const command_line::arg_descriptor<uint64_t> arg_pop_blocks = {"pop-blocks", "Remove blocks from end of blockchain", num_blocks};
const command_line::arg_descriptor<bool> arg_drop_hf = {"drop-hard-fork", "Drop hard fork subdbs", false};
const command_line::arg_descriptor<bool> arg_testnet_on = { const command_line::arg_descriptor<bool> arg_testnet_on = {
"testnet" "testnet"
, "Run on testnet." , "Run on testnet."
@ -589,6 +590,7 @@ int main(int argc, char* argv[])
command_line::add_arg(desc_cmd_only, arg_count_blocks); command_line::add_arg(desc_cmd_only, arg_count_blocks);
command_line::add_arg(desc_cmd_only, arg_pop_blocks); command_line::add_arg(desc_cmd_only, arg_pop_blocks);
command_line::add_arg(desc_cmd_only, arg_drop_hf);
command_line::add_arg(desc_cmd_only, command_line::arg_help); command_line::add_arg(desc_cmd_only, command_line::arg_help);
// call add_options() directly for these arguments since // call add_options() directly for these arguments since
@ -761,6 +763,15 @@ int main(int argc, char* argv[])
return 0; return 0;
} }
#if !defined(BLOCKCHAIN_DB) || (BLOCKCHAIN_DB == DB_LMDB)
if (! vm["drop-hard-fork"].defaulted())
{
LOG_PRINT_L0("Dropping hard fork tables...");
simple_core.m_storage.get_db().drop_hard_fork_info();
return 0;
}
#endif
import_from_file(simple_core, import_file_path, block_stop); import_from_file(simple_core, import_file_path, block_stop);
#endif #endif