-
Notifications
You must be signed in to change notification settings - Fork 171
Bugfix: repair rescan when sync stuck and allow sync to continue #1332
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
…ervice doesn't close down
| 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; | ||
| } |
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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; | ||
| } | ||
| } |
There was a problem hiding this comment.
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.
| // 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); | ||
| // } | ||
| // } |
There was a problem hiding this comment.
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.
Syn-McJ
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good
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?
Checklist: