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

* use isStarted

* set on stop
This commit is contained in:
Evgeny Danilenko 2020-07-14 16:14:43 +03:00 committed by GitHub
parent 9da86a2737
commit 2cccf6d02c
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -507,6 +507,9 @@ func (pool *TxPool) Stop() {
if pool.journal != nil {
pool.journal.close()
}
pool.isStarted = false
log.Info("Transaction pool stopped")
}
@ -1460,6 +1463,10 @@ func (pool *TxPool) RunInit() error {
return errors.New("can't init a nil transaction pool")
}
if pool.IsStarted() {
return errors.New("transaction pool is already started")
}
var err error
for _, fn := range pool.initFns {
if err = fn(); err != nil {
@ -1482,6 +1489,10 @@ func (pool *TxPool) RunStop() error {
return errors.New("can't stop a nil transaction pool")
}
if !pool.IsStarted() {
return errors.New("transaction pool is already stopped")
}
var err error
for _, fn := range pool.stopFns {
if err = fn(); err != nil {