Skip to content

Track peers' available blocks - #4407

Merged
gavinandresen merged 1 commit into
bitcoin:masterfrom
sipa:headersfirst7
Jun 30, 2014
Merged

gavinandresen merged 1 commit into
bitcoin:masterfrom
sipa:headersfirst7

Conversation

@sipa

@sipa sipa commented Jun 24, 2014

Copy link
Copy Markdown
Member

A small piece of logic that will be needed in headersfirst: knowing up to which point each peer is synchronized. As we no longer react on specific messages to trigger fetching blocks, but instead actively & asynchronously fetch what we're missing, we must know what we can ask from whom.

This is not very useful now, except that it adds 'syncheight' to getpeerinfo (which is much more meaningful than startingheight, imho).

@laanwj

laanwj commented Jun 25, 2014

Copy link
Copy Markdown
Member

'syncheight' looks like very useful information, will merge this into my testing nodes.

@jgarzik

jgarzik commented Jun 26, 2014

Copy link
Copy Markdown
Contributor

Looks OK to me... but it makes me nervous to add additional places in the code where a "valid hash equalling zero" may accidentally trigger undesired behavior.

There was some discussion on IRC of separating uint256 and opaque_hash types. If such were the case, this code would not compile.

@gavinandresen

Copy link
Copy Markdown
Contributor

ACK after code review and compiling/running/syncing a week's worth of blocks on OSX.

Comment thread src/main.cpp

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

I have problems wrapping my head around this one. Why is the knowledge of block availability of the node set to 0 here at this point in SendMessage?

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

There is no new information in this case, but hashLastUnknownBlock may
after a while refer to a known one, so we want to update hashBestKnownBlock
in that case. It's just done here because SendMessages is called
periodically.

@sipa

sipa commented Jun 29, 2014

Copy link
Copy Markdown
Member Author

Rebased.

@laanwj Any suggestion for a better method name, as the current name seems to confuse you? Maybe "ProcessBlockAvailability" ?

@laanwj

laanwj commented Jun 29, 2014

Copy link
Copy Markdown
Member

@sipa Another option would be to split the function in two, an UpdateBlockAvailablity(node) for the first part and a ProcessBlockAvailability(node, hash) for the second part (or better names). That would remove the need for special-casing uint256(0) as well.

@sipa

sipa commented Jun 29, 2014

Copy link
Copy Markdown
Member Author

@laanwj Good idea, done.

@BitcoinPullTester

Copy link
Copy Markdown

Automatic sanity-testing: PASSED, see http://jenkins.bluematt.me/pull-tester/p4407_aa815647005bc8467f467c35a9e617794446cd64/ for binaries and test log.
This test script verifies pulls every time they are updated. It, however, dies sometimes and fails to test properly. If you are waiting on a test, please check timestamps to verify that the test.log is moving at http://jenkins.bluematt.me/pull-tester/current/
Contact BlueMatt on freenode if something looks broken.

@gavinandresen
gavinandresen merged commit aa81564 into bitcoin:master Jun 30, 2014
@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.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

6 participants