Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 11 additions & 5 deletions core/txpool/txpool.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
package txpool

import (
"errors"
"fmt"
"maps"
"math/big"

Expand Down Expand Up @@ -89,13 +89,19 @@ func (p *TxPool) Close() error {
// Terminate the reset loop and wait for it to finish
errc := make(chan error)
p.quit <- errc
errs = append(errs, <-errc)

if err := <-errc; err != nil {
errs = append(errs, err)
}
// Terminate each subpool
for _, subpool := range p.subpools {
errs = append(errs, subpool.Close())
if err := subpool.Close(); err != nil {
errs = append(errs, err)
}
}
return errors.Join(errs...)
if len(errs) > 0 {
return fmt.Errorf("subpool close errors: %v", errs)
Copy link

Copilot AI Jan 5, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The error message "subpool close errors" is misleading because the errs slice can also contain an error from the quit channel (line 92-94), which is not a subpool close error. Consider using a more accurate message like "transaction pool close errors" or separately handling and reporting errors from different sources for better diagnostics.

Suggested change
return fmt.Errorf("subpool close errors: %v", errs)
return fmt.Errorf("transaction pool close errors: %v", errs)

Copilot uses AI. Check for mistakes.
Comment on lines +101 to +102
Copy link

Copilot AI Jan 5, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The formatting of multiple errors using fmt.Errorf with %v will produce a slice representation like "[error1 error2]" which is not as user-friendly as the errors.Join function which formats errors on separate lines. Consider using a loop with strings.Builder to format each error on its own line, or use a semicolon-separated format for better readability.

Copilot uses AI. Check for mistakes.
}
return nil
}

// loop is the transaction pool's main event loop, waiting for and reacting to
Expand Down