Skip to content

Commit

Permalink
Merge branch 'rollup_fixes' into rollup_robert_test
Browse files Browse the repository at this point in the history
  • Loading branch information
factom-clay committed May 18, 2018
2 parents 67611f9 + 5333f04 commit 538c88c
Showing 1 changed file with 28 additions and 12 deletions.
40 changes: 28 additions & 12 deletions state/processList.go
Expand Up @@ -104,6 +104,10 @@ type ProcessList struct {
asks chan askRef // Requests to ask for missing messages
adds chan plRef // notices of slots filled in the process list
done chan struct{} // Notice that this DBHeight is done

// debug -- highest nil seen and reported in processlist
nilListMutex sync.Mutex
nilList map[int]int
}

var _ interfaces.IProcessList = (*ProcessList)(nil)
Expand Down Expand Up @@ -843,9 +847,11 @@ func (p *ProcessList) TrimVMList(height uint32, vmIndex int) {
p.VMs[vmIndex].List = p.VMs[vmIndex].List[:height]
p.VMs[vmIndex].HighestAsk = int(height) // make sure we will ask again for nil's above this height
if p.State.DebugExec() {
if nillist[vmIndex] > int(height-1) {
nillist[vmIndex] = int(height - 1) // Drag the highest nil logged back before this nil
p.nilListMutex.Lock()
if p.nilList[vmIndex] > int(height-1) {
p.nilList[vmIndex] = int(height - 1) // Drag the highest nil logged back before this nil
}
p.nilListMutex.Unlock()
}
}
}
Expand Down Expand Up @@ -920,8 +926,6 @@ func (p *ProcessList) decodeState(Syncing bool, DBSig bool, EOM bool, DBSigDone

}

var nillist map[int]int = make(map[int]int)

var extraDebug bool = false

// Process messages and update our state.
Expand Down Expand Up @@ -976,10 +980,12 @@ func (p *ProcessList) Process(state *State) (progress bool) {
}
}
if p.State.DebugExec() {
if nillist[i] < j {
p.nilListMutex.Lock()
if p.nilList[i] < j {
p.State.LogPrintf("process", "%d nils at %v/%v/%v", cnt, p.DBHeight, i, j)
nillist[i] = j
p.nilList[i] = j
}
p.nilListMutex.Unlock()
}

// p.State.LogPrintf("process","nil at %v/%v/%v", p.DBHeight, i, j)
Expand All @@ -1002,9 +1008,11 @@ func (p *ProcessList) Process(state *State) (progress bool) {
vm.List[j] = nil
vm.HighestAsk = j // have to be able to ask for this again
if p.State.DebugExec() {
if nillist[i] > j-1 {
nillist[i] = j - 1 // Drag the highest nil logged back before this nil
p.nilListMutex.Lock()
if p.nilList[i] > j-1 {
p.nilList[i] = j - 1 // Drag the highest nil logged back before this nil
}
p.nilListMutex.Unlock()
}
//p.State.AddStatus(fmt.Sprintf("ProcessList.go Process: Error computing serial hash at dbht: %d vm %d vm-height %d ", p.DBHeight, i, j))
p.Ask(i, uint32(j), 3000) // 3 second delay
Expand Down Expand Up @@ -1050,9 +1058,11 @@ func (p *ProcessList) Process(state *State) (progress bool) {
vm.List[j] = nil // If we have seen this message, we don't process it again. Ever.
vm.HighestAsk = j // have to be able to ask for this again
if p.State.DebugExec() {
if nillist[i] > j-1 {
nillist[i] = j - 1 // Drag the highest nil logged back before this nil
p.nilListMutex.Lock()
if p.nilList[i] > j-1 {
p.nilList[i] = j - 1 // Drag the highest nil logged back before this nil
}
p.nilListMutex.Unlock()
}
p.Ask(i, uint32(j), 3000) // 3 second delay
// If we ask won't we just get the same thing back?
Expand Down Expand Up @@ -1229,8 +1239,11 @@ func (p *ProcessList) AddToProcessList(ack *messages.Ack, m interfaces.IMsg) {
p.VMs[ack.VMIndex].List[ack.Height] = m
p.VMs[ack.VMIndex].ListAck[ack.Height] = ack

delete(nillist, int(ack.Height)) // Notify if this is ever nil again

if p.State.DebugExec() {
p.nilListMutex.Lock()
delete(p.nilList, int(ack.Height)) // Notify if this is ever nil again
p.nilListMutex.Unlock()
}
p.AddOldMsgs(m)
p.OldAcks[msgHash.Fixed()] = ack

Expand Down Expand Up @@ -1440,6 +1453,9 @@ func NewProcessList(state interfaces.IState, previous *ProcessList, dbheight uin
pl.adds = nil
pl.done = nil
}

pl.nilList = make(map[int]int)

return pl
}

Expand Down

0 comments on commit 538c88c

Please sign in to comment.