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")
+ log.WithFields(log.Fields{"module": logModule, "err": err}).Error("finish jobs")
} else if ok {
break
}
}
if ok, err := t.tryAttach(jobs); err != nil {
- log.WithField("err", err).Error("try attach on trace scheduler")
+ log.WithFields(log.Fields{"module": logModule, "err": err}).Error("try attach on trace scheduler")
} else if !ok {
if err := t.detach(jobs); err != nil {
- log.WithField("err", err).Error("detach on trace scheduler")
+ log.WithFields(log.Fields{"module": logModule, "err": err}).Error("detach on trace scheduler")
}
}
}
"errors"
"sync"
- "github.com/sirupsen/logrus"
+ log "github.com/sirupsen/logrus"
"github.com/bytom/bytom/protocol/bc"
"github.com/bytom/bytom/protocol/bc/types"
func NewTraceService(infra *Infrastructure) *TraceService {
allInstances, err := infra.Repository.LoadInstances()
if err != nil {
- logrus.WithField("err", err).Fatal("load instances from db")
+ log.WithFields(log.Fields{"module": logModule, "err": err}).Fatal("load instances from db")
}
chainStatus := infra.Repository.GetChainStatus()
bestHeight, bestHash := infra.Chain.BestChain()
chainStatus = &ChainStatus{BlockHeight: bestHeight, BlockHash: bestHash}
if err := infra.Repository.SaveChainStatus(chainStatus); err != nil {
- logrus.WithField("err", err).Fatal("init chain status for trace service")
+ log.WithFields(log.Fields{"module": logModule, "err": err}).Fatal("init chain status for trace service")
}
}
}
} else if inst.Status == Lagging {
if err := scheduler.addNewJob(inst); err != nil {
- logrus.WithField("err", err).Fatal("add new job when init tracer")
+ log.WithFields(log.Fields{"module": logModule, "err": err}).Fatal("add new job when init tracer")
}
}
}
}
if err := t.infra.Repository.SaveInstances(instances); err != nil {
- logrus.WithField("err", err).Error("save instances when take over instances")
+ log.WithFields(log.Fields{"module": logModule, "err": err}).Error("save instances when take over instances")
return false
}
import (
"encoding/json"
+ log "github.com/sirupsen/logrus"
+
dbm "github.com/bytom/bytom/database/leveldb"
"github.com/bytom/bytom/protocol/bc"
- "github.com/sirupsen/logrus"
)
const (
chainStatus := &ChainStatus{}
if err := json.Unmarshal(data, chainStatus); err != nil {
- logrus.WithField("err", err).Fatal("get chain status from trace store")
+ log.WithFields(log.Fields{"module": logModule, "err": err}).Fatal("get chain status from trace store")
}
return chainStatus
block, err := t.chain.GetBlockByHash(&bestHash)
if err != nil {
log.WithFields(log.Fields{"module": logModule, "err": err, "block_hash": bestHash.String()}).Errorf("trace updater get block")
- return
+ break
}
if err := t.DetachBlock(block); err != nil {
log.WithFields(log.Fields{"module": logModule, "err": err}).Error("trace updater detach block")
- return
+ break
}
} else {
if err := t.ApplyBlock(block); err != nil {
log.WithFields(log.Fields{"module": logModule, "err": err}).Error("trace updater attach block")
- return
+ break
}
}
}