Skip to content

Commit 12aab72

Browse files
committed
mempool: refactor fetchInputUtxosFromUData to fetchInputUtxosFromLeaves
Since the leaves are the actual data we need, it's better that the function argument is the leaves and not the udata. This allows for calling fetchInputUtxosFromLeaves from a different mempool method as the leaves are kept track of.
1 parent 6ed428f commit 12aab72

File tree

1 file changed

+5
-5
lines changed

1 file changed

+5
-5
lines changed

mempool/mempool.go

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -826,18 +826,18 @@ func (mp *TxPool) fetchInputUtxos(tx *btcutil.Tx) (*blockchain.UtxoViewpoint, er
826826
return utxoView, nil
827827
}
828828

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

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

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

0 commit comments

Comments
 (0)