@@ -350,6 +350,9 @@ func (p *TxPool) ValidateTxBasics(tx *types.Transaction) error {
350
350
// Add enqueues a batch of transactions into the pool if they are valid. Due
351
351
// to the large transaction churn, add may postpone fully integrating the tx
352
352
// to a later point to batch multiple ones together.
353
+ //
354
+ // Note, if sync is set the method will block until all internal maintenance
355
+ // related to the add is finished. Only use this during tests for determinism.
353
356
func (p * TxPool ) Add (txs []* types.Transaction , sync bool ) []error {
354
357
// Split the input transactions between the subpools. It shouldn't really
355
358
// happen that we receive merged batches, but better graceful than strange
@@ -503,8 +506,8 @@ func (p *TxPool) Status(hash common.Hash) TxStatus {
503
506
// internal background reset operations. This method will run an explicit reset
504
507
// operation to ensure the pool stabilises, thus avoiding flakey behavior.
505
508
//
506
- // Note, do not use this in production / live code. In live code, the pool is
507
- // meant to reset on a separate thread to avoid DoS vectors .
509
+ // Note, this method is only used for testing and is susceptible to DoS vectors.
510
+ // In production code, the pool is meant to reset on a separate thread.
508
511
func (p * TxPool ) Sync () error {
509
512
sync := make (chan error )
510
513
select {
@@ -516,6 +519,10 @@ func (p *TxPool) Sync() error {
516
519
}
517
520
518
521
// Clear removes all tracked txs from the subpools.
522
+ //
523
+ // Note, this method invokes Sync() and is only used for testing, because it is
524
+ // susceptible to DoS vectors. In production code, the pool is meant to reset on
525
+ // a separate thread.
519
526
func (p * TxPool ) Clear () {
520
527
// Invoke Sync to ensure that txs pending addition don't get added to the pool after
521
528
// the subpools are subsequently cleared
0 commit comments