Bitcoin Forum
May 10, 2024, 06:07:30 PM *
News: Latest Bitcoin Core release: 27.0 [Torrent]
 
   Home   Help Search Login Register More  
Pages: [1]
  Print  
Author Topic: What is the difference between getblockCOUNT and getblockNUMBER ???  (Read 1863 times)
gigabytecoin (OP)
Sr. Member
****
Offline Offline

Activity: 280
Merit: 252


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

Posts: 1715364450

View Profile Personal Message (Offline)

Ignore
1715364450
Reply with quote  #2

1715364450
Report to moderator
"If you don't want people to know you're a scumbag then don't be a scumbag." -- margaritahuyan
Advertised sites are not endorsed by the Bitcoin Forum. They may be unsafe, untrustworthy, or illegal in your jurisdiction.
JoelKatz
Legendary
*
Offline Offline

Activity: 1596
Merit: 1012


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: 5194
Merit: 12982


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 (OP)
Sr. Member
****
Offline Offline

Activity: 280
Merit: 252


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

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

Powered by MySQL Powered by PHP Powered by SMF 1.1.19 | SMF © 2006-2009, Simple Machines Valid XHTML 1.0! Valid CSS!