Bitcoin Forum

Bitcoin => Development & Technical Discussion => Topic started by: Mivexil on January 13, 2014, 04:12:34 AM



Title: Obtain current blockchain height without downloading it?
Post by: Mivexil on January 13, 2014, 04:12:34 AM
As stated - can you run bitcoind (and, more importantly, other coins' daemons - so Blockchain API is out of the question) and query the peers for blockchain height and difficulty without actually downloading the whole blockchain? Or would you need to create a custom daemon for that?


Title: Re: Obtain current blockchain height without downloading it?
Post by: spin on January 13, 2014, 07:28:04 AM
I think the node knows all of it's peers blockheights so when you start a node and it starts connecting to peers it will know the block height of all it's peers and you'd be able to query that with getpeerinfo.  It would however be busy updating itself.  You won't have to wait until it's done though.


Title: Re: Obtain current blockchain height without downloading it?
Post by: Mivexil on January 13, 2014, 12:31:30 PM
I think the node knows all of it's peers blockheights so when you start a node and it starts connecting to peers it will know the block height of all it's peers and you'd be able to query that with getpeerinfo.  It would however be busy updating itself.  You won't have to wait until it's done though.

Well, the point is that I don't want to store the whole hundreds-of-megabytes blockchain. So I'd need to periodically delete the file?

And since getpeerinfo gives me the starting height (which, I assume, is the height at the time of connection), I'd need to de- and reconnect the wallet periodically too? Not a very good idea for my application :(


Title: Re: Obtain current blockchain height without downloading it?
Post by: spin on January 14, 2014, 08:32:48 AM
I guess you have couple of options:
- Adjust the code to find out only blockheights of other nodes.
- Run a full node elsewhere and make the blockheight available via rpc or otherwise to the app you are writing.
- Look at bitcoinj which may do what you want to do as it does a limited abmount of syncing.  It implements "simplified payment verification" (SPV).  In your case it would be even more simple as it would never need to match any actual transactions.