Commit 86e0d815 authored by vicotor's avatar vicotor

update sync

parent 6e9e1227
......@@ -60,7 +60,7 @@ func (s *ChainSync) loop() {
var latestHeight int64
var beginHeight = finishedHeight + 1
var endHeight = beginHeight + int64(s.chain.BatchBlock)
log.WithField("chain", s.name).WithField("begin height", beginHeight).Info("last validator block height")
tm := time.NewTicker(time.Second)
......@@ -69,9 +69,12 @@ func (s *ChainSync) loop() {
for {
select {
case <-s.quit:
log.WithField("chain", s.name).Info("chain sync stopped")
return
case <-tm.C:
var endHeight = beginHeight + int64(s.chain.BatchBlock)
latestHeight, err = s.d.GetBlockHeight(s.chain, s.chain.BehindBlock)
if err != nil {
log.WithField("chain", s.name).WithError(err).Error("get latest block height")
......@@ -96,15 +99,14 @@ func (s *ChainSync) loop() {
if err = s.d.SetStorageHeight(s.heightKey, endHeight); err != nil {
log.WithField("chain", s.name).WithError(err).Error("set last block height")
}
beginHeight = endHeight + 1
endHeight = beginHeight + int64(s.chain.BatchBlock)
log.WithField("chain", s.name).WithFields(log.Fields{
"begin height": beginHeight,
"end height": endHeight,
"latest height": latestHeight,
"diff height": latestHeight - endHeight,
}).Info("validator block")
beginHeight = endHeight + 1
}
}
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment