Move time triggered synchronization to dedicated goroutine (#359)

This commit is contained in:
petricadaipegsp 2024-11-17 09:18:55 +01:00 committed by GitHub
parent 889fcac721
commit 0b499c649c
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -50,6 +50,17 @@ func (e *DataClockConsensusEngine) runSync() {
if _, err := e.collect(enqueuedFrame); err != nil {
e.logger.Error("could not collect", zap.Error(err))
}
case <-time.After(20 * time.Second):
if e.GetFrameProverTries()[0].Contains(e.provingKeyAddress) {
continue
}
head, err := e.dataTimeReel.Head()
if err != nil {
panic(err)
}
if _, err := e.collect(head); err != nil {
e.logger.Error("could not collect", zap.Error(err))
}
}
}
}
@ -84,6 +95,8 @@ func (e *DataClockConsensusEngine) runLoop() {
}
select {
case <-e.ctx.Done():
return
case dataFrame := <-dataFrameCh:
if e.GetFrameProverTries()[0].Contains(e.provingKeyAddress) {
if err = e.publishProof(dataFrame); err != nil {
@ -95,17 +108,6 @@ func (e *DataClockConsensusEngine) runLoop() {
e.stateMx.Unlock()
}
}
latestFrame = e.processFrame(latestFrame, dataFrame)
case <-time.After(20 * time.Second):
if e.GetFrameProverTries()[0].Contains(e.provingKeyAddress) {
continue
}
dataFrame, err := e.dataTimeReel.Head()
if err != nil {
panic(err)
}
latestFrame = e.processFrame(latestFrame, dataFrame)
}
}