Skip to content

Commit

Permalink
set EntryDBHeightComplete during entry sync for each sim
Browse files Browse the repository at this point in the history
  • Loading branch information
stackdump committed Nov 26, 2018
1 parent ce8fbf3 commit 1b433d3
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 10 deletions.
11 changes: 10 additions & 1 deletion state/entrySyncing.go
Expand Up @@ -7,6 +7,7 @@ package state
import (
"fmt"
"math/rand"
"os"
"time"

"github.com/FactomProject/factomd/common/constants"
Expand Down Expand Up @@ -168,6 +169,15 @@ func (s *State) MakeMissingEntryRequests() {
}

func (s *State) GoSyncEntries() {

height, err := s.DB.FetchDatabaseEntryHeight()
if err != nil {
os.Stderr.WriteString(fmt.Sprintf("%10s Skipped setting EntryDBHeightComplete - ERROR: %v\n", s.FactomNodeName, err))
} else {
os.Stderr.WriteString(fmt.Sprintf("%10s set EntryDBHeightComplete: %8d\n", s.FactomNodeName, height))
s.EntryDBHeightComplete = height
}

go s.MakeMissingEntryRequests()

// Map to track what I know is missing
Expand Down Expand Up @@ -292,7 +302,6 @@ func (s *State) GoSyncEntries() {
}

if firstMissing < 0 {
//Only save EntryDBHeightComplete IF it's a multiple of 1000 AND there are no missing entries
err := s.DB.SaveDatabaseEntryHeight(s.EntryDBHeightComplete)
if err != nil {
fmt.Printf("ERROR: %v\n", err)
Expand Down
10 changes: 1 addition & 9 deletions state/state.go
Expand Up @@ -547,14 +547,6 @@ func (s *State) Clone(cloneNumber int) interfaces.IState {
os.MkdirAll(path, 0775)
}

height, err := s.DB.FetchDatabaseEntryHeight()
if err != nil {
os.Stderr.WriteString(fmt.Sprintf("%10s ERROR: %v\n", s.FactomNodeName, err))
} else {
os.Stderr.WriteString(fmt.Sprintf("%10s loaded to %8d\n", s.FactomNodeName, height))
s.EntryDBHeightComplete = height
}

return newState
}

Expand Down Expand Up @@ -871,7 +863,7 @@ func (s *State) Init() {
s.Salt = primitives.Sha(b)
}

salt := fmt.Sprintf("The Instance ID of this node is %s\n", s.Salt.String()[:16])
salt := fmt.Sprintf("The Instance ID of %v node is %s\n", s.FactomNodeName, s.Salt.String()[:16])
fmt.Print(salt)

s.StartDelay = s.GetTimestamp().GetTimeMilli() // We can't start as a leader until we know we are upto date
Expand Down

0 comments on commit 1b433d3

Please sign in to comment.