-
Notifications
You must be signed in to change notification settings - Fork 41
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
Improve reindex_chain readability and small fixes #125
Conversation
Hi @JoseSK999 thanks for the PR. Sorry for the delay, I was traveling this last week, but I should take a loot at this tomorrow. |
You're right, this is completely broken. Nice catch! Btw, the CI error is totally unrelated. |
Thanks! Should that part be removed or we need to check whether the block extends an orphan chain? |
I think it's important to check if this block is indeed the next in our chain. I think the right way to do that is to use the |
Thanks, I will try to do it this weekend (traveling rn as well) |
@Davidson-Souza I think we are already checking if the block is the next in the chain in Actually there's a small issue in |
Yes, you're right. We'll never call validate_block in a block that's not the next one. I'm ok with just removing this check in validate_block at all. |
Done! |
A few suggested changes:
reindex_chain
maybe_reorg
is saving the branch tip with its parent height, so I add 1accept_header
should perhaps return if there's a database errorverify_block_transactions
should just returnOk(())
, instead ofOk(true)
, since any other outcome is returned asErr
I also found an issue in
validate_block
:We check if
block.header.prev_blockhash != prev_block.block_hash()
. Butprev_block
is fetched withheader.prev_blockhash
, so this check always passes! I don't know what is the desired behavior here.