mempool: Expose RemoveOrphansByTag function.

This commit is contained in:
Dave Collins 2016-10-28 12:49:11 -05:00
parent e992d55822
commit 2124accf62
No known key found for this signature in database
GPG key ID: B8904D9D9C93D1F2

View file

@ -218,6 +218,23 @@ func (mp *TxPool) RemoveOrphan(tx *btcutil.Tx) {
mp.mtx.Unlock()
}
// RemoveOrphansByTag removes all orphan transactions tagged with the provided
// identifier.
//
// This function is safe for concurrent access.
func (mp *TxPool) RemoveOrphansByTag(tag Tag) uint64 {
var numEvicted uint64
mp.mtx.Lock()
for _, otx := range mp.orphans {
if otx.tag == tag {
mp.removeOrphan(otx.tx, true)
numEvicted++
}
}
mp.mtx.Unlock()
return numEvicted
}
// limitNumOrphans limits the number of orphan transactions by evicting a random
// orphan if adding a new one would cause it to overflow the max allowed.
//