good morning!!!!

Skip to content
Snippets Groups Projects
Unverified Commit 2cccf6d0 authored by Evgeny Danilenko's avatar Evgeny Danilenko Committed by GitHub
Browse files

Tx pool: prevent double start or stop (#744)

* use isStarted

* set on stop
parent 9da86a27
Branches
Tags
No related merge requests found
...@@ -507,6 +507,9 @@ func (pool *TxPool) Stop() { ...@@ -507,6 +507,9 @@ func (pool *TxPool) Stop() {
if pool.journal != nil { if pool.journal != nil {
pool.journal.close() pool.journal.close()
} }
pool.isStarted = false
log.Info("Transaction pool stopped") log.Info("Transaction pool stopped")
} }
...@@ -1460,6 +1463,10 @@ func (pool *TxPool) RunInit() error { ...@@ -1460,6 +1463,10 @@ func (pool *TxPool) RunInit() error {
return errors.New("can't init a nil transaction pool") return errors.New("can't init a nil transaction pool")
} }
if pool.IsStarted() {
return errors.New("transaction pool is already started")
}
var err error var err error
for _, fn := range pool.initFns { for _, fn := range pool.initFns {
if err = fn(); err != nil { if err = fn(); err != nil {
...@@ -1482,6 +1489,10 @@ func (pool *TxPool) RunStop() error { ...@@ -1482,6 +1489,10 @@ func (pool *TxPool) RunStop() error {
return errors.New("can't stop a nil transaction pool") return errors.New("can't stop a nil transaction pool")
} }
if !pool.IsStarted() {
return errors.New("transaction pool is already stopped")
}
var err error var err error
for _, fn := range pool.stopFns { for _, fn := range pool.stopFns {
if err = fn(); err != nil { if err = fn(); err != nil {
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment