Skip to content
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

use CBlockIndex* insted of uint256 for UpdatedBlockTip signal #6680

Merged
merged 1 commit into from
Sep 30, 2015

Conversation

jonasschnelli
Copy link
Contributor

  • removes mapBlockIndex find operation
  • theoretically allows removing the cs_main lock during zqm notification while introducing a new file position lock

- removes mapBlockIndex find operation
- theoretically allows removing the cs_main lock during zqm notification while introducing a new file position lock
@dcousens
Copy link
Contributor

utACK

@promag
Copy link
Contributor

promag commented Sep 19, 2015

I choose uint256 because I don't know the ownership, thread safety and lifetime of CBlockIndex* objects.

Otherwise LGTM.

@sipa
Copy link
Member

sipa commented Sep 19, 2015

They have infinite lifetime. Some fields are mutable (especially validation state and disk offsets), but even CBlockIndex::GetAncestor can be used without locking.

@dcousens
Copy link
Contributor

@sipa didn't that invariant change with pruning?

@sipa
Copy link
Member

sipa commented Sep 20, 2015 via email

@dcousens
Copy link
Contributor

@sipa ah, so that was what could change in #6688?

@laanwj
Copy link
Member

laanwj commented Sep 21, 2015

This makes sense. If there comes a time that CBlockIndex* are no longer infinitely kept in memory, we need to replace them with another handle type throughout the code, and this change will not be a specific blocker.

utACK.

@sipa
Copy link
Member

sipa commented Sep 22, 2015

I think ReadBlockFromDisk should grab cs_main by itself, only when read the disk position information, and release before actual reading. That way, the publisher doesn't need access to cs_main anymore.

@dcousens
Copy link
Contributor

Agreed with @sipa, do the existing locks allow for recursive locking? Or would we have to re-write a lot of that code?

@sipa
Copy link
Member

sipa commented Sep 22, 2015 via email

@jgarzik
Copy link
Contributor

jgarzik commented Sep 22, 2015

+1 on not holding across disk I/O

@jonasschnelli
Copy link
Contributor Author

@sipa: do you prefer adding the cs_main lock to ReadBlockFromDisk() within this PR?
I personally would recommend to keep this PR as it is and address the ReadBlockFromDisk() cs_main lock in another PR because it might need some adaptation here and there.

@laanwj laanwj merged commit d76a8ac into bitcoin:master Sep 30, 2015
laanwj added a commit that referenced this pull request Sep 30, 2015
d76a8ac use CBlockIndex* insted of uint256 for UpdatedBlockTip signal (Jonas Schnelli)
zkbot added a commit to zcash/zcash that referenced this pull request Feb 9, 2017
zkbot added a commit to zcash/zcash that referenced this pull request Feb 9, 2017
@bitcoin bitcoin locked as resolved and limited conversation to collaborators Sep 8, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants