Skip to content

Commit

Permalink
fix: time
Browse files Browse the repository at this point in the history
  • Loading branch information
richard-ramos committed Jun 7, 2024
1 parent 065a8b4 commit 426006b
Show file tree
Hide file tree
Showing 4 changed files with 21 additions and 13 deletions.
8 changes: 4 additions & 4 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
FROM golang:1.21 as builder

RUN mkdir -p /go/src/github.com/waku-org/test-waku-query/go
RUN mkdir -p /go/src/github.com/waku-org/message-finder

WORKDIR /go/src/github.com/waku-org/test-waku-query/go
WORKDIR /go/src/github.com/waku-org/message-finder

ADD . .

Expand All @@ -11,11 +11,11 @@ RUN make
# Copy the binary to the second image
FROM debian:12.5-slim

LABEL source="https://github.com/waku-org/test-waku-query/go"
LABEL source="https://github.com/waku-org/message-finder"
LABEL description="Storenode query tool"
LABEL commit="unknown"

COPY --from=builder /go/src/github.com/waku-org/test-waku-query/go/build/query /usr/local/bin/query
COPY --from=builder /go/src/github.com/waku-org/message-finder/build/query /usr/local/bin/query

ENTRYPOINT ["/usr/local/bin/query"]
CMD ["-help"]
5 changes: 2 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -104,18 +104,17 @@ Payload:
00000090 7f d0 aa 56 03 ca 49 eb ef 08 9a ef ca 12 85 72 |...V..I........r|
000000a0 b0 47 79 2b 28 50 06 7d 89 69 d8 85 8e 3c 7f cb |.Gy+(P.}.i...<..|
Meta: <nil>
Meta: <nil>
RateLimitProof: <nil>
```

### Docker
```
# Build
docker build -t querytool:latest .
docker build -t storequery:latest .
# Execute
docker run querytool:latest \
docker run storequery:latest \
--cluster-id=16 \
--storenode=/dns4/store-01.do-ams3.shards.test.status.im/tcp/30303/p2p/16Uiu2HAmAUdrQ3uwzuE4Gy4D56hX6uLKEeerJAnhKEHZ3DxF1EfT \
--pubsub-topic=/waku/2/rs/16/32 \
Expand Down
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@ require (
github.com/libp2p/go-libp2p v0.35.0
github.com/multiformats/go-multiaddr v0.12.4
github.com/rodaine/table v1.2.0
github.com/stretchr/testify v1.9.0
github.com/urfave/cli/v2 v2.27.2
github.com/waku-org/go-waku v0.8.1-0.20240605190333-d2d2f5672ebd
go.uber.org/zap v1.27.0
Expand Down Expand Up @@ -119,6 +118,7 @@ require (
github.com/russross/blackfriday/v2 v2.1.0 // indirect
github.com/shirou/gopsutil v3.21.4-0.20210419000835-c7a38de76ee5+incompatible // indirect
github.com/spaolacci/murmur3 v1.1.0 // indirect
github.com/stretchr/testify v1.9.0 // indirect
github.com/syndtr/goleveldb v1.0.1-0.20220614013038-64ee5596c38a // indirect
github.com/tklauser/go-sysconf v0.3.5 // indirect
github.com/tklauser/numcpus v0.2.2 // indirect
Expand Down
19 changes: 14 additions & 5 deletions main.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,6 @@ import (
"github.com/waku-org/go-waku/waku/v2/utils"
"go.uber.org/zap"
"go.uber.org/zap/zapcore"
"google.golang.org/protobuf/proto"
)

type Options struct {
Expand Down Expand Up @@ -242,15 +241,25 @@ func QueryMessages(ctx context.Context, opts Options) error {
}
}

var StartTime *int64
if options.StartTime > 0 {
StartTime = &options.StartTime
}

var EndTime *int64
if options.EndTime > 0 {
EndTime = &options.EndTime
}

cnt := 0
if !options.UseLegacy {
var criteria store.Criteria

if len(hashes) == 0 {
criteria = store.FilterCriteria{
ContentFilter: protocol.NewContentFilter(options.PubSubTopic, options.ContentTopics.Value()...),
TimeStart: proto.Int64(options.StartTime),
TimeEnd: proto.Int64(options.EndTime),
TimeStart: StartTime,
TimeEnd: EndTime,
}
} else {
criteria = store.MessageHashCriteria{
Expand Down Expand Up @@ -313,8 +322,8 @@ func QueryMessages(ctx context.Context, opts Options) error {
query := legacy_store.Query{
PubsubTopic: options.PubSubTopic,
ContentTopics: options.ContentTopics.Value(),
StartTime: proto.Int64(options.StartTime),
EndTime: proto.Int64(options.EndTime),
StartTime: StartTime,
EndTime: EndTime,
}

ctx, cancel := context.WithTimeout(context.Background(), options.QueryTimeout)
Expand Down

0 comments on commit 426006b

Please sign in to comment.