forked from TrueCloudLab/neoneo-go
notary: wait for the service to finish on Shutdown
This commit is contained in:
parent
0d627c947f
commit
bf462a81fe
1 changed files with 4 additions and 0 deletions
|
@ -67,6 +67,7 @@ type (
|
|||
reqCh chan mempoolevent.Event
|
||||
blocksCh chan *block.Block
|
||||
stopCh chan struct{}
|
||||
done chan struct{}
|
||||
}
|
||||
|
||||
// Config represents external configuration for Notary module.
|
||||
|
@ -153,6 +154,7 @@ func NewNotary(cfg Config, net netmode.Magic, mp *mempool.Pool, onTransaction fu
|
|||
reqCh: make(chan mempoolevent.Event),
|
||||
blocksCh: make(chan *block.Block),
|
||||
stopCh: make(chan struct{}),
|
||||
done: make(chan struct{}),
|
||||
}, nil
|
||||
}
|
||||
|
||||
|
@ -206,6 +208,7 @@ drainLoop:
|
|||
}
|
||||
close(n.blocksCh)
|
||||
close(n.reqCh)
|
||||
close(n.done)
|
||||
}
|
||||
|
||||
// Shutdown stops the Notary module.
|
||||
|
@ -214,6 +217,7 @@ func (n *Notary) Shutdown() {
|
|||
return
|
||||
}
|
||||
close(n.stopCh)
|
||||
<-n.done
|
||||
}
|
||||
|
||||
// OnNewRequest is a callback method which is called after a new notary request is added to the notary request pool.
|
||||
|
|
Loading…
Reference in a new issue