Added Init state. Recreate exit and advertise channels when recovering

In order to differentiate between intialized and other states we
introduced a new state: Init. The router is in this state only when it's
created.

We have cleaned up router status management which is now handled by
manageStatus function only.
This commit is contained in:
Milos Gajdos
2019-06-29 00:46:22 +01:00
parent 32300eadc1
commit cff46c3fd8
2 changed files with 138 additions and 102 deletions

View File

@@ -56,8 +56,10 @@ type Status struct {
}
const (
// Running means the rotuer is running
Running StatusCode = iota
// Init means the rotuer has just been initialized
Init StatusCode = iota
// Running means the router is running
Running
// Error means the router has crashed with error
Error
// Stopped means the router has stopped
@@ -67,6 +69,8 @@ const (
// String returns human readable status code
func (sc StatusCode) String() string {
switch sc {
case Init:
return "INITIALIZED"
case Running:
return "RUNNING"
case Error: