Skip to content

Commit

Permalink
Merge pull request #379 from FactomProject/FD-313
Browse files Browse the repository at this point in the history
FD-313 Entry Key
  • Loading branch information
carryforward committed Dec 21, 2017
2 parents fd07354 + febdd4f commit 12009e2
Show file tree
Hide file tree
Showing 3 changed files with 41 additions and 3 deletions.
11 changes: 10 additions & 1 deletion Utilities/DatabaseIntegrityCheck/DatabaseIntegrityCheck.go
Expand Up @@ -287,13 +287,22 @@ func CheckDatabase(dbo interfaces.DBOverlay) {
if eHash.IsMinuteMarker() == true {
continue
}

entry, err := dbo.FetchEntry(eHash)
if err != nil {
panic(err)
}
if entry == nil {
missingCount++
fmt.Printf("Missing entry %v!\n", eHash.String())
exists, err := dbo.DoesKeyExist(databaseOverlay.ENTRY, eHash.Bytes())
if err != nil {
panic(err)
}
if exists == true {
fmt.Printf("Missing entry %v!, but the key exists\n", eHash.String())
} else {
fmt.Printf("Missing entry %v!\n", eHash.String())
}
} else {
checkCount++
}
Expand Down
7 changes: 7 additions & 0 deletions engine/NetStart.go
Expand Up @@ -218,6 +218,13 @@ func NetStart(s *state.State, p *FactomParams, listenToStdin bool) {

if p.Sync2 >= 0 {
s.EntryDBHeightComplete = uint32(p.Sync2)
} else {
height, err := s.DB.FetchDatabaseEntryHeight()
if err != nil {
os.Stderr.WriteString(fmt.Sprintf("ERROR: %v", err))
} else {
s.EntryDBHeightComplete = height
}
}

mLog.Init(p.RuntimeLog, p.Cnt)
Expand Down
26 changes: 24 additions & 2 deletions state/entrySyncing.go
Expand Up @@ -6,7 +6,6 @@ package state

import (
"fmt"

"math/rand"
"time"

Expand All @@ -24,7 +23,16 @@ func has(s *State, entry interfaces.IHash) bool {
time.Sleep(30 * time.Millisecond)
}
}
exists, _ := s.DB.DoesKeyExist(databaseOverlay.ENTRY, entry.Bytes())
exists, err := s.DB.DoesKeyExist(databaseOverlay.ENTRY, entry.Bytes())
if exists {
if err != nil {
return false
}
entry, err2 := s.DB.FetchEntry(entry)
if err2 != nil || entry == nil {
return false
}
}
return exists
}

Expand Down Expand Up @@ -177,6 +185,8 @@ func (s *State) GoSyncEntries() {

lastfirstmissing := 0

found := 0

for {

ESMissing.Set(float64(len(missingMap)))
Expand All @@ -189,6 +199,7 @@ func (s *State) GoSyncEntries() {

for k := range missingMap {
if has(s, missingMap[k]) {
found++
delete(missingMap, k)
}
}
Expand Down Expand Up @@ -247,6 +258,7 @@ func (s *State) GoSyncEntries() {

// If I have the entry, then remove it from the Missing Entries list.
if has(s, entryhash) {
found++
delete(missingMap, entryhash.Fixed())
continue
}
Expand Down Expand Up @@ -276,6 +288,16 @@ func (s *State) GoSyncEntries() {
}
}
}

if s.EntryDBHeightComplete%1000 == 0 {
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)
}
}
}
}
lastfirstmissing = firstMissing
if firstMissing < 0 {
Expand Down

0 comments on commit 12009e2

Please sign in to comment.