Merge pull request #7 from vulcanize/VDB-347-Squelch-lightSync

VDB-347 Squelch lightSync in stdout
This commit is contained in:
Edvard Hübinette 2019-02-01 11:02:48 +01:00 committed by GitHub
commit 29f2537130
4 changed files with 6 additions and 20 deletions

View File

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

View File

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

View File

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

View File

@ -17,8 +17,6 @@
package history_test package history_test
import ( import (
"bytes"
. "github.com/onsi/ginkgo" . "github.com/onsi/ginkgo"
. "github.com/onsi/gomega" . "github.com/onsi/gomega"
@ -50,15 +48,4 @@ var _ = Describe("Validation window", func() {
Expect(numberOfBlocksCreated).To(Equal(expected)) Expect(numberOfBlocksCreated).To(Equal(expected))
}) })
It("logs window message", func() {
expectedMessage := &bytes.Buffer{}
window := history.ValidationWindow{LowerBound: 5, UpperBound: 7}
history.ParsedWindowTemplate.Execute(expectedMessage, window)
actualMessage := &bytes.Buffer{}
window.Log(actualMessage)
Expect(actualMessage).To(Equal(expectedMessage))
})
}) })