Browse Source

Fixed issue with bootstrap retries.

bootstrap
CalDescent 3 years ago
parent
commit
35718f6215
  1. 6
      src/main/java/org/qortal/block/BlockChain.java
  2. 20
      src/main/java/org/qortal/repository/Bootstrap.java

6
src/main/java/org/qortal/block/BlockChain.java

@ -609,10 +609,8 @@ public class BlockChain {
boolean shouldBootstrap = Settings.getInstance().getBootstrap();
if (shouldBootstrap) {
// Settings indicate that we should apply a bootstrap rather than rebuilding and syncing from genesis
try (final Repository repository = RepositoryManager.getRepository()) {
Bootstrap bootstrap = new Bootstrap(repository);
bootstrap.startImport();
}
Bootstrap bootstrap = new Bootstrap();
bootstrap.startImport();
return;
}

20
src/main/java/org/qortal/repository/Bootstrap.java

@ -28,7 +28,7 @@ import static java.nio.file.StandardCopyOption.REPLACE_EXISTING;
public class Bootstrap {
private final Repository repository;
private Repository repository;
private static final Logger LOGGER = LogManager.getLogger(Bootstrap.class);
@ -39,6 +39,9 @@ public class Bootstrap {
private static final int MAXIMUM_UNPRUNED_BLOCKS = 100;
public Bootstrap() {
}
public Bootstrap(Repository repository) {
this.repository = repository;
}
@ -56,6 +59,12 @@ public class Bootstrap {
final boolean isTopOnly = Settings.getInstance().isTopOnly();
final boolean archiveEnabled = Settings.getInstance().isArchiveEnabled();
// Make sure we have a repository instance
if (repository == null) {
LOGGER.info("Error: repository instance required to check if we can create a bootstrap.");
return false;
}
// Require that a block archive has been built
if (!isTopOnly && !archiveEnabled) {
LOGGER.info("Unable to create bootstrap because the block archive isn't enabled. " +
@ -201,6 +210,11 @@ public class Bootstrap {
public String create() throws DataException, InterruptedException, IOException {
// Make sure we have a repository instance
if (repository == null) {
throw new DataException("Repository instance required in order to create a boostrap");
}
LOGGER.info("Acquiring blockchain lock...");
ReentrantLock blockchainLock = Controller.getInstance().getBlockchainLock();
blockchainLock.lockInterruptibly();
@ -285,7 +299,9 @@ public class Bootstrap {
public void startImport() throws InterruptedException {
while (!Controller.isStopping()) {
try {
try (final Repository repository = RepositoryManager.getRepository()) {
this.repository = repository;
LOGGER.info("Starting import of bootstrap...");
this.doImport();

Loading…
Cancel
Save