Reduced unnecessary database queries in the block archiver.

This commit is contained in:
CalDescent 2021-10-02 11:52:20 +01:00
parent ca02cd72ae
commit ca7f42c409

View File

@ -42,8 +42,6 @@ public class BlockArchiver implements Runnable {
while (!Controller.isStopping()) { while (!Controller.isStopping()) {
repository.discardChanges(); repository.discardChanges();
final int maximumArchiveHeight = BlockArchiveWriter.getMaxArchiveHeight(repository);
Thread.sleep(Settings.getInstance().getArchiveInterval()); Thread.sleep(Settings.getInstance().getArchiveInterval());
BlockData chainTip = Controller.getInstance().getChainTip(); BlockData chainTip = Controller.getInstance().getChainTip();
@ -65,6 +63,7 @@ public class BlockArchiver implements Runnable {
// Build cache of blocks // Build cache of blocks
try { try {
final int maximumArchiveHeight = BlockArchiveWriter.getMaxArchiveHeight(repository);
BlockArchiveWriter writer = new BlockArchiveWriter(startHeight, maximumArchiveHeight, repository); BlockArchiveWriter writer = new BlockArchiveWriter(startHeight, maximumArchiveHeight, repository);
BlockArchiveWriter.BlockArchiveWriteResult result = writer.write(); BlockArchiveWriter.BlockArchiveWriteResult result = writer.write();
switch (result) { switch (result) {