mirror of
https://github.com/ethereum/go-ethereum.git
synced 2026-07-24 21:56:43 +00:00
era-download logic fix
Downloading from a range was failing because it would return and error early with an error misinterpreting "start-end".
This commit is contained in:
parent
b62c0c67fa
commit
563b4b0b5c
1 changed files with 13 additions and 9 deletions
|
|
@ -765,15 +765,8 @@ func downloadEra(ctx *cli.Context) error {
|
||||||
}
|
}
|
||||||
|
|
||||||
func parseRange(s string) (start uint64, end uint64, ok bool) {
|
func parseRange(s string) (start uint64, end uint64, ok bool) {
|
||||||
if m, _ := regexp.MatchString("[0-9]+", s); m {
|
log.Info("Parsing block range", "input", s)
|
||||||
start, err := strconv.ParseUint(s, 10, 64)
|
if m, _ := regexp.MatchString("^[0-9]+-[0-9]+$", s); m {
|
||||||
if err != nil {
|
|
||||||
return 0, 0, false
|
|
||||||
}
|
|
||||||
end = start
|
|
||||||
return start, end, true
|
|
||||||
}
|
|
||||||
if m, _ := regexp.MatchString("[0-9]+-[0-9]+", s); m {
|
|
||||||
s1, s2, _ := strings.Cut(s, "-")
|
s1, s2, _ := strings.Cut(s, "-")
|
||||||
start, err := strconv.ParseUint(s1, 10, 64)
|
start, err := strconv.ParseUint(s1, 10, 64)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
|
@ -783,7 +776,18 @@ func parseRange(s string) (start uint64, end uint64, ok bool) {
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return 0, 0, false
|
return 0, 0, false
|
||||||
}
|
}
|
||||||
|
log.Info("Parsing block range", "start", start, "end", end)
|
||||||
return start, end, true
|
return start, end, true
|
||||||
}
|
}
|
||||||
|
if m, _ := regexp.MatchString("^[0-9]+$", s); m {
|
||||||
|
start, err := strconv.ParseUint(s, 10, 64)
|
||||||
|
if err != nil {
|
||||||
|
return 0, 0, false
|
||||||
|
}
|
||||||
|
end = start
|
||||||
|
log.Info("Parsing single block range", "block", start)
|
||||||
|
return start, end, true
|
||||||
|
}
|
||||||
|
|
||||||
return 0, 0, false
|
return 0, 0, false
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue