Author

Topic: What is the difference between getblockCOUNT and getblockNUMBER ??? (Read 1879 times)

sr. member
Activity: 280
Merit: 252
Thanks for those explanations everyone.
administrator
Activity: 5222
Merit: 13032
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.
legendary
Activity: 1596
Merit: 1012
Democracy is vulnerable to a 51% attack.
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;
}
sr. member
Activity: 280
Merit: 252
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?
Jump to: