Skip to content

Commit

Permalink
tweeked the flag handling for readytosave
Browse files Browse the repository at this point in the history
  • Loading branch information
factom-clay committed May 8, 2019
1 parent 2632e8a commit 36e1d65
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 9 deletions.
4 changes: 2 additions & 2 deletions engine/factomd_test.go
Expand Up @@ -132,9 +132,9 @@ func TestLoad(t *testing.T) {
RanSimTest = true

// use a tree so the messages get reordered
state0 := SetupSim("LLF", map[string]string{"--debuglog": ""}, 15, 0, 0, t)
state0 := SetupSim("LFF", map[string]string{"--debuglog": ""}, 15, 0, 0, t)

RunCmd("2") // select 2
// RunCmd("2") // select 2
RunCmd("R30") // Feed load
WaitBlocks(state0, 10)
RunCmd("R0") // Stop load
Expand Down
16 changes: 9 additions & 7 deletions state/stateConsensus.go
Expand Up @@ -747,8 +747,17 @@ func (s *State) MoveStateToHeight(dbheight uint32, newMinute int) {
if s.Leader && !s.LeaderPL.DBSigAlreadySent {
s.SendDBSig(s.LLeaderHeight, s.LeaderVMIndex) // MoveStateToHeight()
}
s.DBStates.UpdateState() // call to get the state signed now that the DBSigs have processed

} else if s.CurrentMinute != newMinute { // And minute
if newMinute == 1 {
dbstate := s.GetDBState(dbheight - 1)
if dbstate != nil && !dbstate.Saved {
s.LogPrintf("dbstateprocess", "Set ReadyToSave %d", dbstate.DirectoryBlock.GetHeader().GetDBHeight())
dbstate.ReadyToSave = true
}
s.DBStates.UpdateState() // call to get the state signed now that the DBSigs have processed
}
s.CurrentMinute = newMinute // Update just the minute
s.Leader, s.LeaderVMIndex = s.LeaderPL.GetVirtualServers(newMinute, s.IdentityChainID) // MoveStateToHeight minute
// We are between blocks make sure we are setup to sync
Expand All @@ -761,9 +770,6 @@ func (s *State) MoveStateToHeight(dbheight uint32, newMinute int) {
s.LeaderPL.SortAuditServers()
s.LeaderPL.SortFedServers()

if newMinute == 1 {
defer s.DBStates.UpdateState()
}
}

{ // debug
Expand Down Expand Up @@ -2015,16 +2021,12 @@ func (s *State) ProcessEOM(dbheight uint32, msg interfaces.IMsg) bool {
switch {
case s.CurrentMinute < 10:
if s.CurrentMinute == 1 {
dbstate := s.GetDBState(dbheight - 1)
// Panic had arose when leaders would reboot and the follower was on a future minute
if dbstate == nil {
// We recognize that this will leave us "Done" without finishing the process. But
// a Follower can heal themselves by asking for a block, and overwriting this block.
return false
}
if !dbstate.Saved {
dbstate.ReadyToSave = true
}
}
LeaderPL := s.ProcessLists.Get(s.LLeaderHeight)
if s.LeaderPL != LeaderPL {
Expand Down

0 comments on commit 36e1d65

Please sign in to comment.