-
-
Notifications
You must be signed in to change notification settings - Fork 648
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
Purge Blocks to a specific height #213
Comments
I do not exactly understand what you need. |
That sounds helpful and I will check the reorg implementation supported. |
There is a configuration parameter blockbook/configs/coins/bitcoin.json Line 57 in 104f6f9
which specifies the maximum depth of reorg that Blockbook supports, by default 300 blocks. If reorg is deeper, Blockbook will report an error and the whole DB will have to be reindexed. If you think that there is a chance of deeper reorgs, change it to some higher number for your coin. |
Hi! @martinboehm, How exactly does the block reorg / purging some unwanted blocks during the sync work? I tried sending an older block than requested through F0626 05:24:47.817345 21867 sync.go:271] writeBlockWorker skipped block, expected block 80741, new block 80740 My implementation using the reorg concept isn't that great but I wonder if there is a way to drop some blocks and probably reset the height from where the sync should proceed from? |
You have to return a newest block hash using Lines 87 to 110 in b1810dc
and the content of the handleFork method.
|
This reorg implementation seems to work only before the first sync runs, Is there a way to do it while the first sync is in progress? |
This is the case scenario that I am trying to fix. The proof of stake implementation which could benefit from the reorg during sync works like this: When a block is mined on decred block chain as the best block, it doesn't have the confirming votes cast to validate it. The next consecutive block mined either validates or invalidates that block whereby the txs in the invalidated block are mined in other following blocks. I was hopeful that a reorg implementation during sync would help me address that unique concern on decred's part since I don't have access to the db so as to drop/delete txs in the invalidated block. |
Also does one have to restart the code for reorg to work? |
On the contrary, during the inital sync we do not expect any reorg as the initial sync is starting with old blocks with many confirmations. Only in the end, close to the chain top there can be a reorg.
I do not really see any difference to let's say Bitcoin but I probably do not understand the decred implementation enough.
No, you do not have to restart. |
ok. Noted. Is there a way that I could remove the transaction details of a synced invalidated block that falls within set the max reorg depth during the first sync? |
I wish there was a function similar to this code, accessible to the coins package which could help me delete the unwanted transactions in the invalidated block during the first sync. I am experiencing some bugs due to the hacks I have resorted to in order to avoid transactions in invalidated blocks from being saved in the rocksdb. Lines 1282 to 1340 in b1810dc
|
In decred we have a reorganization (or reorg) of the blockchain where a set of blocks are replaced with another set which has more work. The number of blocks replaced is the depth of the reorg. The old set of blocks goes to side chains not available on re-sync.
Can we have an implementation accessible to the
bchain.coin
package that allows a number of blocks to be dropped?The text was updated successfully, but these errors were encountered: