Skip to content

Commit 75502f6

Browse files
authored
Merge pull request #2404 from CortexFoundation/dev
parse range
2 parents a21d7cc + f4de333 commit 75502f6

15 files changed

Lines changed: 293 additions & 37 deletions

File tree

cmd/cortex/chaincmd.go

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,8 +21,10 @@ import (
2121
"fmt"
2222
"os"
2323
"path/filepath"
24+
"regexp"
2425
"runtime"
2526
"strconv"
27+
"strings"
2628
"sync/atomic"
2729
"time"
2830

@@ -532,3 +534,33 @@ func hashish(x string) bool {
532534
_, err := strconv.Atoi(x)
533535
return err != nil
534536
}
537+
538+
func parseRange(s string) (start uint64, end uint64, ok bool) {
539+
log.Info("Parsing block range", "input", s)
540+
if m, _ := regexp.MatchString("^[0-9]+-[0-9]+$", s); m {
541+
s1, s2, _ := strings.Cut(s, "-")
542+
start, err := strconv.ParseUint(s1, 10, 64)
543+
if err != nil {
544+
return 0, 0, false
545+
}
546+
end, err = strconv.ParseUint(s2, 10, 64)
547+
if err != nil {
548+
return 0, 0, false
549+
}
550+
if start > end {
551+
return 0, 0, false
552+
}
553+
log.Info("Parsing block range", "start", start, "end", end)
554+
return start, end, true
555+
}
556+
if m, _ := regexp.MatchString("^[0-9]+$", s); m {
557+
start, err := strconv.ParseUint(s, 10, 64)
558+
if err != nil {
559+
return 0, 0, false
560+
}
561+
end = start
562+
log.Info("Parsing single block range", "block", start)
563+
return start, end, true
564+
}
565+
return 0, 0, false
566+
}

go.mod

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ require (
66
github.com/Azure/azure-sdk-for-go/sdk/storage/azblob v1.6.1
77
github.com/CortexFoundation/inference v1.0.2-0.20230307032835-9197d586a4e8
88
github.com/CortexFoundation/statik v0.0.0-20210315012922-8bb8a7b5dc66
9-
github.com/CortexFoundation/torrentfs v1.0.69-0.20250616125459-02aa4dc4ace7
9+
github.com/CortexFoundation/torrentfs v1.0.69-0.20250624130554-3907c8c961de
1010
github.com/VictoriaMetrics/fastcache v1.12.5
1111
github.com/arsham/figurine v1.3.0
1212
github.com/aws/aws-sdk-go-v2 v1.36.5
@@ -149,7 +149,7 @@ require (
149149
github.com/erikgeiser/coninput v0.0.0-20211004153227-1c3628e74d0f // indirect
150150
github.com/fatih/color v1.18.0 // indirect
151151
github.com/garslo/gogen v0.0.0-20170306192744-1d203ffc1f61 // indirect
152-
github.com/getsentry/sentry-go v0.33.0 // indirect
152+
github.com/getsentry/sentry-go v0.34.0 // indirect
153153
github.com/go-llsqlite/adapter v0.2.0 // indirect
154154
github.com/go-llsqlite/crawshaw v0.6.0 // indirect
155155
github.com/go-logr/logr v1.4.3 // indirect

go.sum

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -70,8 +70,8 @@ github.com/CortexFoundation/statik v0.0.0-20210315012922-8bb8a7b5dc66/go.mod h1:
7070
github.com/CortexFoundation/torrentfs v1.0.13-0.20200623060705-ce027f43f2f8/go.mod h1:Ma+tGhPPvz4CEZHaqEJQMOEGOfHeQBiAoNd1zyc/w3Q=
7171
github.com/CortexFoundation/torrentfs v1.0.14-0.20200703071639-3fcabcabf274/go.mod h1:qnb3YlIJmuetVBtC6Lsejr0Xru+1DNmDCdTqnwy7lhk=
7272
github.com/CortexFoundation/torrentfs v1.0.20-0.20200810031954-d36d26f82fcc/go.mod h1:N5BsicP5ynjXIi/Npl/SRzlJ630n1PJV2sRj0Z0t2HA=
73-
github.com/CortexFoundation/torrentfs v1.0.69-0.20250616125459-02aa4dc4ace7 h1:rUUeU01baYxFrQIUshzvqD9bI15YCNz5R+291AIqDtg=
74-
github.com/CortexFoundation/torrentfs v1.0.69-0.20250616125459-02aa4dc4ace7/go.mod h1:2kPs5QtFTkHKQz/VKUN0qzRHKSGucudGcEIEvRhmH/g=
73+
github.com/CortexFoundation/torrentfs v1.0.69-0.20250624130554-3907c8c961de h1:Kmr75lnqQQRsJm7eMw7yACLKiLD9QjRfabjv51Ao7Vg=
74+
github.com/CortexFoundation/torrentfs v1.0.69-0.20250624130554-3907c8c961de/go.mod h1:2kPs5QtFTkHKQz/VKUN0qzRHKSGucudGcEIEvRhmH/g=
7575
github.com/CortexFoundation/wormhole v0.0.2-0.20241128010855-a23c88842cfa h1:46VAGWxOwpoLlPNcR9etAhK0NtT215skO9Wl4i14r4o=
7676
github.com/CortexFoundation/wormhole v0.0.2-0.20241128010855-a23c88842cfa/go.mod h1:ipzmPabDgzYKUbXkGVe2gTkBEp+MsDx6pXGiuYzmP6s=
7777
github.com/DATA-DOG/go-sqlmock v1.3.3/go.mod h1:f/Ixk793poVmq4qj/V1dPUg2JEAKC73Q5eFN3EC/SaM=
@@ -492,8 +492,8 @@ github.com/garslo/gogen v0.0.0-20170306192744-1d203ffc1f61/go.mod h1:Q0X6pkwTILD
492492
github.com/garyburd/redigo v1.6.0/go.mod h1:NR3MbYisc3/PwhQ00EMzDiPmrwpPxAn5GI05/YaO1SY=
493493
github.com/gballet/go-libpcsclite v0.0.0-20191108122812-4678299bea08 h1:f6D9Hr8xV8uYKlyuj8XIruxlh9WjVjdh1gIicAS7ays=
494494
github.com/gballet/go-libpcsclite v0.0.0-20191108122812-4678299bea08/go.mod h1:x7DCsMOv1taUwEWCzT4cmDeAkigA5/QCwUodaVOe8Ww=
495-
github.com/getsentry/sentry-go v0.33.0 h1:YWyDii0KGVov3xOaamOnF0mjOrqSjBqwv48UEzn7QFg=
496-
github.com/getsentry/sentry-go v0.33.0/go.mod h1:C55omcY9ChRQIUcVcGcs+Zdy4ZpQGvNJ7JYHIoSWOtE=
495+
github.com/getsentry/sentry-go v0.34.0 h1:1FCHBVp8TfSc8L10zqSwXUZNiOSF+10qw4czjarTiY4=
496+
github.com/getsentry/sentry-go v0.34.0/go.mod h1:C55omcY9ChRQIUcVcGcs+Zdy4ZpQGvNJ7JYHIoSWOtE=
497497
github.com/ghodss/yaml v1.0.0/go.mod h1:4dBDuWmgqj2HViK6kFavaiC9ZROes6MMH2rRYeMEF04=
498498
github.com/gliderlabs/ssh v0.1.1/go.mod h1:U7qILu1NlMHj9FlMhZLlkCdDnU1DBEAqr0aevW3Awn0=
499499
github.com/glycerine/go-unsnap-stream v0.0.0-20180323001048-9f0cb55181dd/go.mod h1:/20jfyN9Y5QPEAprSgKAUr+glWDY39ZiUEAYOEv5dsE=

vendor/github.com/CortexFoundation/torrentfs/backend/api.go

Lines changed: 5 additions & 4 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

vendor/github.com/getsentry/sentry-go/CHANGELOG.md

Lines changed: 101 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

vendor/github.com/getsentry/sentry-go/attribute/bulider.go renamed to vendor/github.com/getsentry/sentry-go/attribute/builder.go

File renamed without changes.

vendor/github.com/getsentry/sentry-go/client.go

Lines changed: 19 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

vendor/github.com/getsentry/sentry-go/hub.go

Lines changed: 22 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

vendor/github.com/getsentry/sentry-go/interfaces.go

Lines changed: 27 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

vendor/github.com/getsentry/sentry-go/log.go

Lines changed: 23 additions & 9 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)