remove shutdown and done channels from db and use stop group

This commit is contained in:
Jeffrey Picard 2022-10-15 16:11:06 +00:00
parent 1822fc4064
commit 31e91f67c8
3 changed files with 5 additions and 8 deletions

View file

@ -60,8 +60,6 @@ type ReadOnlyDBColumnFamily struct {
FilteredStreams map[string][]byte
FilteredChannels map[string][]byte
Grp *stop.Group
ShutdownChan chan struct{}
DoneChan chan struct{}
Cleanup func()
}
@ -601,8 +599,7 @@ func GetDBColumnFamilies(name string, secondayPath string, cfNames []string) (*R
LastState: nil,
Height: 0,
Headers: nil,
ShutdownChan: make(chan struct{}, 1),
DoneChan: make(chan struct{}, 1),
Grp: nil,
}
err = myDB.ReadDBState() //TODO: Figure out right place for this
@ -694,8 +691,8 @@ func (db *ReadOnlyDBColumnFamily) RunDetectChanges(notifCh chan<- interface{}) {
log.Infof("Error detecting changes: %#v", err)
}
select {
case <-db.ShutdownChan:
db.DoneChan <- struct{}{}
case <-db.Grp.Ch():
db.Grp.Done()
return
case <-time.After(time.Millisecond * 10):
}

View file

@ -93,8 +93,7 @@ func OpenAndFillTmpDBColumnFamlies(filePath string) (*dbpkg.ReadOnlyDBColumnFami
LastState: nil,
Height: 0,
Headers: nil,
ShutdownChan: make(chan struct{}, 1),
DoneChan: make(chan struct{}, 1),
Grp: nil,
}
// err = dbpkg.ReadDBState(myDB) //TODO: Figure out right place for this

View file

@ -275,6 +275,7 @@ func MakeHubServer(grp *stop.Group, args *Args) *Server {
logrus.Warning(err)
}
myDB.Grp = stop.New(grp)
myDB.Grp.Add(1)
}
// Determine which chain to use based on db and cli values