Skip to content

Commit

Permalink
Merge pull request #844 from FactomProject/FD-1169_merge_save_state_f…
Browse files Browse the repository at this point in the history
…ix_to_v6.4.0

FD-1169 Allow DBsigs that are created before boot time to be valid
  • Loading branch information
carryforward committed Aug 23, 2019
2 parents 571b4da + 433def0 commit 3c29962
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 4 deletions.
7 changes: 6 additions & 1 deletion engine/factomd.go
Expand Up @@ -59,7 +59,12 @@ func Factomd(params *FactomParams, listenToStdin bool) interfaces.IState {
state0.FactomNodeName = state0.Prefix + "FNode0"
state0.TimestampAtBoot = primitives.NewTimestampNow()
state0.SetLeaderTimestamp(state0.TimestampAtBoot)
state0.SetMessageFilterTimestamp(state0.TimestampAtBoot)

// build a timestamp 20 minutes before boot so we will accept messages from nodes who booted before us.
preBootTime := new(primitives.Timestamp)
preBootTime.SetTimeMilli(state0.TimestampAtBoot.GetTimeMilli() - 20*60*1000)
state0.SetMessageFilterTimestamp(preBootTime)

state0.EFactory = new(electionMsgs.ElectionsFactory)

NetStart(state0, params, listenToStdin)
Expand Down
10 changes: 7 additions & 3 deletions state/state.go
Expand Up @@ -2236,7 +2236,7 @@ func (s *State) GetMessageFilterTimestamp() interfaces.Timestamp {
}

// the MessageFilterTimestamp is used to filter messages from the past or before the replay filter.
// We will not set it to a time that is before boot or more than one hour in the past.
// We will not set it to a time that is before (20 minutes before) boot or more than one hour in the past.
// this ensure messages from prior boot and messages that predate the current replay filter are
// are dropped.
// It marks the start of the replay filter content
Expand All @@ -2253,8 +2253,12 @@ func (s *State) SetMessageFilterTimestamp(leaderTS interfaces.Timestamp) {
requestedTS.SetTimestamp(onehourago)
}

if requestedTS.GetTimeMilli() < s.TimestampAtBoot.GetTimeMilli() {
requestedTS.SetTimestamp(s.TimestampAtBoot)
// build a timestamp 20 minutes before boot so we will accept messages from nodes who booted before us.
preBootTime := new(primitives.Timestamp)
preBootTime.SetTimeMilli(s.TimestampAtBoot.GetTimeMilli() - 20*60*1000)

if requestedTS.GetTimeMilli() < preBootTime.GetTimeMilli() {
requestedTS.SetTimestamp(preBootTime)
}

if s.MessageFilterTimestamp != nil && requestedTS.GetTimeMilli() < s.MessageFilterTimestamp.GetTimeMilli() {
Expand Down

0 comments on commit 3c29962

Please sign in to comment.