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