recompute state bug fixed
This commit is contained in:
+1
-1
@@ -97,7 +97,7 @@ static bool DebitAddress(const uint8_t address[32], const uint256_t* amount) {
|
||||
return BalanceSheet_Insert(entry) >= 0;
|
||||
}
|
||||
|
||||
static bool Chain_RecomputeRuntimeState(blockchain_t* chain) {
|
||||
bool Chain_RecomputeRuntimeState(blockchain_t* chain) {
|
||||
if (!chain) {
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -698,6 +698,11 @@ int main(int argc, char* argv[]) {
|
||||
uint8_t lastSavedHash[32] = {0};
|
||||
if (!Chain_LoadFromFile(chain, chainDataDir, ¤tSupply, &difficultyTarget, ¤tReward, lastSavedHash, false)) {
|
||||
printf("No existing chain loaded from %s\n", chainDataDir);
|
||||
} else {
|
||||
// Recompute runtime supply/reward from loaded blocks to avoid trusting stale meta values.
|
||||
if (!Chain_RecomputeRuntimeState(chain)) {
|
||||
fprintf(stderr, "Failed to recompute runtime state from loaded chain\n");
|
||||
}
|
||||
}
|
||||
|
||||
if (!BalanceSheet_LoadFromFile(chainDataDir)) {
|
||||
|
||||
Reference in New Issue
Block a user