pull/3596/head
Jacky Wang 4 years ago committed by Leo Chen
parent 8629a6d45e
commit 4081f3124c
  1. 3
      hmy/downloader/downloader.go
  2. 7
      hmy/downloader/longrange.go
  3. 2
      hmy/downloader/longrange_test.go

@ -99,8 +99,7 @@ func (d *Downloader) Close() {
}
}
// DownloadAsync triggers the download async. If there is already a download task that is
// in progress, return ErrDownloadInProgress.
// DownloadAsync triggers the download async.
func (d *Downloader) DownloadAsync() {
select {
case d.downloadC <- struct{}{}:

@ -119,7 +119,7 @@ func (lsi *lrSyncIter) estimateCurrentNumber() (uint64, error) {
}
return 0, errors.New("zero block number response from remote nodes")
}
bn := computeBNMaxVote(cnResults)
bn := computeBlockNumberByMaxVote(cnResults)
return bn, nil
}
@ -428,6 +428,7 @@ func (gbm *getBlocksManager) PullContinuousBlocks(cap int) []*blockResult {
return results
}
// getBatchFromRetries get the block number batch to be requested from retries.
func (gbm *getBlocksManager) getBatchFromRetries(cap int) []uint64 {
var (
requestBNs []uint64
@ -446,6 +447,7 @@ func (gbm *getBlocksManager) getBatchFromRetries(cap int) []uint64 {
return requestBNs
}
// getBatchFromRetries get the block number batch to be requested from unprocessed.
func (gbm *getBlocksManager) getBatchFromUnprocessed(cap int) []uint64 {
var (
requestBNs []uint64
@ -490,7 +492,8 @@ func validateGetBlocksResult(requested []uint64, result []*types.Block) error {
return nil
}
func computeBNMaxVote(votes map[sttypes.StreamID]uint64) uint64 {
// computeBlockNumberByMaxVote compute the target block number by max vote.
func computeBlockNumberByMaxVote(votes map[sttypes.StreamID]uint64) uint64 {
var (
nm = make(map[uint64]int)
res uint64

@ -299,7 +299,7 @@ func TestComputeBNMaxVote(t *testing.T) {
}
for i, test := range tests {
res := computeBNMaxVote(test.votes)
res := computeBlockNumberByMaxVote(test.votes)
if res != test.exp {
t.Errorf("Test %v: unexpected bn %v / %v", i, res, test.exp)
}

Loading…
Cancel
Save