From 8eea1b00edd9bf3981f180c5781abe711753f863 Mon Sep 17 00:00:00 2001 From: Edvard Date: Thu, 31 Jan 2019 15:55:28 +0100 Subject: [PATCH 1/2] Redirect validation window status to logrus instead of stdout --- cmd/lightSync.go | 3 +-- cmd/sync.go | 3 +-- pkg/history/validation_window.go | 7 ++++--- 3 files changed, 6 insertions(+), 7 deletions(-) diff --git a/cmd/lightSync.go b/cmd/lightSync.go index 630f487f..242d8a1a 100644 --- a/cmd/lightSync.go +++ b/cmd/lightSync.go @@ -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) diff --git a/cmd/sync.go b/cmd/sync.go index bbf51a9c..7c71d091 100644 --- a/cmd/sync.go +++ b/cmd/sync.go @@ -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) } diff --git a/pkg/history/validation_window.go b/pkg/history/validation_window.go index e10253c3..2ca55876 100644 --- a/pkg/history/validation_window.go +++ b/pkg/history/validation_window.go @@ -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) } From a1fa21cbecebb0456ecfb6d2756a41ba903bb1f0 Mon Sep 17 00:00:00 2001 From: Edvard Date: Thu, 31 Jan 2019 16:39:29 +0100 Subject: [PATCH 2/2] Remove test based on window buffer stuff --- pkg/history/validation_window_test.go | 13 ------------- 1 file changed, 13 deletions(-) diff --git a/pkg/history/validation_window_test.go b/pkg/history/validation_window_test.go index 354af33e..246d9168 100644 --- a/pkg/history/validation_window_test.go +++ b/pkg/history/validation_window_test.go @@ -1,8 +1,6 @@ package history_test import ( - "bytes" - . "github.com/onsi/ginkgo" . "github.com/onsi/gomega" @@ -34,15 +32,4 @@ var _ = Describe("Validation window", func() { 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)) - }) })