|
|
@ -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(); |
|
|
|