fix short range hash chain

pull/4351/head
“GheisMohammadi” 2 years ago committed by Casey Gardiner
parent 601422a631
commit e5f18d3f36
  1. 10
      api/service/stagedstreamsync/short_range_helper.go
  2. 8
      api/service/stagedstreamsync/stage_short_range.go

@ -139,15 +139,11 @@ func (sh *srHelper) checkPrerequisites() error {
return nil
}
func (sh *srHelper) prepareBlockHashNumbers(curNumber uint64, count int) []uint64 {
func (sh *srHelper) prepareBlockHashNumbers(curNumber uint64) []uint64 {
n := count
if count > BlockHashesPerRequest {
n = BlockHashesPerRequest
}
res := make([]uint64, 0, n)
res := make([]uint64, 0, BlockHashesPerRequest)
for bn := curNumber + 1; bn <= curNumber+uint64(n); bn++ {
for bn := curNumber + 1; bn <= curNumber+uint64(BlockHashesPerRequest); bn++ {
res = append(res, bn)
}
return res

@ -54,11 +54,6 @@ func (sr *StageShortRange) Exec(firstCycle bool, invalidBlockRevert bool, s *Sta
return nil
}
curBN := sr.configs.bc.CurrentBlock().NumberU64()
if curBN >= s.state.status.targetBN {
return nil
}
// do short range sync
n, err := sr.doShortRangeSync(s)
s.state.inserted = n
@ -109,8 +104,7 @@ func (sr *StageShortRange) doShortRangeSync(s *StageState) (int, error) {
return 0, errors.Wrap(err, "prerequisite")
}
curBN := sr.configs.bc.CurrentBlock().NumberU64()
blkCount := int(s.state.status.targetBN) - int(curBN)
blkNums := sh.prepareBlockHashNumbers(curBN, blkCount)
blkNums := sh.prepareBlockHashNumbers(curBN)
hashChain, whitelist, err := sh.getHashChain(blkNums)
if err != nil {
return 0, errors.Wrap(err, "getHashChain")

Loading…
Cancel
Save