core: optimize persist() for the case when no next block found

If there is no next block in the cache, looping through the whole cache won't
help.
This commit is contained in:
Roman Khimov 2019-09-11 20:32:30 +03:00
parent 7812fb28ea
commit 4f60fd3e8e

View file

@ -409,6 +409,9 @@ func (bc *Blockchain) persist(ctx context.Context) (err error) {
}
bc.blockCache.Delete(hash)
persisted++
} else {
// no next block in the cache, no reason to continue looping
break
}
}
}