multi: Add auto revocations to agenda flags.
This adds AFAutoRevocationsEnabled to blockchain.AgendaFlags, which may be set to indicate that the automatic ticket revocations agenda should be considered as active when checking a transaction so that any additional checks which depend on the agenda being active are applied. Additionally, this updates all references of blockchain.AgendaFlags to set AFAutoRevocationsEnabled if the automatic ticket revocations agenda is active.
This commit is contained in:
parent
83e21aad6e
commit
170ba4fc99
@ -330,6 +330,12 @@ const (
|
||||
// being active are applied.
|
||||
AFExplicitVerUpgrades
|
||||
|
||||
// AFAutoRevocationsEnabled may be set to indicate that the automatic ticket
|
||||
// revocations agenda should be considered as active when checking a
|
||||
// transaction so that any additional checks which depend on the agenda being
|
||||
// active are applied.
|
||||
AFAutoRevocationsEnabled
|
||||
|
||||
// AFNone is a convenience value to specifically indicate no flags.
|
||||
AFNone AgendaFlags = 0
|
||||
)
|
||||
@ -346,6 +352,12 @@ func (flags AgendaFlags) IsExplicitVerUpgradesEnabled() bool {
|
||||
return flags&AFExplicitVerUpgrades == AFExplicitVerUpgrades
|
||||
}
|
||||
|
||||
// IsAutoRevocationsEnabled returns whether the flags indicate that the
|
||||
// automatic ticket revocations agenda is enabled.
|
||||
func (flags AgendaFlags) IsAutoRevocationsEnabled() bool {
|
||||
return flags&AFAutoRevocationsEnabled == AFAutoRevocationsEnabled
|
||||
}
|
||||
|
||||
// determineCheckTxFlags returns the flags to use when checking transactions
|
||||
// based on the agendas that are active as of the block AFTER the given node.
|
||||
func (b *BlockChain) determineCheckTxFlags(prevNode *blockNode) (AgendaFlags, error) {
|
||||
@ -362,6 +374,13 @@ func (b *BlockChain) determineCheckTxFlags(prevNode *blockNode) (AgendaFlags, er
|
||||
return 0, err
|
||||
}
|
||||
|
||||
// Determine if the automatic ticket revocations agenda is active as of the
|
||||
// block being checked.
|
||||
isAutoRevocationsEnabled, err := b.isAutoRevocationsAgendaActive(prevNode)
|
||||
if err != nil {
|
||||
return 0, err
|
||||
}
|
||||
|
||||
// Create and return agenda flags for checking transactions based on which
|
||||
// ones are active as of the block being checked.
|
||||
checkTxFlags := AFNone
|
||||
@ -371,6 +390,9 @@ func (b *BlockChain) determineCheckTxFlags(prevNode *blockNode) (AgendaFlags, er
|
||||
if explicitUpgradesActive {
|
||||
checkTxFlags |= AFExplicitVerUpgrades
|
||||
}
|
||||
if isAutoRevocationsEnabled {
|
||||
checkTxFlags |= AFAutoRevocationsEnabled
|
||||
}
|
||||
return checkTxFlags, nil
|
||||
}
|
||||
|
||||
|
||||
@ -1795,6 +1795,11 @@ func (mp *TxPool) MaybeAcceptTransaction(tx *dcrutil.Tx, isNew, rateLimit bool)
|
||||
return nil, err
|
||||
}
|
||||
|
||||
isAutoRevocationsEnabled, err := mp.cfg.IsAutoRevocationsAgendaActive()
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
// Create agenda flags for checking transactions based on which ones are
|
||||
// active or should otherwise always be enforced.
|
||||
//
|
||||
@ -1803,6 +1808,9 @@ func (mp *TxPool) MaybeAcceptTransaction(tx *dcrutil.Tx, isNew, rateLimit bool)
|
||||
if isTreasuryEnabled {
|
||||
checkTxFlags |= blockchain.AFTreasuryEnabled
|
||||
}
|
||||
if isAutoRevocationsEnabled {
|
||||
checkTxFlags |= blockchain.AFAutoRevocationsEnabled
|
||||
}
|
||||
|
||||
// Protect concurrent access.
|
||||
mp.mtx.Lock()
|
||||
@ -2041,6 +2049,11 @@ func (mp *TxPool) ProcessTransaction(tx *dcrutil.Tx, allowOrphan, rateLimit, all
|
||||
return nil, err
|
||||
}
|
||||
|
||||
isAutoRevocationsEnabled, err := mp.cfg.IsAutoRevocationsAgendaActive()
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
// Create agenda flags for checking transactions based on which ones are
|
||||
// active or should otherwise always be enforced.
|
||||
//
|
||||
@ -2049,6 +2062,9 @@ func (mp *TxPool) ProcessTransaction(tx *dcrutil.Tx, allowOrphan, rateLimit, all
|
||||
if isTreasuryEnabled {
|
||||
checkTxFlags |= blockchain.AFTreasuryEnabled
|
||||
}
|
||||
if isAutoRevocationsEnabled {
|
||||
checkTxFlags |= blockchain.AFAutoRevocationsEnabled
|
||||
}
|
||||
|
||||
// Protect concurrent access.
|
||||
mp.mtx.Lock()
|
||||
|
||||
Loading…
Reference in New Issue
Block a user