OSDN Git Service

fix init trace service (#2115)
[bytom/bytom.git] / contract / trace_scheduler.go
index e06c2b2..0d3e35c 100644 (file)
@@ -53,10 +53,13 @@ func (t *traceScheduler) processLoop() {
 
        for range ticker.C {
                jobs, beginHeight, beginHash := t.prepareJobs()
+               if beginHeight > t.tracerService.BestHeight() {
+                       continue
+               }
                t.tracer = newTracer(jobs[beginHash])
 
-               for t.currentHeight, t.currentHash = beginHeight, beginHash; len(jobs) != 0 ; {
-                       if bestHeight := t.tracerService.BestHeight(); t.currentHeight == bestHeight {
+               for t.currentHeight, t.currentHash = beginHeight, beginHash; len(jobs) != 0; {
+                       if t.currentHeight == t.tracerService.BestHeight() {
                                if ok, err := t.finishJobs(jobs); err != nil {
                                        log.WithField("err", err).Error("finish jobs")
                                } else if ok {