Merge branch 'dev' into feature/clear-stale-staking-data

feature/dev-engine_test
static 1 year ago
commit 7262b56567
  1. 2
      consensus/consensus.go
  2. 8
      consensus/consensus_service.go
  3. 6
      consensus/consensus_v2.go
  4. 23
      consensus/downloader.go

@ -296,7 +296,7 @@ func New(
// viewID has to be initialized as the height of
// the blockchain during initialization as it was
// displayed on explorer as Height right now
consensus.SetCurBlockViewID(0)
consensus.setCurBlockViewID(0)
consensus.SlashChan = make(chan slash.Record)
consensus.readySignal = make(chan ProposalType)
consensus.commitSigChannel = make(chan []byte)

@ -514,12 +514,14 @@ func (consensus *Consensus) setViewIDs(height uint64) {
// SetCurBlockViewID set the current view ID
func (consensus *Consensus) SetCurBlockViewID(viewID uint64) uint64 {
return consensus.current.SetCurBlockViewID(viewID)
consensus.mutex.Lock()
defer consensus.mutex.Unlock()
return consensus.setCurBlockViewID(viewID)
}
// SetCurBlockViewID set the current view ID
func (consensus *Consensus) setCurBlockViewID(viewID uint64) {
consensus.current.SetCurBlockViewID(viewID)
func (consensus *Consensus) setCurBlockViewID(viewID uint64) uint64 {
return consensus.current.SetCurBlockViewID(viewID)
}
// SetViewChangingID set the current view change ID

@ -323,10 +323,8 @@ func (consensus *Consensus) Start(
consensus.mutex.Unlock()
}()
if consensus.dHelper != nil {
consensus.dHelper.start()
}
}
func (consensus *Consensus) StartChannel() {
consensus.mutex.Lock()
@ -448,10 +446,6 @@ func (consensus *Consensus) BlockChannel(newBlock *types.Block) {
Msg("[ConsensusMainLoop] STARTING CONSENSUS")
consensus.announce(newBlock)
})
if consensus.dHelper != nil {
consensus.dHelper.start()
}
}
// LastMileBlockIter is the iterator to iterate over the last mile blocks in consensus cache.

@ -39,7 +39,7 @@ func newDownloadHelper(c *Consensus, d downloader) *downloadHelper {
finishedCh := make(chan struct{}, 1)
finishedSub := d.SubscribeDownloadFinished(finishedCh)
return &downloadHelper{
out := &downloadHelper{
c: c,
d: d,
startedCh: startedCh,
@ -47,16 +47,12 @@ func newDownloadHelper(c *Consensus, d downloader) *downloadHelper {
startedSub: startedSub,
finishedSub: finishedSub,
}
go out.downloadStartedLoop()
go out.downloadFinishedLoop()
return out
}
func (dh *downloadHelper) start() {
go dh.downloadStartedLoop()
go dh.downloadFinishedLoop()
}
func (dh *downloadHelper) close() {
dh.startedSub.Unsubscribe()
dh.finishedSub.Unsubscribe()
}
func (dh *downloadHelper) downloadStartedLoop() {
@ -107,22 +103,11 @@ func (consensus *Consensus) AddConsensusLastMile() error {
}
func (consensus *Consensus) spinUpStateSync() {
if consensus.dHelper != nil {
consensus.dHelper.d.DownloadAsync()
consensus.current.SetMode(Syncing)
for _, v := range consensus.consensusTimeout {
v.Stop()
}
} else {
select {
case consensus.BlockNumLowChan <- struct{}{}:
consensus.current.SetMode(Syncing)
for _, v := range consensus.consensusTimeout {
v.Stop()
}
default:
}
}
}
func (consensus *Consensus) spinLegacyStateSync() {

Loading…
Cancel
Save