Skip to content

Commit

Permalink
Call rollback lists for full reindexing
Browse files Browse the repository at this point in the history
  • Loading branch information
andyoknen committed Sep 8, 2022
1 parent adce55f commit 8107ae5
Showing 1 changed file with 10 additions and 7 deletions.
17 changes: 10 additions & 7 deletions src/pocketdb/repositories/ChainRepository.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,7 @@ namespace PocketDb

LogPrintf("Rollback to first block..\n");
RollbackHeight(0);
RollbackBlockingList(0);

m_database.CreateStructure();

Expand All @@ -82,6 +83,7 @@ namespace PocketDb
TryTransactionStep(__func__, [&]()
{
RestoreOldLast(height);
RollbackBlockingList(height);
RollbackHeight(height);
});

Expand Down Expand Up @@ -578,13 +580,6 @@ namespace PocketDb

int64_t nTime3 = GetTimeMicros();
LogPrint(BCLog::BENCH, " - RestoreOldLast (Balances): %.2fms\n", 0.001 * (nTime3 - nTime2));

// ----------------------------------------
// Rollback blocking list
RollbackBlockingList(height);

int64_t nTime4 = GetTimeMicros();
LogPrint(BCLog::BENCH, " - RollbackHeight (Rollback blocking list): %.2fms\n", 0.001 * (nTime4 - nTime3));
}

void ChainRepository::RollbackHeight(int height)
Expand Down Expand Up @@ -662,6 +657,8 @@ namespace PocketDb

void ChainRepository::RollbackBlockingList(int height)
{
int64_t nTime0 = GetTimeMicros();

auto delListStmt = SetupSqlStatement(R"sql(
delete from BlockingLists where ROWID in
(
Expand All @@ -682,6 +679,9 @@ namespace PocketDb
)sql");
TryBindStatementInt(delListStmt, 1, height);
TryStepStatement(delListStmt);

int64_t nTime1 = GetTimeMicros();
LogPrint(BCLog::BENCH, " - RollbackList (Delete blocking list): %.2fms\n", 0.001 * (nTime1 - nTime0));

auto insListStmt = SetupSqlStatement(R"sql(
insert into BlockingLists
Expand All @@ -706,6 +706,9 @@ namespace PocketDb
)sql");
TryBindStatementInt(insListStmt, 1, height);
TryStepStatement(insListStmt);

int64_t nTime2 = GetTimeMicros();
LogPrint(BCLog::BENCH, " - RollbackList (Insert blocking list): %.2fms\n", 0.001 * (nTime2 - nTime1));
}


Expand Down

0 comments on commit 8107ae5

Please sign in to comment.