mempool: add CheckSpend method
This commit adds a new method CheckSpend to the mempool, which takes an outpoint and returns any transaction in the mempool that spends this outpoint.
This commit is contained in:
parent
ceb1caeb24
commit
5394ca1afe
1 changed files with 11 additions and 0 deletions
|
@ -571,6 +571,17 @@ func (mp *TxPool) checkPoolDoubleSpend(tx *btcutil.Tx) error {
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// CheckSpends checks whether the passed outpoint is already spent by a
|
||||||
|
// transaction in the mempool. If that's the case the spending transaction will
|
||||||
|
// be returned, if not nil will be returned.
|
||||||
|
func (mp *TxPool) CheckSpend(op wire.OutPoint) *btcutil.Tx {
|
||||||
|
mp.mtx.RLock()
|
||||||
|
txR := mp.outpoints[op]
|
||||||
|
mp.mtx.RUnlock()
|
||||||
|
|
||||||
|
return txR
|
||||||
|
}
|
||||||
|
|
||||||
// fetchInputUtxos loads utxo details about the input transactions referenced by
|
// fetchInputUtxos loads utxo details about the input transactions referenced by
|
||||||
// the passed transaction. First, it loads the details form the viewpoint of
|
// the passed transaction. First, it loads the details form the viewpoint of
|
||||||
// the main chain, then it adjusts them based upon the contents of the
|
// the main chain, then it adjusts them based upon the contents of the
|
||||||
|
|
Loading…
Reference in a new issue