0
Does the getblock(hash) RPC call always return a "previousblockhash" field and if not: under what conditions does it not return this?
Background: many algorithms suggest using this field as a way to step back in the blockchain when an orphan or reorganization occurs but the C++ code would indicate this field isn't always present.
if (blockindex->pprev)
result.push_back(Pair("previousblockhash", blockindex->pprev->GetBlockHash().GetHex()));
Would that be due to chain reorganizations and orphans? Can anyone explain what dynamics would make this check fail and what the next step would be if it does?
Do you really mean orphan blocks, or rather stale blocks? A block can never become an orphan, Bitcoin Core can not connect a block without its previous existing. – Anonymous – 2015-08-08T10:53:20.667
I guess stale block might be the term I'm after then. Good observation – Matthew Roberts – 2015-08-08T11:05:22.650
It won't return information on
previousblockhashfor thegenesisblock, for instance. – George Kimionis – 2015-08-08T14:14:05.5671@Bitcoin Nice analysis, but it's not correct.
getblockheaderwas indeed added becausegetblockcan fail when a block is pruned, but even then, the index entries remain. See my answer. – Pieter Wuille – 2015-08-10T14:06:30.483@PieterWuille Right, that makes a lot more sense. – Anonymous – 2015-08-10T14:10:43.803