mirror of
https://github.com/monero-project/monero.git
synced 2025-08-12 01:20:11 -04:00
remove hf_starting_height db
It's not really needed, it used to be an optimization for when that code was not using the db and needed to recalculate things fast on startup.
This commit is contained in:
parent
18dd507024
commit
d7b681cd65
9 changed files with 9 additions and 186 deletions
|
@ -137,10 +137,6 @@ bool HardFork::add(uint8_t block_version, uint8_t voting_version, uint64_t heigh
|
|||
|
||||
uint8_t voted = get_voted_fork_index(height + 1);
|
||||
if (voted > current_fork_index) {
|
||||
for (int v = heights[current_fork_index].version + 1; v <= heights[voted].version; ++v) {
|
||||
// we reached the vote threshold with this block, next one will be forked
|
||||
db.set_hard_fork_starting_height(v, height + 1);
|
||||
}
|
||||
current_fork_index = voted;
|
||||
}
|
||||
|
||||
|
@ -172,7 +168,12 @@ void HardFork::init()
|
|||
else
|
||||
height = 1;
|
||||
|
||||
bool populate = db.get_hard_fork_starting_height(original_version) == std::numeric_limits<uint64_t>::max();
|
||||
bool populate = false;
|
||||
try
|
||||
{
|
||||
db.get_hard_fork_version(0);
|
||||
}
|
||||
catch (...) { populate = true; }
|
||||
if (populate) {
|
||||
LOG_PRINT_L0("The DB has no hard fork info, reparsing from start");
|
||||
height = 1;
|
||||
|
@ -182,7 +183,6 @@ void HardFork::init()
|
|||
reorganize_from_chain_height(height);
|
||||
// reorg will not touch the genesis block, use this as a flag for populating done
|
||||
db.set_hard_fork_version(0, original_version);
|
||||
db.set_hard_fork_starting_height(original_version, 0);
|
||||
}
|
||||
else {
|
||||
rescan_from_chain_height(height);
|
||||
|
@ -215,7 +215,6 @@ bool HardFork::reorganize_from_block_height(uint64_t height)
|
|||
const uint64_t rescan_height = height >= (window_size - 1) ? height - (window_size -1) : 0;
|
||||
const uint8_t start_version = height == 0 ? original_version : db.get_hard_fork_version(height);
|
||||
while (current_fork_index > 0 && heights[current_fork_index].version > start_version) {
|
||||
db.set_hard_fork_starting_height(heights[current_fork_index].version, std::numeric_limits<uint64_t>::max());
|
||||
--current_fork_index;
|
||||
}
|
||||
for (uint64_t h = rescan_height; h <= height; ++h) {
|
||||
|
@ -227,10 +226,6 @@ bool HardFork::reorganize_from_block_height(uint64_t height)
|
|||
|
||||
uint8_t voted = get_voted_fork_index(height + 1);
|
||||
if (voted > current_fork_index) {
|
||||
for (int v = heights[current_fork_index].version + 1; v <= heights[voted].version; ++v) {
|
||||
// we reached the vote threshold with this block, next one will be forked
|
||||
db.set_hard_fork_starting_height(v, height + 1);
|
||||
}
|
||||
current_fork_index = voted;
|
||||
}
|
||||
|
||||
|
@ -337,12 +332,6 @@ uint8_t HardFork::get(uint64_t height) const
|
|||
return db.get_hard_fork_version(height);
|
||||
}
|
||||
|
||||
uint64_t HardFork::get_start_height(uint8_t version) const
|
||||
{
|
||||
CRITICAL_REGION_LOCAL(lock);
|
||||
return db.get_hard_fork_starting_height(version);
|
||||
}
|
||||
|
||||
uint8_t HardFork::get_current_version() const
|
||||
{
|
||||
CRITICAL_REGION_LOCAL(lock);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue