Skip to content

Commit

Permalink
DualAckPostElection Fix
Browse files Browse the repository at this point in the history
  • Loading branch information
factom-clay committed May 14, 2019
1 parent 07ccec3 commit aed1e9e
Show file tree
Hide file tree
Showing 2 changed files with 39 additions and 9 deletions.
11 changes: 10 additions & 1 deletion state/processList.go
Expand Up @@ -845,7 +845,16 @@ func (p *ProcessList) Process(s *State) (progress bool) {

s.LogPrintf("process", "expected %x", expectedSerialHash.Bytes())
s.LogPrintf("process", "thisAck %x", thisAck.SerialHash.Bytes())
s.Reset() // This currently does nothing.. see comments in reset

vm.List[j] = nil
if vm.HighestNil > j {
vm.HighestNil = j // Drag report limit back
}
if vm.HighestAsk > j {
vm.HighestAsk = j // Drag Ask limit back
}
//s.AddStatus(fmt.Sprintf("ProcessList.go Process: Error computing serial hash at dbht: %d vm %d vm-height %d ", p.DBHeight, i, j))
vm.ReportMissing(j, 0)
//todo: report this... it's probably bad
return
}
Expand Down
37 changes: 29 additions & 8 deletions state/safeMsgMap.go
Expand Up @@ -12,6 +12,9 @@ import (

var _ = fmt.Println

var SafeMapLog bool = false
var SafeMapDetailLog bool = false

// SafeMsgMap is a threadsafe map[[32]byte]interfaces.IMsg
type SafeMsgMap struct {
msgmap map[[32]byte]interfaces.IMsg
Expand All @@ -38,7 +41,11 @@ func (m *SafeMsgMap) Put(key [32]byte, msg interfaces.IMsg) {
m.Lock()
_, ok := m.msgmap[key]
if !ok {
defer m.s.LogMessage(m.name, "put", msg)
if SafeMapLog {
defer m.s.LogMessage(m.name, "put", msg)
}
} else if SafeMapDetailLog {
defer m.s.LogMessage(m.name, "re-put", msg)
}
m.msgmap[key] = msg
m.Unlock()
Expand All @@ -48,10 +55,14 @@ func (m *SafeMsgMap) Delete(key [32]byte) (msg interfaces.IMsg, found bool) {
m.Lock()
msg, ok := m.msgmap[key] // return the message being deleted
if ok {
defer m.s.LogMessage(m.name, fmt.Sprintf("delete from %s", atomic.WhereAmIString(1)), msg)
if SafeMapLog {
defer m.s.LogMessage(m.name, fmt.Sprintf("delete from %s", atomic.WhereAmIString(1)), msg)
}
delete(m.msgmap, key)
} else {
defer m.s.LogPrintf(m.name, "nodelete from %s M-%x", atomic.WhereAmIString(1), key[:3])
if SafeMapDetailLog {
defer m.s.LogPrintf(m.name, "nodelete from %s M-%x", atomic.WhereAmIString(1), key[:3])
}
}
m.Unlock()
return
Expand Down Expand Up @@ -82,7 +93,9 @@ func (m *SafeMsgMap) Reset() {
m.msgmap = make(map[[32]byte]interfaces.IMsg)
}
m.Unlock()
m.s.LogPrintf(m.name, "reset")
if SafeMapLog {
m.s.LogPrintf(m.name, "reset")
}
}

//
Expand All @@ -100,7 +113,9 @@ func (m *SafeMsgMap) Cleanup(s *State) {
if ok && !s.NoEntryYet(cc.CommitChain.EntryHash, now) {
msg, ok := m.msgmap[k]
if ok {
defer m.s.LogMessage(m.name, "cleanup_chain", msg)
if SafeMapLog {
defer m.s.LogMessage(m.name, "cleanup_chain", msg)
}
}
delete(m.msgmap, k)
continue
Expand All @@ -110,7 +125,9 @@ func (m *SafeMsgMap) Cleanup(s *State) {
if ok && !s.NoEntryYet(c.CommitEntry.EntryHash, now) {
msg, ok := m.msgmap[k]
if ok {
defer m.s.LogMessage(m.name, "cleanup_entry", msg)
if SafeMapLog {
defer m.s.LogMessage(m.name, "cleanup_entry", msg)
}
}
delete(m.msgmap, k)
continue
Expand All @@ -120,15 +137,19 @@ func (m *SafeMsgMap) Cleanup(s *State) {
if !ok {
msg, ok := m.msgmap[k]
if ok {
defer m.s.LogMessage(m.name, "cleanup_timeout", msg)
if SafeMapLog {
defer m.s.LogMessage(m.name, "cleanup_timeout", msg)
}
}
delete(m.msgmap, k)
}
ok = s.Replay.IsHashUnique(constants.REVEAL_REPLAY, k)
if !ok {
msg, ok := m.msgmap[k]
if ok {
defer m.s.LogMessage(m.name, "cleanup_replay", msg)
if SafeMapLog {
defer m.s.LogMessage(m.name, "cleanup_replay", msg)
}
}
delete(m.msgmap, k)
}
Expand Down

0 comments on commit aed1e9e

Please sign in to comment.