blockchain: Trsy always inactive for genesis blk.

This modifies the IsTreasuryAgendaActive method to return false when a
zero hash is provided since that indicates the next block is the genesis
block and the treasury agenda is always inactive for the genesis block.

This has the effect of fixing a few RPC handlers, such as getblock, when
working with the genesis block.
This commit is contained in:
Dave Collins 2021-04-20 01:23:58 -05:00
parent cd76b0799b
commit 02567db254
No known key found for this signature in database
GPG Key ID: B8904D9D9C93D1F2

View File

@ -717,6 +717,11 @@ func (b *BlockChain) isTreasuryAgendaActive(prevNode *blockNode) (bool, error) {
//
// This function is safe for concurrent access.
func (b *BlockChain) IsTreasuryAgendaActive(prevHash *chainhash.Hash) (bool, error) {
// The treasury agenda is never active for the genesis block.
if *prevHash == *zeroHash {
return false, nil
}
prevNode := b.index.LookupNode(prevHash)
if prevNode == nil || !b.index.CanValidate(prevNode) {
return false, unknownBlockError(prevHash)