Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

mempool: refactor fetchInputUtxosFromUData to fetchInputUtxosFromLeaves #209

Merged
merged 1 commit into from
Nov 5, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading