mirror of
https://source.quilibrium.com/quilibrium/ceremonyclient.git
synced 2024-12-24 23:55: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")
|
e.logger.Info("no peers available for sync, waiting")
|
||||||
time.Sleep(5 * time.Second)
|
time.Sleep(5 * time.Second)
|
||||||
} else if maxFrame > latest.FrameNumber {
|
} 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)
|
latest, err = e.sync(latest, maxFrame, peerId)
|
||||||
if err == nil {
|
if err == nil {
|
||||||
break
|
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
|
return nil
|
||||||
}
|
}
|
||||||
|
@ -31,6 +31,12 @@ func (e *CeremonyDataClockConsensusEngine) GetDataFrame(
|
|||||||
var err error
|
var err error
|
||||||
if request.FrameNumber == 0 {
|
if request.FrameNumber == 0 {
|
||||||
frame, err = e.dataTimeReel.Head()
|
frame, err = e.dataTimeReel.Head()
|
||||||
|
if frame.FrameNumber == 0 {
|
||||||
|
return nil, errors.Wrap(
|
||||||
|
errors.New("not currently syncable"),
|
||||||
|
"get data frame",
|
||||||
|
)
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
frame, _, err = e.clockStore.GetDataClockFrame(
|
frame, _, err = e.clockStore.GetDataClockFrame(
|
||||||
e.filter,
|
e.filter,
|
||||||
|
Loading…
Reference in New Issue
Block a user