core/txpool: add notice to Clear that is not meant for production code

This commit is contained in:
lightclient 2025-04-04 13:48:56 -06:00
parent 9f83e9e673
commit c1b9b76d7e
No known key found for this signature in database
GPG key ID: 657913021EF45A6A
3 changed files with 9 additions and 0 deletions

View file

@ -1754,6 +1754,9 @@ func (p *BlobPool) Status(hash common.Hash) txpool.TxStatus {
// Clear implements txpool.SubPool, removing all tracked transactions // Clear implements txpool.SubPool, removing all tracked transactions
// from the blob pool and persistent store. // from the blob pool and persistent store.
//
// Note, do not use this in production / live code. In live code, the pool is
// meant to reset on a separate thread to avoid DoS vectors.
func (p *BlobPool) Clear() { func (p *BlobPool) Clear() {
p.lock.Lock() p.lock.Lock()
defer p.lock.Unlock() defer p.lock.Unlock()

View file

@ -1876,6 +1876,9 @@ func numSlots(tx *types.Transaction) int {
// Clear implements txpool.SubPool, removing all tracked txs from the pool // Clear implements txpool.SubPool, removing all tracked txs from the pool
// and rotating the journal. // and rotating the journal.
//
// Note, do not use this in production / live code. In live code, the pool is
// meant to reset on a separate thread to avoid DoS vectors.
func (pool *LegacyPool) Clear() { func (pool *LegacyPool) Clear() {
pool.mu.Lock() pool.mu.Lock()
defer pool.mu.Unlock() defer pool.mu.Unlock()

View file

@ -575,6 +575,9 @@ func (p *TxPool) Sync() error {
} }
// Clear removes all tracked txs from the subpools. // Clear removes all tracked txs from the subpools.
//
// Note, do not use this in production / live code. In live code, the pool is
// meant to reset on a separate thread to avoid DoS vectors.
func (p *TxPool) Clear() { func (p *TxPool) Clear() {
// Invoke Sync to ensure that txs pending addition don't get added to the pool after // Invoke Sync to ensure that txs pending addition don't get added to the pool after
// the subpools are subsequently cleared // the subpools are subsequently cleared