Merge pull request #569

ee9d71e BlockchainDB: skip fixup check if read-only database (warptangent)
This commit is contained in:
Riccardo Spagni 2015-12-30 09:36:54 +02:00
commit 9b3300fe9b
No known key found for this signature in database
GPG key ID: 55432DF31CCD4FCD
6 changed files with 32 additions and 0 deletions

View file

@ -2200,8 +2200,14 @@ void BlockchainBDB::checkpoint_worker() const
LOG_PRINT_L0("Leaving BDB checkpoint thread."); LOG_PRINT_L0("Leaving BDB checkpoint thread.");
} }
bool BlockchainBDB::is_read_only() const
{
return false;
}
void BlockchainBDB::fixup() void BlockchainBDB::fixup()
{ {
LOG_PRINT_L3("BlockchainBDB::" << __func__);
// Always call parent as well // Always call parent as well
BlockchainDB::fixup(); BlockchainDB::fixup();
} }

View file

@ -405,6 +405,9 @@ private:
uint64_t get_output_global_index(const uint64_t& amount, const uint64_t& index); uint64_t get_output_global_index(const uint64_t& amount, const uint64_t& index);
void checkpoint_worker() const; void checkpoint_worker() const;
void check_open() const; void check_open() const;
virtual bool is_read_only() const;
// //
// fix up anything that may be wrong due to past bugs // fix up anything that may be wrong due to past bugs
virtual void fixup(); virtual void fixup();

View file

@ -199,6 +199,11 @@ void BlockchainDB::show_stats()
void BlockchainDB::fixup() void BlockchainDB::fixup()
{ {
if (is_read_only()) {
LOG_PRINT_L1("Database is opened read only - skipping fixup check");
return;
}
// There was a bug that would cause key images for transactions without // There was a bug that would cause key images for transactions without
// any outputs to not be added to the spent key image set. There are two // any outputs to not be added to the spent key image set. There are two
// instances of such transactions, in blocks 202612 and 685498. // instances of such transactions, in blocks 202612 and 685498.

View file

@ -503,6 +503,8 @@ 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 bool is_read_only() const = 0;
// fix up anything that may be wrong due to past bugs // fix up anything that may be wrong due to past bugs
virtual void fixup(); virtual void fixup();

View file

@ -2496,8 +2496,22 @@ uint8_t BlockchainLMDB::get_hard_fork_version(uint64_t height) const
return ret; return ret;
} }
bool BlockchainLMDB::is_read_only() const
{
unsigned int flags;
auto result = mdb_env_get_flags(m_env, &flags);
if (result)
throw0(DB_ERROR(std::string("Error getting database environment info: ").append(mdb_strerror(result)).c_str()));
if (flags & MDB_RDONLY)
return true;
return false;
}
void BlockchainLMDB::fixup() void BlockchainLMDB::fixup()
{ {
LOG_PRINT_L3("BlockchainLMDB::" << __func__);
// Always call parent as well // Always call parent as well
BlockchainDB::fixup(); BlockchainDB::fixup();
} }

View file

@ -266,6 +266,8 @@ private:
void check_open() const; void check_open() const;
virtual bool is_read_only() const;
// fix up anything that may be wrong due to past bugs // fix up anything that may be wrong due to past bugs
virtual void fixup(); virtual void fixup();