Skip to content

Commit

Permalink
Merge pull request btcsuite#209 from kcalvinalvin/2024-11-05-udata-to…
Browse files Browse the repository at this point in the history
…-leaves

mempool: refactor fetchInputUtxosFromUData to fetchInputUtxosFromLeaves
  • Loading branch information
kcalvinalvin authored Nov 5, 2024
2 parents 6ed428f + 12aab72 commit d801339
Showing 1 changed file with 5 additions and 5 deletions.
10 changes: 5 additions & 5 deletions mempool/mempool.go
Original file line number Diff line number Diff line change
Expand Up @@ -826,18 +826,18 @@ func (mp *TxPool) fetchInputUtxos(tx *btcutil.Tx) (*blockchain.UtxoViewpoint, er
return utxoView, nil
}

// fetchInputUtxosFromUData extracts utxo details about the input transactions
// provided in the UData for the passed transaction. First, it extracts the
// fetchInputUtxosFromLeaves extracts utxo details about the input transactions
// provided in the leaves for the passed transaction. First, it extracts the
// details from the udata, then it adjusts them based upon the contents of the
// transaction pool.
//
// This function MUST be called with the mempool lock held (for reads).
func (mp *TxPool) fetchInputUtxosFromUData(tx *btcutil.Tx, ud *wire.UData) *blockchain.UtxoViewpoint {
func (mp *TxPool) fetchInputUtxosFromLeaves(tx *btcutil.Tx, leaves []wire.LeafData) *blockchain.UtxoViewpoint {
utxoView := blockchain.NewUtxoViewpoint()
viewEntries := utxoView.Entries()

// Loop through leaf datas and convert them into UtxoEntries.
for _, ld := range ud.LeafDatas {
for _, ld := range leaves {
// If the leaf data was marked to be unconfirmed, set as nil.
// The outpoint for the txIn that this LeafData is supposed to
// represent will be attempted to be fetched from the mempool
Expand Down Expand Up @@ -1492,7 +1492,7 @@ func (mp *TxPool) checkMempoolAcceptance(tx *btcutil.Tx,
log.Debugf("VerifyUData passed for tx %s", txHash.String())

// After the validation passes, turn that proof into a utxoView.
utxoView = mp.fetchInputUtxosFromUData(tx, ud)
utxoView = mp.fetchInputUtxosFromLeaves(tx, ud.LeafDatas)
} else {
// Fetch all of the unspent transaction outputs referenced by the
// inputs to this transaction. This function also attempts to fetch the
Expand Down

0 comments on commit d801339

Please sign in to comment.