fix: time

This commit is contained in:
Richard Ramos 2024-06-06 22:59:35 -04:00
parent 065a8b4a67
commit 3e9f79074a
No known key found for this signature in database
GPG Key ID: 1CE87DB518195760
4 changed files with 25 additions and 14 deletions

View File

@ -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 . .
@ -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"]

View File

@ -83,7 +83,10 @@ MessageHash Content Topi
To see the content of a message
```
./build/query --cluster-id=16 --storenode=/dns4/store-01.do-ams3.shards.test.status.im/tcp/30303/p2p/16Uiu2HAmAUdrQ3uwzuE4Gy4D56hX6uLKEeerJAnhKEHZ3DxF1EfT --hash 0xacb469e0464aa6ebe7847807bf856c05a7ed3d26c5813f76c206ff9706eb686b
./build/query \
--cluster-id=16 \
--storenode=/dns4/store-01.do-ams3.shards.test.status.im/tcp/30303/p2p/16Uiu2HAmAUdrQ3uwzuE4Gy4D56hX6uLKEeerJAnhKEHZ3DxF1EfT \
--hash 0xacb469e0464aa6ebe7847807bf856c05a7ed3d26c5813f76c206ff9706eb686b
PubsubTopic: 0xc000350830
MessageHash: 0xacb469e0464aa6ebe7847807bf856c05a7ed3d26c5813f76c206ff9706eb686b
@ -104,7 +107,6 @@ 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>
```
@ -112,10 +114,10 @@ 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 \

2
go.mod
View File

@ -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
@ -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

19
main.go
View File

@ -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 {
@ -242,6 +241,16 @@ 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
@ -249,8 +258,8 @@ func QueryMessages(ctx context.Context, opts Options) error {
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{
@ -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)