mirror of
https://source.quilibrium.com/quilibrium/ceremonyclient.git
synced 2024-12-26 16:45:18 +00:00
fix: resync can happen again if distance is significant
This commit is contained in:
parent
b0a755cdc3
commit
53a19f3f23
@ -87,6 +87,7 @@ type CeremonyDataClockConsensusEngine struct {
|
||||
peerAnnounceMap map[string]*protobufs.CeremonyPeerListAnnounce
|
||||
peerMap map[string]*peerInfo
|
||||
activeChannelsMap map[string]ChannelServer
|
||||
fullResync bool
|
||||
}
|
||||
|
||||
var _ consensus.DataConsensusEngine = (*CeremonyDataClockConsensusEngine)(nil)
|
||||
|
@ -885,6 +885,7 @@ func (e *CeremonyDataClockConsensusEngine) collect(
|
||||
zap.String("peer_id", peer.ID(peerId).String()),
|
||||
)
|
||||
|
||||
willPerformFullResync := false
|
||||
cc, err := e.pubSub.GetDirectChannel(peerId)
|
||||
if err != nil {
|
||||
e.logger.Error(
|
||||
@ -895,7 +896,7 @@ func (e *CeremonyDataClockConsensusEngine) collect(
|
||||
from := latest.FrameNumber
|
||||
if from == 0 {
|
||||
from = 1
|
||||
} else if maxFrame-from > 32 {
|
||||
} else if maxFrame-from > 32 && !e.fullResync {
|
||||
// divergence is high, we need to confirm we're not in a fork
|
||||
from = 1
|
||||
latest, _, err = e.clockStore.GetDataClockFrame(e.filter, 0)
|
||||
@ -907,6 +908,7 @@ func (e *CeremonyDataClockConsensusEngine) collect(
|
||||
)
|
||||
panic(err)
|
||||
}
|
||||
willPerformFullResync = true
|
||||
}
|
||||
|
||||
client := protobufs.NewCeremonyServiceClient(cc)
|
||||
@ -946,6 +948,10 @@ func (e *CeremonyDataClockConsensusEngine) collect(
|
||||
if err := cc.Close(); err != nil {
|
||||
e.logger.Error("error while closing connection", zap.Error(err))
|
||||
}
|
||||
|
||||
if willPerformFullResync {
|
||||
e.fullResync = true
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user