mirror of
https://github.com/bitcoinj/bitcoinj.git
synced 2025-03-13 11:36:15 +01:00
StoredBlock: if getPrev() called on a genesis block, cut short
Don't try to locate a previous block of the genesis block, using an arbitrary "previous block hash".
This commit is contained in:
parent
9e91ae629e
commit
8cbd09438c
1 changed files with 3 additions and 1 deletions
|
@ -129,7 +129,9 @@ public class StoredBlock {
|
|||
* @return the previous block in the chain or null if it was not found in the store.
|
||||
*/
|
||||
public StoredBlock getPrev(BlockStore store) throws BlockStoreException {
|
||||
return store.get(getHeader().getPrevBlockHash());
|
||||
return height > 0 ?
|
||||
store.get(header.getPrevBlockHash()) :
|
||||
null; // Genesis blocks have no previous block.
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
Loading…
Add table
Reference in a new issue