forked from Qortal/qortal
Fixed issue with bootstrap retries.
This commit is contained in:
parent
a6d3891a95
commit
35718f6215
@ -609,10 +609,8 @@ public class BlockChain {
|
|||||||
boolean shouldBootstrap = Settings.getInstance().getBootstrap();
|
boolean shouldBootstrap = Settings.getInstance().getBootstrap();
|
||||||
if (shouldBootstrap) {
|
if (shouldBootstrap) {
|
||||||
// Settings indicate that we should apply a bootstrap rather than rebuilding and syncing from genesis
|
// 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();
|
||||||
Bootstrap bootstrap = new Bootstrap(repository);
|
bootstrap.startImport();
|
||||||
bootstrap.startImport();
|
|
||||||
}
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -28,7 +28,7 @@ import static java.nio.file.StandardCopyOption.REPLACE_EXISTING;
|
|||||||
|
|
||||||
public class Bootstrap {
|
public class Bootstrap {
|
||||||
|
|
||||||
private final Repository repository;
|
private Repository repository;
|
||||||
|
|
||||||
private static final Logger LOGGER = LogManager.getLogger(Bootstrap.class);
|
private static final Logger LOGGER = LogManager.getLogger(Bootstrap.class);
|
||||||
|
|
||||||
@ -39,6 +39,9 @@ public class Bootstrap {
|
|||||||
private static final int MAXIMUM_UNPRUNED_BLOCKS = 100;
|
private static final int MAXIMUM_UNPRUNED_BLOCKS = 100;
|
||||||
|
|
||||||
|
|
||||||
|
public Bootstrap() {
|
||||||
|
}
|
||||||
|
|
||||||
public Bootstrap(Repository repository) {
|
public Bootstrap(Repository repository) {
|
||||||
this.repository = repository;
|
this.repository = repository;
|
||||||
}
|
}
|
||||||
@ -56,6 +59,12 @@ public class Bootstrap {
|
|||||||
final boolean isTopOnly = Settings.getInstance().isTopOnly();
|
final boolean isTopOnly = Settings.getInstance().isTopOnly();
|
||||||
final boolean archiveEnabled = Settings.getInstance().isArchiveEnabled();
|
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
|
// Require that a block archive has been built
|
||||||
if (!isTopOnly && !archiveEnabled) {
|
if (!isTopOnly && !archiveEnabled) {
|
||||||
LOGGER.info("Unable to create bootstrap because the block archive isn't enabled. " +
|
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 {
|
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...");
|
LOGGER.info("Acquiring blockchain lock...");
|
||||||
ReentrantLock blockchainLock = Controller.getInstance().getBlockchainLock();
|
ReentrantLock blockchainLock = Controller.getInstance().getBlockchainLock();
|
||||||
blockchainLock.lockInterruptibly();
|
blockchainLock.lockInterruptibly();
|
||||||
@ -285,7 +299,9 @@ public class Bootstrap {
|
|||||||
|
|
||||||
public void startImport() throws InterruptedException {
|
public void startImport() throws InterruptedException {
|
||||||
while (!Controller.isStopping()) {
|
while (!Controller.isStopping()) {
|
||||||
try {
|
try (final Repository repository = RepositoryManager.getRepository()) {
|
||||||
|
this.repository = repository;
|
||||||
|
|
||||||
LOGGER.info("Starting import of bootstrap...");
|
LOGGER.info("Starting import of bootstrap...");
|
||||||
|
|
||||||
this.doImport();
|
this.doImport();
|
||||||
|
Loading…
Reference in New Issue
Block a user