Bitcoin Forum
December 09, 2016, 02:12:17 AM *
News: Latest stable version of Bitcoin Core: 0.13.1  [Torrent].
 
   Home   Help Search Donate Login Register  
Pages: [1]
  Print  
Author Topic: What is the difference between getblockCOUNT and getblockNUMBER ???  (Read 1581 times)
gigabytecoin
Sr. Member
****
Offline Offline

Activity: 280


View Profile
June 28, 2011, 02:00:10 AM
 #1

When interacting with the bitcoin client, you have the option of passing two (different?) commands to it that seemingly always return the exact same result.

getblockcount === getblocknumber

Or does it?

And why?
Advertised sites are not endorsed by the Bitcoin Forum. They may be unsafe, untrustworthy, or illegal in your jurisdiction. Advertise here.
JoelKatz
Legendary
*
Offline Offline

Activity: 1386


Democracy is vulnerable to a 51% attack.


View Profile WWW
June 28, 2011, 02:15:09 AM
 #2

Their code is identical in the client, other than the slight difference in the help text. One says it "[r]eturns the number of blocks in the longest block chain" the other says it "[r]eturns the block number of the latest block in the longest block chain".

Value getblockcount(const Array& params, bool fHelp)
{
    if (fHelp || params.size() != 0)
        throw runtime_error(
            "getblockcount\n"
            "Returns the number of blocks in the longest block chain.");

    return nBestHeight;
}

Value getblocknumber(const Array& params, bool fHelp)
{
    if (fHelp || params.size() != 0)
        throw runtime_error(
            "getblocknumber\n"
            "Returns the block number of the latest block in the longest block chain.");

    return nBestHeight;
}

I am an employee of Ripple.
1Joe1Katzci1rFcsr9HH7SLuHVnDy2aihZ BM-NBM3FRExVJSJJamV9ccgyWvQfratUHgN
theymos
Administrator
Legendary
*
expert
Offline Offline

Activity: 2506


View Profile
June 28, 2011, 02:50:59 AM
 #3

They are the same. getblocknumber is obsolete.

It used to be that getblocknumber would return the highest block number, while getblockcount would return the total number of blocks. Confusingly, this behavior was switched when getblocknumber was made obsolete, so getblockcount now actually gives the highest block number.

The total number of blocks is different from the highest block number because the genesis block is block #0.

1NXYoJ5xU91Jp83XfVMHwwTUyZFK64BoAD
gigabytecoin
Sr. Member
****
Offline Offline

Activity: 280


View Profile
June 28, 2011, 03:33:02 AM
 #4

Thanks for those explanations everyone.
Pages: [1]
  Print  
 
Jump to:  

Sponsored by , a Bitcoin-accepting VPN.
Powered by MySQL Powered by PHP Powered by SMF 1.1.19 | SMF © 2006-2009, Simple Machines Valid XHTML 1.0! Valid CSS!