Server endpoints goroutine refactor #69
3 changed files with 5 additions and 8 deletions
9
db/db.go
9
db/db.go
|
@ -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):
|
||||
}
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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
|
||||
|
|
Loading…
Reference in a new issue
OpenIterator
s,ItMut
not needed anymore.