Bitcoin Forum

Bitcoin => Development & Technical Discussion => Topic started by: jackjack on April 20, 2013, 09:55:35 AM



Title: Getting block headers
Post by: jackjack on April 20, 2013, 09:55:35 AM
Hi
I ran into something strange when I'm downloading block hashes from bitcoin nodes (let's call my script 'BD')
When I'm connecting to 63.247.147.163 (all fallback nodes on the wiki* behave the same way), the following happens:
  • BD sends version
  • BD receives version and verack
  • BD sends verack
  • BD regularly receives tx inv's (about 1 per second)
Moreover, sending getblocks doesn't change anything and I still receive only tx inv's

On the other hand, when I connect to my local bitcoin node (127.0.0.1 ofc), that becomes:
  • BD sends version
  • BD receives version and verack
  • BD sends verack
  • BD receives tons of block hash inv's (yeah, TONS OF THEM)
I didn't even try to send a getblocks...


So, why does my local node behaves differently than the other ones?



(*) all the nodes I tested on http://blockchain.info/connected-nodes too



Edit: 98.26.149.98:8333 sends me some block headers after a getblocks


Title: Re: Getting block headers
Post by: Zeilap on April 20, 2013, 10:52:49 AM
Is your local node syncing at the time?

There is a new field in the version message you send which tells the other peer not to send you inv's like this.

To receive block headers, you need to ask with a 'getheaders' message, it doesn't follow the 'getblocks' -> receive 'inv' -> 'getdata' -> receive block  message sequence.


Title: Re: Getting block headers
Post by: jackjack on April 20, 2013, 10:57:24 AM
Absolutely
Does this change anything? I didn't saw anything about it
I didn't finish reading https://en.bitcoin.it/wiki/Satoshi_Client_Block_Exchange though


Edit:
I just checked what the two responding nodes (localhost and 98.26...) and it looks like they are sending me their last blocks
localhost is sending me hashes of blocks number ~134k


Title: Re: Getting block headers
Post by: Zeilap on April 20, 2013, 11:27:43 AM
The client will relay invs to its other peers for every new block it receives. If it's syncing, then it receives a lot of new blocks and so you get a lot of invs.


Title: Re: Getting block headers
Post by: jackjack on April 20, 2013, 11:34:53 AM
Thanks!


I didn't see your edit
There is a new field in the version message you send which tells the other peer not to send you inv's like this.
Thanks a lot, that'll clean my display

To receive block headers, you need to ask with a 'getheaders' message, it doesn't follow the 'getblocks' -> receive 'inv' -> 'getdata' -> receive block  message sequence.
Yeah, I was mixing getheaders and getblocks