3
0
mirror of https://github.com/Qortal/altcoinj.git synced 2025-02-13 18:55:52 +00:00

Watch out for scripts with a creation time of zero (and warn the developer about them via logging).

This commit is contained in:
Mike Hearn 2015-04-21 14:48:46 +02:00
parent eb15ded065
commit 4471709693
3 changed files with 9 additions and 1 deletions

View File

@ -216,6 +216,9 @@ public class CheckpointManager {
time -= 86400 * 7; time -= 86400 * 7;
checkArgument(time > 0);
log.info("Attempting to initialize a new block store with a checkpoint for time {}", time);
BufferedInputStream stream = new BufferedInputStream(checkpoints); BufferedInputStream stream = new BufferedInputStream(checkpoints);
CheckpointManager manager = new CheckpointManager(params, stream); CheckpointManager manager = new CheckpointManager(params, stream);
StoredBlock checkpoint = manager.getCheckpointBefore(time); StoredBlock checkpoint = manager.getCheckpointBefore(time);

View File

@ -823,6 +823,8 @@ public class Wallet extends BaseTaggableObject implements Serializable, BlockCha
try { try {
for (final Script script : scripts) { for (final Script script : scripts) {
if (watchedScripts.contains(script)) continue; if (watchedScripts.contains(script)) continue;
if (script.getCreationTimeSeconds() == 0)
log.warn("Adding a script to the wallet with a creation time of zero, this will disable the checkpointing optimization! {}", script);
watchedScripts.add(script); watchedScripts.add(script);
added++; added++;
} }

View File

@ -295,7 +295,10 @@ public class WalletAppKit extends AbstractIdleService {
} else { } else {
time = vWallet.getEarliestKeyCreationTime(); time = vWallet.getEarliestKeyCreationTime();
} }
CheckpointManager.checkpoint(params, checkpoints, vStore, time); if (time > 0)
CheckpointManager.checkpoint(params, checkpoints, vStore, time);
else
log.warn("Creating a new uncheckpointed block store due to a wallet with a creation time of zero: this will result in a very slow chain sync");
} else if (chainFileExists) { } else if (chainFileExists) {
log.info("Deleting the chain file in preparation from restore."); log.info("Deleting the chain file in preparation from restore.");
vStore.close(); vStore.close();