From 93902730c19c0fb37c8eeb1b228ee9267da57394 Mon Sep 17 00:00:00 2001 From: Ryan Staudt Date: Tue, 27 Jul 2021 12:59:07 -0500 Subject: [PATCH] blockchain: Add IsTreasuryEnabled to AgendaFlags. This adds an IsTreasuryEnabled method to the AgendaFlags type that returns whether the flags indicate that the treasury agenda is enabled. This is useful since checking the flags directly is pretty verbose, especially when using the type outside of the blockchain package. This also updates existing references to the AgendaFlags type to use the IsTreasuryEnabled function. --- blockchain/validate.go | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/blockchain/validate.go b/blockchain/validate.go index 08cbbe07..76bd646d 100644 --- a/blockchain/validate.go +++ b/blockchain/validate.go @@ -328,6 +328,12 @@ const ( AFNone AgendaFlags = 0 ) +// IsTreasuryEnabled returns whether the flags indicate that the treasury agenda +// is enabled. +func (flags AgendaFlags) IsTreasuryEnabled() bool { + return flags&AFTreasuryEnabled == AFTreasuryEnabled +} + // checkTransactionContext performs several validation checks on the transaction // which depend on having the full block data for all of its ancestors // available, most likely because the checks depend on whether or not an agenda @@ -338,7 +344,7 @@ const ( // in order to change how the validation rules are applied accordingly. func checkTransactionContext(tx *wire.MsgTx, params *chaincfg.Params, flags AgendaFlags) error { // Determine active agendas based on flags. - isTreasuryEnabled := flags&AFTreasuryEnabled == AFTreasuryEnabled + isTreasuryEnabled := flags.IsTreasuryEnabled() // Determine type. var isCoinBase, isVote, isTicket, isRevocation bool