multi: Remove treasury flag from several funcs.
This removes the treasury agenda flag from the several functions since it is now unused due to it being removed from the stake.IsSSGen function.
This commit is contained in:
parent
5b8b1f7b3d
commit
065222e2bc
@ -647,10 +647,10 @@ func (b *BlockChain) connectBlock(node *blockNode, block, parent *dcrutil.Block,
|
||||
isTreasuryEnabled := checkTxFlags.IsTreasuryEnabled()
|
||||
|
||||
// Sanity check the correct number of stxos are provided.
|
||||
if len(stxos) != countSpentOutputs(block, isTreasuryEnabled) {
|
||||
if len(stxos) != countSpentOutputs(block) {
|
||||
panicf("provided %v stxos for block %v (height %v) which spends %v "+
|
||||
"outputs", len(stxos), node.hash, node.height,
|
||||
countSpentOutputs(block, isTreasuryEnabled))
|
||||
countSpentOutputs(block))
|
||||
}
|
||||
|
||||
// Write any modified block index entries to the database before
|
||||
@ -689,7 +689,7 @@ func (b *BlockChain) connectBlock(node *blockNode, block, parent *dcrutil.Block,
|
||||
curTotalTxns := b.stateSnapshot.TotalTxns
|
||||
curTotalSubsidy := b.stateSnapshot.TotalSubsidy
|
||||
b.stateLock.RUnlock()
|
||||
subsidy := calculateAddedSubsidy(block, parent, isTreasuryEnabled)
|
||||
subsidy := calculateAddedSubsidy(block, parent)
|
||||
numTxns := uint64(len(block.Transactions()) + len(block.STransactions()))
|
||||
blockSize := uint64(block.MsgBlock().Header.Size)
|
||||
state := newBestState(node, blockSize, numTxns, curTotalTxns+numTxns,
|
||||
@ -866,7 +866,6 @@ func (b *BlockChain) disconnectBlock(node *blockNode, block, parent *dcrutil.Blo
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
isTreasuryEnabled := checkTxFlags.IsTreasuryEnabled()
|
||||
|
||||
// Write any modified block index entries to the database before
|
||||
// updating the best state.
|
||||
@ -895,7 +894,7 @@ func (b *BlockChain) disconnectBlock(node *blockNode, block, parent *dcrutil.Blo
|
||||
numParentTxns := uint64(len(parent.Transactions()) + len(parent.STransactions()))
|
||||
numBlockTxns := uint64(len(block.Transactions()) + len(block.STransactions()))
|
||||
newTotalTxns := curTotalTxns - numBlockTxns
|
||||
subsidy := calculateAddedSubsidy(block, parent, isTreasuryEnabled)
|
||||
subsidy := calculateAddedSubsidy(block, parent)
|
||||
newTotalSubsidy := curTotalSubsidy - subsidy
|
||||
prevNode := node.parent
|
||||
state := newBestState(prevNode, parentBlockSize, numParentTxns,
|
||||
@ -997,7 +996,7 @@ func countSpentRegularOutputs(block *dcrutil.Block) int {
|
||||
|
||||
// countSpentStakeOutputs returns the number of utxos the stake transactions in
|
||||
// the passed block spend.
|
||||
func countSpentStakeOutputs(block *dcrutil.Block, isTreasuryEnabled bool) int {
|
||||
func countSpentStakeOutputs(block *dcrutil.Block) int {
|
||||
var numSpent int
|
||||
for _, stx := range block.MsgBlock().STransactions {
|
||||
// Exclude the vote stakebase since it has no input.
|
||||
@ -1017,9 +1016,8 @@ func countSpentStakeOutputs(block *dcrutil.Block, isTreasuryEnabled bool) int {
|
||||
}
|
||||
|
||||
// countSpentOutputs returns the number of utxos the passed block spends.
|
||||
func countSpentOutputs(block *dcrutil.Block, isTreasuryEnabled bool) int {
|
||||
return countSpentRegularOutputs(block) +
|
||||
countSpentStakeOutputs(block, isTreasuryEnabled)
|
||||
func countSpentOutputs(block *dcrutil.Block) int {
|
||||
return countSpentRegularOutputs(block) + countSpentStakeOutputs(block)
|
||||
}
|
||||
|
||||
// loadOrCreateFilter attempts to load and return the version 2 GCS filter for
|
||||
@ -1239,7 +1237,7 @@ func (b *BlockChain) reorganizeChainInternal(target *blockNode) error {
|
||||
// Skip validation if the block has already been validated. However,
|
||||
// the utxo view still needs to be updated and the stxos and header
|
||||
// commitment data are still needed.
|
||||
numSpentOutputs := countSpentOutputs(block, isTreasuryEnabled)
|
||||
numSpentOutputs := countSpentOutputs(block)
|
||||
stxos := make([]spentTxOut, 0, numSpentOutputs)
|
||||
var hdrCommitments headerCommitmentData
|
||||
if b.index.NodeStatus(n).HasValidated() {
|
||||
|
||||
@ -646,7 +646,7 @@ func decodeSpentTxOut(serialized []byte, stxo *spentTxOut, amount int64,
|
||||
// format comments, this function also requires the transactions that spend the
|
||||
// txouts and a utxo view that contains any remaining existing utxos in the
|
||||
// transactions referenced by the inputs to the passed transactions.
|
||||
func deserializeSpendJournalEntry(serialized []byte, txns []*wire.MsgTx, isTreasuryEnabled bool) ([]spentTxOut, error) {
|
||||
func deserializeSpendJournalEntry(serialized []byte, txns []*wire.MsgTx) ([]spentTxOut, error) {
|
||||
// Calculate the total number of stxos.
|
||||
var numStxos int
|
||||
for _, tx := range txns {
|
||||
@ -769,8 +769,7 @@ func dbFetchSpendJournalEntry(dbTx database.Tx, block *dcrutil.Block, isTreasury
|
||||
panicf("missing spend journal data for %s", block.Hash())
|
||||
}
|
||||
|
||||
stxos, err := deserializeSpendJournalEntry(serialized, blockTxns,
|
||||
isTreasuryEnabled)
|
||||
stxos, err := deserializeSpendJournalEntry(serialized, blockTxns)
|
||||
if err != nil {
|
||||
// Ensure any deserialization errors are returned as database
|
||||
// corruption errors.
|
||||
|
||||
@ -706,7 +706,7 @@ func TestSpendJournalSerialization(t *testing.T) {
|
||||
|
||||
// Deserialize to a spend journal entry.
|
||||
gotEntry, err := deserializeSpendJournalEntry(test.serialized,
|
||||
test.blockTxns, noTreasury)
|
||||
test.blockTxns)
|
||||
if err != nil {
|
||||
t.Errorf("%q: unexpected error: %v", test.name, err)
|
||||
continue
|
||||
@ -778,7 +778,7 @@ func TestSpendJournalErrors(t *testing.T) {
|
||||
// Ensure the expected error type is returned and the returned
|
||||
// slice is nil.
|
||||
stxos, err := deserializeSpendJournalEntry(test.serialized,
|
||||
test.blockTxns, noTreasury)
|
||||
test.blockTxns)
|
||||
if !errors.As(err, &test.errType) {
|
||||
t.Errorf("%q: expected error type does not match - got %T, want %T",
|
||||
test.name, err, test.errType)
|
||||
|
||||
@ -1043,7 +1043,7 @@ func (idx *AddrIndex) indexUnconfirmedAddresses(scriptVersion uint16, pkScript [
|
||||
// some or all addresses not being indexed.
|
||||
//
|
||||
// This function is safe for concurrent access.
|
||||
func (idx *AddrIndex) AddUnconfirmedTx(tx *dcrutil.Tx, prevScripts PrevScripter, isTreasuryEnabled bool) {
|
||||
func (idx *AddrIndex) AddUnconfirmedTx(tx *dcrutil.Tx, prevScripts PrevScripter) {
|
||||
// Index addresses of all referenced previous transaction outputs.
|
||||
//
|
||||
// The existence checks are elided since this is only called after the
|
||||
|
||||
@ -32,7 +32,7 @@ type SequenceLock struct {
|
||||
// to the IsSSGen function in the stake package and exists to make calling code
|
||||
// that does not care about the specific reason the transaction is not a
|
||||
// stakebase, rather only if it is one or not.
|
||||
func isStakeBaseTx(tx *wire.MsgTx, isTreasuryEnabled bool) bool {
|
||||
func isStakeBaseTx(tx *wire.MsgTx) bool {
|
||||
return stake.IsSSGen(tx)
|
||||
}
|
||||
|
||||
@ -57,7 +57,7 @@ func (b *BlockChain) calcSequenceLock(node *blockNode, tx *dcrutil.Tx, view *Utx
|
||||
msgTx := tx.MsgTx()
|
||||
enforce := isActive && msgTx.Version >= 2
|
||||
if !enforce || standalone.IsCoinBaseTx(msgTx, isTreasuryEnabled) ||
|
||||
isStakeBaseTx(msgTx, isTreasuryEnabled) {
|
||||
isStakeBaseTx(msgTx) {
|
||||
return sequenceLock, nil
|
||||
}
|
||||
|
||||
|
||||
@ -177,7 +177,7 @@ func checkTreasuryBase(subsidyCache *standalone.SubsidyCache, tx *dcrutil.Tx, he
|
||||
// and its parent. The blocks passed to this function MUST be valid blocks
|
||||
// that have already been confirmed to abide by the consensus rules of the
|
||||
// network, or the function might panic.
|
||||
func calculateAddedSubsidy(block, parent *dcrutil.Block, isTreasuryEnabled bool) int64 {
|
||||
func calculateAddedSubsidy(block, parent *dcrutil.Block) int64 {
|
||||
var subsidy int64
|
||||
if headerApprovesParent(&block.MsgBlock().Header) {
|
||||
subsidy += parent.MsgBlock().Transactions[0].TxIn[0].ValueIn
|
||||
|
||||
@ -493,10 +493,10 @@ func (view *UtxoViewpoint) disconnectDisapprovedBlock(db database.DB, block *dcr
|
||||
}
|
||||
|
||||
// Sanity check the correct number of stxos are provided.
|
||||
if len(stxos) != countSpentOutputs(block, isTreasuryEnabled) {
|
||||
if len(stxos) != countSpentOutputs(block) {
|
||||
panicf("provided %v stxos for block %v (height %v) which spends %v "+
|
||||
"outputs", len(stxos), block.Hash(), block.MsgBlock().Header.Height,
|
||||
countSpentOutputs(block, isTreasuryEnabled))
|
||||
countSpentOutputs(block))
|
||||
}
|
||||
|
||||
return view.disconnectRegularTransactions(block, stxos, isTreasuryEnabled,
|
||||
@ -586,10 +586,10 @@ func (view *UtxoViewpoint) disconnectBlock(block, parent *dcrutil.Block,
|
||||
stxos []spentTxOut, isTreasuryEnabled, isAutoRevocationsEnabled bool) error {
|
||||
|
||||
// Sanity check the correct number of stxos are provided.
|
||||
if len(stxos) != countSpentOutputs(block, isTreasuryEnabled) {
|
||||
if len(stxos) != countSpentOutputs(block) {
|
||||
panicf("provided %v stxos for block %v (height %v) which spends %v "+
|
||||
"outputs", len(stxos), block.Hash(), block.MsgBlock().Header.Height,
|
||||
countSpentOutputs(block, isTreasuryEnabled))
|
||||
countSpentOutputs(block))
|
||||
}
|
||||
|
||||
// Load all of the utxos referenced by the inputs for all transactions in
|
||||
|
||||
@ -3327,8 +3327,7 @@ func checkNumSigOps(tx *dcrutil.Tx, view *UtxoViewpoint, index int, txTree bool,
|
||||
// single stakebase transactions (votes) within a block. This function skips a
|
||||
// ton of checks already performed by CheckTransactionInputs.
|
||||
func checkStakeBaseAmounts(subsidyCache *standalone.SubsidyCache, height int64,
|
||||
txs []*dcrutil.Tx, view *UtxoViewpoint, isTreasuryEnabled,
|
||||
isSubsidySplitEnabled bool) error {
|
||||
txs []*dcrutil.Tx, view *UtxoViewpoint, isSubsidySplitEnabled bool) error {
|
||||
|
||||
for _, tx := range txs {
|
||||
msgTx := tx.MsgTx()
|
||||
@ -3644,7 +3643,7 @@ func (b *BlockChain) checkTransactionsAndConnect(inputFees dcrutil.Amount, node
|
||||
}
|
||||
|
||||
err := checkStakeBaseAmounts(b.subsidyCache, node.height, txs, view,
|
||||
isTreasuryEnabled, isSubsidySplitEnabled)
|
||||
isSubsidySplitEnabled)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
@ -120,7 +120,7 @@ func TestBlockchainSpendJournal(t *testing.T) {
|
||||
return err
|
||||
}
|
||||
|
||||
ntx := countSpentOutputs(block, noTreasury)
|
||||
ntx := countSpentOutputs(block)
|
||||
stxos, err := dbFetchSpendJournalEntry(dbTx, block,
|
||||
noTreasury)
|
||||
if err != nil {
|
||||
|
||||
@ -975,7 +975,7 @@ func (mp *TxPool) addTransaction(utxoView *blockchain.UtxoViewpoint,
|
||||
// Add unconfirmed address index entries associated with the transaction
|
||||
// if enabled.
|
||||
if mp.cfg.AddrIndex != nil {
|
||||
mp.cfg.AddrIndex.AddUnconfirmedTx(tx, utxoView, isTreasuryEnabled)
|
||||
mp.cfg.AddrIndex.AddUnconfirmedTx(tx, utxoView)
|
||||
}
|
||||
if mp.cfg.ExistsAddrIndex != nil {
|
||||
mp.cfg.ExistsAddrIndex.AddUnconfirmedTx(msgTx)
|
||||
|
||||
@ -4086,7 +4086,7 @@ type retrievedTx struct {
|
||||
// fetchInputTxos fetches the outpoints from all transactions referenced by the
|
||||
// inputs to the passed transaction by checking the transaction mempool first
|
||||
// then the transaction index for those already mined into blocks.
|
||||
func fetchInputTxos(s *Server, tx *wire.MsgTx, isTreasuryEnabled bool) (map[wire.OutPoint]wire.TxOut, error) {
|
||||
func fetchInputTxos(s *Server, tx *wire.MsgTx) (map[wire.OutPoint]wire.TxOut, error) {
|
||||
originOutputs := make(map[wire.OutPoint]wire.TxOut)
|
||||
voteTx := stake.IsSSGen(tx)
|
||||
for txInIndex, txIn := range tx.TxIn {
|
||||
@ -4254,7 +4254,7 @@ func createVinListPrevOut(s *Server, mtx *wire.MsgTx,
|
||||
var originOutputs map[wire.OutPoint]wire.TxOut
|
||||
if vinExtra || len(filterAddrMap) > 0 {
|
||||
var err error
|
||||
originOutputs, err = fetchInputTxos(s, mtx, isTreasuryEnabled)
|
||||
originOutputs, err = fetchInputTxos(s, mtx)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
Loading…
Reference in New Issue
Block a user