Determine Block Height from Block Hash

Post Reply
coinheavy
Posts: 1
Joined: Tue May 27, 2014 11:06 pm
os: linux

Determine Block Height from Block Hash

Post by coinheavy »

Is it possible to use namecoind to determine the block number from a block hash?
going the other way is easy:

Code: Select all

namecoind getblockhash <index>
but getting the height from the hash appears to be impossible...

Height is not an attribute on each block and no method appears to return it.

The closest two are:

Code: Select all

namecoind getblockcount
which:
"Returns the number of blocks in the longest block chain."
 and
namecoind getblocknumber
which:
"Returns the block number of the latest block in the longest block chain."
So there are two methods which do the same thing and no methods that take a block hash and return that block's height, nor is block height a block attribute.

Is there something I'm missing here?  Other coins do not appear to lack this basic functionality.

ryanc
Posts: 147
Joined: Wed Dec 18, 2013 8:10 pm
os: linux

Re: Determine Block Height from Block Hash

Post by ryanc »

I've written a patch that adds this and a few other properties to Namecoin's getblock RPC call.

https://github.com/namecoin/namecoin/issues/87
https://gist.github.com/ryancdotorg/5e6 ... 46beed367d

ryanc
Posts: 147
Joined: Wed Dec 18, 2013 8:10 pm
os: linux

Re: Determine Block Height from Block Hash

Post by ryanc »

This feature has been merged into the development branch of Namecoin.

See my pull request for details.

Post Reply