Skip to content

Conversation

@HashEngineering
Copy link
Collaborator

@HashEngineering HashEngineering commented Dec 11, 2024

Issue being fixed or feature implemented

Related PR's and Dependencies

dashpay/dashj#266
dashpay/kotlin-platform#19

Screenshots / Videos

How Has This Been Tested?

  • QA (Mobile Team)

Checklist:

  • I have performed a self-review of my own code and added comments where necessary
  • I have added or updated relevant unit/integration/functional/e2e tests

@HashEngineering HashEngineering self-assigned this Dec 11, 2024
Comment on lines +1503 to +1512
private boolean verifyBlockStore(BlockStore store) throws BlockStoreException {
StoredBlock cursor = store.getChainHead();
for (int i = 0; i < 10; ++i) {
cursor = cursor.getPrev(store);
if (cursor == null || cursor.getHeader().equals(Constants.NETWORK_PARAMETERS.getGenesisBlock())) {
break;
}
}
return true;
}
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This was added to check to see if it was possible to access the blockStore. The theory was that the blockStore file was corrupted and this resulted in a freeze when accessing the file.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

So far this test passed, even with a device with sync problems.

log.warn("verification of blockstore failed:", e);
return false;
}
}
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This will verify that the blockStore's can be accessed and give a time limit. When the blockchain was accessed during sync, the thread froze. So this was added to check for the freeze earlier.

Turns out, though, that with one user that this check seemed to "warm up" the blockStore and the sync thread didn't freeze later.

Comment on lines +1524 to +1530
// TODO: should we have a backup blockchain file?
// public static void copyFile(File source, File destination) throws IOException {
// try (FileChannel sourceChannel = new FileInputStream(source).getChannel();
// FileChannel destChannel = new FileOutputStream(destination).getChannel()) {
// sourceChannel.transferTo(0, sourceChannel.size(), destChannel);
// }
// }
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

When we thought that the blockchain file was corrupt, I thought to back it up and have a means of restoring it.

I will leave this for now and think a bit more about it. The backup file may not be necessary.

@HashEngineering HashEngineering marked this pull request as ready for review December 12, 2024 20:03
Copy link
Member

@Syn-McJ Syn-McJ left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good

@HashEngineering HashEngineering merged commit 7a2af44 into master Dec 13, 2024
0 of 2 checks passed
@HashEngineering HashEngineering deleted the bugfix-rescan-when-sync-stuck branch February 6, 2025 17:41
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants