Skip to content

refactor: Pass block reference instead of pointer to PeerManagerImpl::BlockRequested - #22221

Merged
fanquake merged 1 commit into
bitcoin:masterfrom
maflcko:2106-netBlock
Jun 12, 2021
Merged

fanquake merged 1 commit into
bitcoin:masterfrom
maflcko:2106-netBlock

Conversation

@maflcko

@maflcko maflcko commented Jun 11, 2021

Copy link
Copy Markdown
Member

This allows to remove an assert and at the same time make it more obvious that the block is never nullptr.

Also, add missing {} while touching the function.

@maflcko

maflcko commented Jun 11, 2021

Copy link
Copy Markdown
Member Author

From #22141 (comment)

@jnewbery

Copy link
Copy Markdown
Contributor

Code review ACK fa334b4

@mjdietzx

Copy link
Copy Markdown
Contributor

crACK fa334b4

@practicalswift

Copy link
Copy Markdown
Contributor

Concept ACK

Candidates for similar treatment can be found using the git grep commands in #19062 :)

@theStack theStack left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Code review ACK fa334b4

@fanquake
fanquake merged commit 96f828b into bitcoin:master Jun 12, 2021
@maflcko
maflcko deleted the 2106-netBlock branch June 13, 2021 07:22
@Sjors Sjors mentioned this pull request Jun 13, 2021
@Sjors

Sjors commented Jun 13, 2021

Copy link
Copy Markdown
Member

This change may not be entirely without consequence (though I'm not sure if it really matters): #20295 (comment)

@maflcko

maflcko commented Jun 13, 2021

Copy link
Copy Markdown
Member Author

There was an assert(pindex);, so passing nullptr wasn't possible before this commit either.

@Sjors

Sjors commented Jun 13, 2021 •

Copy link
Copy Markdown
Member

That assert was introduced in 85e058b as part of #22141.

@jnewbery

Copy link
Copy Markdown
Contributor

BlockRequested no longer takes a pointer. Which means we can't call it for blocks for which we don't have a header.

(from #20295 (comment))

I think this is fine. Since headers-first syncing, we'll never attempt to download a block if we don't already have its header.

Adding the assert in #22141 didn't add any new assumptions. All callers of BlockRequested were already dereferencing the CBlockIndex* that was bring passed in.

gwillen pushed a commit to ElementsProject/elements that referenced this pull request Jun 1, 2022
@bitcoin bitcoin locked as resolved and limited conversation to collaborators Aug 16, 2022
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.

8 participants