From 2124accf62e424ff02aa6845d66be0e8191202ea Mon Sep 17 00:00:00 2001 From: Dave Collins <davec@conformal.com> Date: Fri, 28 Oct 2016 12:49:11 -0500 Subject: [PATCH] mempool: Expose RemoveOrphansByTag function. --- mempool/mempool.go | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/mempool/mempool.go b/mempool/mempool.go index 7221a394..7f47e0a2 100644 --- a/mempool/mempool.go +++ b/mempool/mempool.go @@ -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. //