Bitcoin Forum
April 25, 2024, 07:38:17 AM *
News: Latest Bitcoin Core release: 27.0 [Torrent]
 
   Home   Help Search Login Register More  
Pages: [1]
  Print  
Author Topic: getblocks vs getheaders  (Read 114 times)
barrysty1e (OP)
Hero Member
*****
Offline Offline

Activity: 636
Merit: 516



View Profile WWW
March 25, 2020, 01:25:00 PM
Merited by ABCbits (3)
 #1

Hi everyone,

I'm currently mid way through converting Bitcoin 0.19 based client so that it can properly synchronize from a pre-0.10 clients chain.
Those who are in the know should automatically know exactly which currency i'm talking about.

So far i'm having good luck but seem to run into an unusual and undocumented problem.
Every 500 blocks received via INV request, seem to come with an extra block at the end that reflects the current chains tip.
Everywhere i've read suggests that *only* 500 blocks are sent, but I always seem to get this extra block tacked onto the end.

Quote
2020-03-24T15:44:05Z ComputeNextStakeModifier: prev modifier=0x000000105dbc2bd6 time=1545703144
2020-03-24T15:44:05Z ComputeNextStakeModifier: no new interval keep current modifier: pindexPrev nHeight=499 nTime=1545703144
2020-03-24T15:44:05Z UpdateTip: new best=0000000105a7e280f68b5d030282998640d6da2fa0eb107e9dd65a3e7ccad9d8 height=500 version=0x00000003 log2_work=8.9686668 tx=521 date='2018-12-25T02:01:18Z' progress=1.000000 cache=0.1MiB(676txo)
2020-03-24T15:44:06Z ERROR: ProcessNewBlock: AcceptBlock FAILED ( (code 0))
2020-03-24T15:44:08Z ComputeNextStakeModifier: prev modifier=0x000000105dbc2bd6 time=1545703144

It doesnt actually affect sync at all, but it bugs the s**t out of me.

Yes neckbeards, this isnt technically 'bitcoin only' discussion; but I think its a heartwarming change from 'howTO cloening of the cOIN'.. and technical discussion, which this forum has sorely lacked over the past few years.

james

my father wears sneakers in the pool
1714030697
Hero Member
*
Offline Offline

Posts: 1714030697

View Profile Personal Message (Offline)

Ignore
1714030697
Reply with quote  #2

1714030697
Report to moderator
Advertised sites are not endorsed by the Bitcoin Forum. They may be unsafe, untrustworthy, or illegal in your jurisdiction.
1714030697
Hero Member
*
Offline Offline

Posts: 1714030697

View Profile Personal Message (Offline)

Ignore
1714030697
Reply with quote  #2

1714030697
Report to moderator
achow101
Moderator
Legendary
*
expert
Offline Offline

Activity: 3374
Merit: 6535


Just writing some code


View Profile WWW
March 25, 2020, 04:23:10 PM
Merited by ABCbits (1)
 #2

It's there to prompt nodes to request the next 500 blocks. It's to ensure that they know there are more blocks to download. Relevant lines in Bitcoin Core: https://github.com/bitcoin/bitcoin/blob/v0.9.5/src/main.cpp#L3698 and https://github.com/bitcoin/bitcoin/blob/v0.9.5/src/main.cpp#L3344

barrysty1e (OP)
Hero Member
*****
Offline Offline

Activity: 636
Merit: 516



View Profile WWW
March 25, 2020, 04:49:58 PM
 #3

It's there to prompt nodes to request the next 500 blocks. It's to ensure that they know there are more blocks to download. Relevant lines in Bitcoin Core: https://github.com/bitcoin/bitcoin/blob/v0.9.5/src/main.cpp#L3698 and https://github.com/bitcoin/bitcoin/blob/v0.9.5/src/main.cpp#L3344

thankyou.
where in the code does it 'set' this as the known tip? ive tried using hashStop/hashContinue but this doesnt seem to work..

my father wears sneakers in the pool
achow101
Moderator
Legendary
*
expert
Offline Offline

Activity: 3374
Merit: 6535


Just writing some code


View Profile WWW
March 26, 2020, 06:12:03 AM
Merited by ABCbits (1), aliashraf (1)
 #4

thankyou.
where in the code does it 'set' this as the known tip? ive tried using hashStop/hashContinue but this doesnt seem to work..
It doesn't. The node makes no assumptions about the validity of that block. All it knows is that it is missing the chain leading up to that block and needs to fetch that chain in order to verify that block. For efficiency, the block's hash is cached in mapOrphanBlocks so that it doesn't have to download the same block over and over. Instead it knows that if it sees a block hash in that map, it knows it checked some things (e.g. PoW) but still needs the chain leading up to it to verify it. So it requests more blocks in that chain.

Pages: [1]
  Print  
 
Jump to:  

Powered by MySQL Powered by PHP Powered by SMF 1.1.19 | SMF © 2006-2009, Simple Machines Valid XHTML 1.0! Valid CSS!