mirror of
https://source.quilibrium.com/quilibrium/ceremonyclient.git
synced 2024-11-20 15:15:18 +00:00
qol: div-by-zero fix, minor patch on sync (#155)
This commit is contained in:
parent
f05bb62d63
commit
e92af02122
@ -269,6 +269,22 @@ func (e *CeremonyDataClockConsensusEngine) collect(
|
||||
e.logger.Info("no peers available for sync, waiting")
|
||||
time.Sleep(5 * time.Second)
|
||||
} else if maxFrame > latest.FrameNumber {
|
||||
masterHead, err := e.masterTimeReel.Head()
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
|
||||
if masterHead.FrameNumber < maxFrame {
|
||||
e.logger.Info(
|
||||
"master frame synchronization needed to continue, waiting",
|
||||
zap.Uint64("master_frame_head", masterHead.FrameNumber),
|
||||
zap.Uint64("max_data_frame_target", maxFrame),
|
||||
)
|
||||
|
||||
time.Sleep(30 * time.Second)
|
||||
continue
|
||||
}
|
||||
|
||||
latest, err = e.sync(latest, maxFrame, peerId)
|
||||
if err == nil {
|
||||
break
|
||||
|
@ -347,6 +347,14 @@ func (e *CeremonyDataClockConsensusEngine) handleClockFrameData(
|
||||
}
|
||||
}()
|
||||
}
|
||||
e.dataTimeReel.Insert(frame, e.latestFrameReceived < frame.FrameNumber)
|
||||
|
||||
head, err := e.dataTimeReel.Head()
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
|
||||
if frame.FrameNumber > head.FrameNumber {
|
||||
e.dataTimeReel.Insert(frame, e.latestFrameReceived < frame.FrameNumber)
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
@ -31,6 +31,12 @@ func (e *CeremonyDataClockConsensusEngine) GetDataFrame(
|
||||
var err error
|
||||
if request.FrameNumber == 0 {
|
||||
frame, err = e.dataTimeReel.Head()
|
||||
if frame.FrameNumber == 0 {
|
||||
return nil, errors.Wrap(
|
||||
errors.New("not currently syncable"),
|
||||
"get data frame",
|
||||
)
|
||||
}
|
||||
} else {
|
||||
frame, _, err = e.clockStore.GetDataClockFrame(
|
||||
e.filter,
|
||||
|
Loading…
Reference in New Issue
Block a user