[crash] fix issue #703

Signed-off-by: Leo Chen <leo@harmony.one>
pull/712/head
Leo Chen 6 years ago
parent 5446f751b2
commit a98ead38fa
  1. 4
      api/service/syncing/syncing.go

@ -343,14 +343,14 @@ func (ss *StateSync) downloadBlocks(bc *core.BlockChain) {
defer wg.Done()
for !stateSyncTaskQueue.Empty() {
task, err := ss.stateSyncTaskQueue.Poll(1, time.Millisecond)
if err == queue.ErrTimeout {
if err == queue.ErrTimeout || len(task) == 0 {
utils.GetLogInstance().Debug("[SYNC] ss.stateSyncTaskQueue poll timeout", "error", err)
break
}
syncTask := task[0].(SyncBlockTask)
//id := syncTask.index
payload, err := peerConfig.GetBlocks([][]byte{syncTask.blockHash})
if err != nil {
if err != nil || len(payload) == 0 {
count++
utils.GetLogInstance().Debug("[SYNC] GetBlocks failed", "failNumber", count)
if count > TimesToFail {

Loading…
Cancel
Save