Skip to content

Commit

Permalink
blockchain: Remove unused stxosToScriptSource.
Browse files Browse the repository at this point in the history
This removes the no longer used stxosToScriptSource function.

This is part of the overall effort to remove all of the code related to
taking previous script snapshots and feeding them through to the
indexers.
  • Loading branch information
davecgh committed Aug 19, 2022
1 parent fd1e115 commit fdbfcf1
Showing 1 changed file with 0 additions and 77 deletions.
77 changes: 0 additions & 77 deletions internal/blockchain/chain.go
Original file line number Diff line number Diff line change
Expand Up @@ -1991,83 +1991,6 @@ func extractDeploymentIDVersions(params *chaincfg.Params) (map[string]uint32, er
return deploymentVers, nil
}

// stxosToScriptSource uses the provided block and spent txo information to
// create a source of previous transaction scripts and versions spent by the
// block.
func stxosToScriptSource(block *dcrutil.Block, stxos []spentTxOut, isTreasuryEnabled bool, chainParams *chaincfg.Params) scriptSource {
source := make(scriptSource)
msgBlock := block.MsgBlock()

// TSpends can only be added to TVI blocks so don't look for them
// except in those blocks.
isTVI := standalone.IsTreasuryVoteInterval(uint64(msgBlock.Header.Height),
chainParams.TreasuryVoteInterval)

// Loop through all of the transaction inputs in the stake transaction
// tree (except for the stakebases, treasurybases and treasuryspends
// which have no inputs) and add the scripts and associated script
// versions from the referenced txos to the script source.
//
// Note that transactions in the stake tree are spent before transactions in
// the regular tree when originally creating the spend journal entry, thus
// the spent txouts need to be processed in the same order.
var stxoIdx int
for i, tx := range msgBlock.STransactions {
// Ignore treasury base and tspends since they have no inputs.
isTreasuryBase := isTreasuryEnabled && i == 0
isTSpend := isTreasuryEnabled && i > 0 && isTVI && stake.IsTSpend(tx)
if isTreasuryBase || isTSpend {
continue
}

isVote := stake.IsSSGen(tx)
for txInIdx, txIn := range tx.TxIn {
// Ignore stakebase since it has no input.
if isVote && txInIdx == 0 {
continue
}

// Ensure the spent txout index is incremented to stay in sync with
// the transaction input.
stxo := &stxos[stxoIdx]
stxoIdx++

// Create an output for the referenced script and version using the
// stxo data from the spend journal if it doesn't already exist in
// the view.
prevOut := &txIn.PreviousOutPoint
source[*prevOut] = scriptSourceEntry{
version: stxo.scriptVersion,
script: stxo.pkScript,
}
}
}

// Loop through all of the transaction inputs in the regular transaction
// tree (except for the coinbase which has no inputs) and add the scripts
// and associated script versions from the referenced txos to the script
// source.
for _, tx := range msgBlock.Transactions[1:] {
for _, txIn := range tx.TxIn {
// Ensure the spent txout index is incremented to stay in sync with
// the transaction input.
stxo := &stxos[stxoIdx]
stxoIdx++

// Create an output for the referenced script and version using the
// stxo data from the spend journal if it doesn't already exist in
// the view.
prevOut := &txIn.PreviousOutPoint
source[*prevOut] = scriptSourceEntry{
version: stxo.scriptVersion,
script: stxo.pkScript,
}
}
}

return source
}

// ChainQueryerAdapter provides an adapter from a BlockChain instance to the
// indexers.ChainQueryer interface.
type ChainQueryerAdapter struct {
Expand Down

0 comments on commit fdbfcf1

Please sign in to comment.