mirror of
https://source.quilibrium.com/quilibrium/ceremonyclient.git
synced 2024-11-20 15:15:18 +00:00
small qol items
This commit is contained in:
parent
5afabc401b
commit
286d38e054
@ -41,7 +41,7 @@ func (e *CeremonyDataClockConsensusEngine) publishProof(
|
||||
panic(err)
|
||||
}
|
||||
|
||||
peers, max, err := e.GetMostAheadPeer()
|
||||
peers, max, err := e.GetMostAheadPeer(head.FrameNumber)
|
||||
if err != nil || len(peers) == 0 || head.FrameNumber > max {
|
||||
if err := e.publishMessage(e.filter, frame); err != nil {
|
||||
return errors.Wrap(
|
||||
|
@ -566,6 +566,7 @@ func (e *CeremonyDataClockConsensusEngine) Stop(force bool) <-chan error {
|
||||
wg.Wait()
|
||||
e.logger.Info("execution engines stopped")
|
||||
|
||||
e.dataTimeReel.Stop()
|
||||
e.state = consensus.EngineStateStopped
|
||||
|
||||
e.engineMx.Lock()
|
||||
|
@ -143,24 +143,21 @@ func (e *CeremonyDataClockConsensusEngine) prove(
|
||||
return frame, nil
|
||||
}
|
||||
|
||||
func (e *CeremonyDataClockConsensusEngine) GetMostAheadPeer() (
|
||||
func (e *CeremonyDataClockConsensusEngine) GetMostAheadPeer(
|
||||
frameNumber uint64,
|
||||
) (
|
||||
[]byte,
|
||||
uint64,
|
||||
error,
|
||||
) {
|
||||
frame, err := e.dataTimeReel.Head()
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
|
||||
e.logger.Info(
|
||||
"checking peer list",
|
||||
zap.Int("peers", len(e.peerMap)),
|
||||
zap.Int("uncooperative_peers", len(e.uncooperativePeersMap)),
|
||||
zap.Uint64("current_head_frame", frame.FrameNumber),
|
||||
zap.Uint64("current_head_frame", frameNumber),
|
||||
)
|
||||
|
||||
max := frame.FrameNumber
|
||||
max := frameNumber
|
||||
var peer []byte = nil
|
||||
e.peerMapMx.RLock()
|
||||
for _, v := range e.peerMap {
|
||||
@ -514,7 +511,7 @@ func (e *CeremonyDataClockConsensusEngine) collect(
|
||||
latest := currentFramePublished
|
||||
|
||||
for {
|
||||
peerId, maxFrame, err := e.GetMostAheadPeer()
|
||||
peerId, maxFrame, err := e.GetMostAheadPeer(latest.FrameNumber)
|
||||
if maxFrame > latest.FrameNumber {
|
||||
e.syncingStatus = SyncStatusSynchronizing
|
||||
if err != nil {
|
||||
|
@ -325,7 +325,7 @@ func (e *MasterClockConsensusEngine) performBandwidthTest(peerID []byte) {
|
||||
|
||||
cc, err := e.pubSub.GetDirectChannel(peerID, "validation")
|
||||
if err != nil {
|
||||
e.logger.Info(
|
||||
e.logger.Debug(
|
||||
"could not connect to peer for validation",
|
||||
zap.String("peer_id", base58.Encode(peerID)),
|
||||
)
|
||||
@ -348,7 +348,7 @@ func (e *MasterClockConsensusEngine) performBandwidthTest(peerID []byte) {
|
||||
end := time.Now().UnixMilli()
|
||||
if err != nil && err != io.EOF {
|
||||
cc.Close()
|
||||
e.logger.Info(
|
||||
e.logger.Debug(
|
||||
"peer returned error",
|
||||
zap.String("peer_id", base58.Encode(peerID)),
|
||||
zap.Error(err),
|
||||
@ -360,7 +360,7 @@ func (e *MasterClockConsensusEngine) performBandwidthTest(peerID []byte) {
|
||||
cc.Close()
|
||||
|
||||
if !bytes.Equal(verification, validation.Validation) {
|
||||
e.logger.Info(
|
||||
e.logger.Debug(
|
||||
"peer provided invalid verification",
|
||||
zap.String("peer_id", base58.Encode(peerID)),
|
||||
)
|
||||
@ -370,7 +370,7 @@ func (e *MasterClockConsensusEngine) performBandwidthTest(peerID []byte) {
|
||||
}
|
||||
|
||||
if end-start > 2000 {
|
||||
e.logger.Info(
|
||||
e.logger.Debug(
|
||||
"peer has slow bandwidth, scoring out",
|
||||
zap.String("peer_id", base58.Encode(peerID)),
|
||||
)
|
||||
|
@ -458,11 +458,11 @@ func (e *CeremonyExecutionEngine) Start() <-chan error {
|
||||
}
|
||||
|
||||
// Stop implements ExecutionEngine
|
||||
func (*CeremonyExecutionEngine) Stop(force bool) <-chan error {
|
||||
func (e *CeremonyExecutionEngine) Stop(force bool) <-chan error {
|
||||
errChan := make(chan error)
|
||||
|
||||
go func() {
|
||||
errChan <- nil
|
||||
errChan <- <-e.clock.Stop(force)
|
||||
}()
|
||||
|
||||
return errChan
|
||||
|
@ -1251,6 +1251,21 @@ func (p *PebbleClockStore) Compact(
|
||||
); err != nil {
|
||||
return errors.Wrap(err, "compact")
|
||||
}
|
||||
|
||||
if err := p.db.DeleteRange(
|
||||
clockDataParentIndexKey(
|
||||
make([]byte, 32),
|
||||
0,
|
||||
make([]byte, 32),
|
||||
),
|
||||
clockDataParentIndexKey(
|
||||
bytes.Repeat([]byte{0xff}, 32),
|
||||
0,
|
||||
bytes.Repeat([]byte{0xff}, 32),
|
||||
),
|
||||
); err != nil {
|
||||
return errors.Wrap(err, "compact")
|
||||
}
|
||||
}
|
||||
|
||||
if dataFilter != nil && !cleared {
|
||||
|
@ -78,7 +78,7 @@ func (p *PebbleDB) CompactAll() error {
|
||||
return errors.Wrap(err, "compact all")
|
||||
}
|
||||
|
||||
if err := p.Compact(first, last, true); err != nil {
|
||||
if err := p.Compact(first, last, false); err != nil {
|
||||
return errors.Wrap(err, "compact all")
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user