mirror of
https://github.com/QuilibriumNetwork/ceremonyclient.git
synced 2026-02-21 10:27:26 +08:00
Ensure latest frame monotonicity (#350)
This commit is contained in:
parent
5b05ed03d5
commit
f06d2c0ff2
@ -26,6 +26,7 @@ import (
|
||||
qtime "source.quilibrium.com/quilibrium/monorepo/node/consensus/time"
|
||||
qcrypto "source.quilibrium.com/quilibrium/monorepo/node/crypto"
|
||||
"source.quilibrium.com/quilibrium/monorepo/node/execution"
|
||||
"source.quilibrium.com/quilibrium/monorepo/node/internal/cas"
|
||||
"source.quilibrium.com/quilibrium/monorepo/node/keys"
|
||||
"source.quilibrium.com/quilibrium/monorepo/node/p2p"
|
||||
"source.quilibrium.com/quilibrium/monorepo/node/protobufs"
|
||||
@ -413,7 +414,7 @@ func (e *DataClockConsensusEngine) Start() <-chan error {
|
||||
},
|
||||
}
|
||||
|
||||
e.latestFrameReceived = frame.FrameNumber
|
||||
cas.IfLessThanUint64(&e.latestFrameReceived, frame.FrameNumber)
|
||||
e.logger.Info(
|
||||
"preparing peer announce",
|
||||
zap.Uint64("frame_number", frame.FrameNumber),
|
||||
|
||||
@ -8,6 +8,7 @@ import (
|
||||
"github.com/iden3/go-iden3-crypto/poseidon"
|
||||
"go.uber.org/zap"
|
||||
"source.quilibrium.com/quilibrium/monorepo/node/consensus"
|
||||
"source.quilibrium.com/quilibrium/monorepo/node/internal/cas"
|
||||
"source.quilibrium.com/quilibrium/monorepo/node/protobufs"
|
||||
"source.quilibrium.com/quilibrium/monorepo/node/tries"
|
||||
)
|
||||
@ -108,9 +109,7 @@ func (e *DataClockConsensusEngine) processFrame(
|
||||
latestFrame = dataFrame
|
||||
}
|
||||
|
||||
if e.latestFrameReceived < latestFrame.FrameNumber {
|
||||
e.latestFrameReceived = latestFrame.FrameNumber
|
||||
}
|
||||
cas.IfLessThanUint64(&e.latestFrameReceived, latestFrame.FrameNumber)
|
||||
e.frameProverTriesMx.Lock()
|
||||
e.frameProverTries = e.dataTimeReel.GetFrameProverTries()
|
||||
e.frameProverTriesMx.Unlock()
|
||||
|
||||
12
node/internal/cas/cas.go
Normal file
12
node/internal/cas/cas.go
Normal file
@ -0,0 +1,12 @@
|
||||
package cas
|
||||
|
||||
import "sync/atomic"
|
||||
|
||||
// IfLessThanInt64 sets the value of a to lt if the current value of a is less than lt.
|
||||
func IfLessThanUint64(a *uint64, lt uint64) {
|
||||
for val := atomic.LoadUint64(a); val < lt; val = atomic.LoadUint64(a) {
|
||||
if atomic.CompareAndSwapUint64(a, val, lt) {
|
||||
return
|
||||
}
|
||||
}
|
||||
}
|
||||
Loading…
Reference in New Issue
Block a user