This commit is contained in:
Roy Crihfield 2020-11-25 18:25:25 +08:00
parent ab841a9abe
commit 83c3583355
2 changed files with 5 additions and 7 deletions

View File

@ -242,6 +242,7 @@ var AppHelpFlagGroups = []flags.FlagGroup{
utils.StateDiffDBNodeIDFlag, utils.StateDiffDBNodeIDFlag,
utils.StateDiffDBClientNameFlag, utils.StateDiffDBClientNameFlag,
utils.StateDiffWritingFlag, utils.StateDiffWritingFlag,
utils.StateDiffWorkersFlag,
}, },
}, },
{ {

View File

@ -276,11 +276,11 @@ func (sds *Service) writeLoopWorker(params workerParams) {
// TODO: how to handle with concurrent workers // TODO: how to handle with concurrent workers
statediffMetrics.lastStatediffHeight.Update(int64(currentBlock.Number().Uint64())) statediffMetrics.lastStatediffHeight.Update(int64(currentBlock.Number().Uint64()))
case err := <-params.errCh: case err := <-params.errCh:
log.Warn("Error from chain event subscription", "error", err) log.Warn("Error from chain event subscription", "error", err, "worker", params.id)
sds.close() sds.close()
return return
case <-sds.QuitChan: case <-sds.QuitChan:
log.Info("Quitting the statediff writing process") log.Info("Quitting the statediff writing process", "worker", params.id)
sds.close() sds.close()
return return
} }
@ -480,11 +480,8 @@ func (sds *Service) Unsubscribe(id rpc.ID) error {
func (sds *Service) Start() error { func (sds *Service) Start() error {
log.Info("Starting statediff service") log.Info("Starting statediff service")
{
// TODO: also use worker pool here?
chainEventCh := make(chan core.ChainEvent, chainEventChanSize) chainEventCh := make(chan core.ChainEvent, chainEventChanSize)
go sds.Loop(chainEventCh) go sds.Loop(chainEventCh)
}
if sds.enableWriteLoop { if sds.enableWriteLoop {
log.Info("Starting statediff DB write loop", "params", writeLoopParams) log.Info("Starting statediff DB write loop", "params", writeLoopParams)