mirror of
https://source.quilibrium.com/quilibrium/ceremonyclient.git
synced 2024-12-27 00:55:17 +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
|
peerAnnounceMap map[string]*protobufs.CeremonyPeerListAnnounce
|
||||||
peerMap map[string]*peerInfo
|
peerMap map[string]*peerInfo
|
||||||
activeChannelsMap map[string]ChannelServer
|
activeChannelsMap map[string]ChannelServer
|
||||||
|
fullResync bool
|
||||||
}
|
}
|
||||||
|
|
||||||
var _ consensus.DataConsensusEngine = (*CeremonyDataClockConsensusEngine)(nil)
|
var _ consensus.DataConsensusEngine = (*CeremonyDataClockConsensusEngine)(nil)
|
||||||
|
@ -885,6 +885,7 @@ func (e *CeremonyDataClockConsensusEngine) collect(
|
|||||||
zap.String("peer_id", peer.ID(peerId).String()),
|
zap.String("peer_id", peer.ID(peerId).String()),
|
||||||
)
|
)
|
||||||
|
|
||||||
|
willPerformFullResync := false
|
||||||
cc, err := e.pubSub.GetDirectChannel(peerId)
|
cc, err := e.pubSub.GetDirectChannel(peerId)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
e.logger.Error(
|
e.logger.Error(
|
||||||
@ -895,7 +896,7 @@ func (e *CeremonyDataClockConsensusEngine) collect(
|
|||||||
from := latest.FrameNumber
|
from := latest.FrameNumber
|
||||||
if from == 0 {
|
if from == 0 {
|
||||||
from = 1
|
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
|
// divergence is high, we need to confirm we're not in a fork
|
||||||
from = 1
|
from = 1
|
||||||
latest, _, err = e.clockStore.GetDataClockFrame(e.filter, 0)
|
latest, _, err = e.clockStore.GetDataClockFrame(e.filter, 0)
|
||||||
@ -907,6 +908,7 @@ func (e *CeremonyDataClockConsensusEngine) collect(
|
|||||||
)
|
)
|
||||||
panic(err)
|
panic(err)
|
||||||
}
|
}
|
||||||
|
willPerformFullResync = true
|
||||||
}
|
}
|
||||||
|
|
||||||
client := protobufs.NewCeremonyServiceClient(cc)
|
client := protobufs.NewCeremonyServiceClient(cc)
|
||||||
@ -946,6 +948,10 @@ func (e *CeremonyDataClockConsensusEngine) collect(
|
|||||||
if err := cc.Close(); err != nil {
|
if err := cc.Close(); err != nil {
|
||||||
e.logger.Error("error while closing connection", zap.Error(err))
|
e.logger.Error("error while closing connection", zap.Error(err))
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if willPerformFullResync {
|
||||||
|
e.fullResync = true
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user