Bitcoin Forum
April 04, 2020, 04:15:08 PM *
News: Latest Bitcoin Core release: 0.19.1 [Torrent]
 
   Home   Help Search Login Register More  
Pages: [1]
  Print  
Author Topic: What is the difference between getblockCOUNT and getblockNUMBER ???  (Read 1791 times)
gigabytecoin
Sr. Member
****
Offline Offline

Activity: 280
Merit: 250


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?
1586016908
Hero Member
*
Offline Offline

Posts: 1586016908

View Profile Personal Message (Offline)

Ignore
1586016908
Reply with quote  #2

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

Posts: 1586016908

View Profile Personal Message (Offline)

Ignore
1586016908
Reply with quote  #2

1586016908
Report to moderator
JoelKatz
Legendary
*
Offline Offline

Activity: 1596
Merit: 1005


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. Follow me on Twitter @JoelKatz
1Joe1Katzci1rFcsr9HH7SLuHVnDy2aihZ BM-NBM3FRExVJSJJamV9ccgyWvQfratUHgN
theymos
Administrator
Legendary
*
Offline Offline

Activity: 3710
Merit: 7711


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
Merit: 250


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!