Redirect validation window status to logrus instead of stdout

This commit is contained in:
Edvard 2019-01-31 15:55:28 +01:00
parent d7dde86942
commit 8eea1b00ed
3 changed files with 6 additions and 7 deletions

View File

@ -15,7 +15,6 @@
package cmd
import (
"os"
"time"
log "github.com/sirupsen/logrus"
@ -85,7 +84,7 @@ func lightSync() {
if err != nil {
log.Error("ValidateHeaders failed in lightSync: ", err)
}
window.Log(os.Stdout)
log.Info(window.GetString())
case n := <-missingBlocksPopulated:
if n == 0 {
time.Sleep(3 * time.Second)

View File

@ -15,7 +15,6 @@
package cmd
import (
"os"
"time"
log "github.com/sirupsen/logrus"
@ -85,7 +84,7 @@ func sync() {
select {
case <-ticker.C:
window := validator.ValidateBlocks()
window.Log(os.Stdout)
log.Info(window.GetString())
case <-missingBlocksPopulated:
go backFillAllBlocks(blockChain, blockRepository, missingBlocksPopulated, startingBlockNumber)
}

View File

@ -1,8 +1,8 @@
package history
import (
"fmt"
"github.com/vulcanize/vulcanizedb/pkg/core"
"io"
"text/template"
)
@ -36,6 +36,7 @@ func MakeRange(min, max int64) []int64 {
return a
}
func (window ValidationWindow) Log(out io.Writer) {
ParsedWindowTemplate.Execute(out, window)
func (window ValidationWindow) GetString() string {
return fmt.Sprintf("Validating Blocks |%v|-- Validation Window --|%v}|",
window.LowerBound, window.UpperBound)
}