WIP
This commit is contained in:
parent
4c8e1f0f03
commit
65e3a12fd7
61
run.go
61
run.go
|
@ -3,7 +3,6 @@ package main
|
|||
import (
|
||||
"bytes"
|
||||
"context"
|
||||
"encoding/hex"
|
||||
"fmt"
|
||||
"time"
|
||||
|
||||
|
@ -44,6 +43,26 @@ func ToTopic(s string) []byte {
|
|||
return crypto.Keccak256([]byte(s))[:types.TopicLength]
|
||||
}
|
||||
|
||||
func buildComparerFN(messages []string) (func([]byte) bool, error) {
|
||||
var msgIDArray [][]byte
|
||||
for _, m := range messages {
|
||||
b, err := hexutil.Decode(m)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
msgIDArray = append(msgIDArray, b)
|
||||
}
|
||||
|
||||
return func(hash []byte) bool {
|
||||
for _, m := range msgIDArray {
|
||||
if bytes.Equal(m, hash) {
|
||||
return true
|
||||
}
|
||||
}
|
||||
return false
|
||||
}, nil
|
||||
}
|
||||
|
||||
var nodeList = []string{
|
||||
"/dns4/node-01.ac-cn-hongkong-c.status.prod.statusim.net/tcp/30303/p2p/16Uiu2HAkvEZgh3KLwhLwXg95e5ojM8XykJ4Kxi2T7hk22rnA7pJC",
|
||||
"/dns4/node-01.do-ams3.status.prod.statusim.net/tcp/30303/p2p/16Uiu2HAm6HZZr7aToTvEBPpiys4UxajCTU97zj5v7RNR2gbniy1D",
|
||||
|
@ -54,11 +73,6 @@ var nodeList = []string{
|
|||
}
|
||||
|
||||
func main() {
|
||||
|
||||
topic := "0x0324f1c85601c3c8faf6758dc9b79c3565525759e1ff66260019b2033919eb0bf0c2c1efca-c309-4655-b4c4-fb3cb0e32594"
|
||||
topicBytes := ToTopic(topic)
|
||||
contentTopic := ContentTopic(topicBytes)
|
||||
|
||||
ctx, cancel := context.WithCancel(context.Background())
|
||||
defer cancel()
|
||||
|
||||
|
@ -72,19 +86,29 @@ func main() {
|
|||
defer s1.Stop()
|
||||
|
||||
for i, n := range nodeList {
|
||||
queryNode(ctx, n, host1, contentTopic, s1, "first", i)
|
||||
queryNode(ctx, n, host1, s1, i)
|
||||
}
|
||||
}
|
||||
|
||||
func queryNode(ctx context.Context, node string, host1 host.Host, contentTopic string, s1 *store.WakuStore, attempt string, i int) {
|
||||
func queryNode(ctx context.Context, node string, host1 host.Host, s1 *store.WakuStore, i int) {
|
||||
p, err := multiaddr.NewMultiaddr(node)
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
|
||||
hash1, _ := hex.DecodeString("305b9f88bc8f670b57d895b06296a50eef8b69f1576bce7313d61c3fd4adf677")
|
||||
hash2, _ := hex.DecodeString("5336a19ad110eb5efaa39c180881529da490e3cc12b6f634d00a4105ed57da21")
|
||||
hash3, _ := hex.DecodeString("7554ffbeb8ec0373b165013708214ebda8103c9ff3d1bd676e0c1cd9b1a9571e")
|
||||
messagesToLookFor := []string{
|
||||
"0x305b9f88bc8f670b57d895b06296a50eef8b69f1576bce7313d61c3fd4adf677",
|
||||
"0x5336a19ad110eb5efaa39c180881529da490e3cc12b6f634d00a4105ed57da21",
|
||||
"0x7554ffbeb8ec0373b165013708214ebda8103c9ff3d1bd676e0c1cd9b1a9571e",
|
||||
}
|
||||
|
||||
startDate := 1671058980
|
||||
endDate := 1671058980 + 120
|
||||
|
||||
messageExists, err := buildComparerFN(messagesToLookFor)
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
|
||||
info, err := peer.AddrInfoFromP2pAddr(p)
|
||||
if err != nil {
|
||||
|
@ -102,8 +126,8 @@ func queryNode(ctx context.Context, node string, host1 host.Host, contentTopic s
|
|||
|
||||
result, err := s1.Query(ctx, store.Query{
|
||||
Topic: "/waku/2/default-waku/proto",
|
||||
StartTime: int64(1671058980 * time.Second),
|
||||
EndTime: int64((1671058980 + 120) * time.Second),
|
||||
StartTime: int64(time.Duration(startDate) * time.Second),
|
||||
EndTime: int64((time.Duration(endDate) * time.Second)),
|
||||
}, store.WithPeer(info.ID), store.WithPaging(false, 100), store.WithRequestId([]byte{1, 2, 3, 4, 5, 6, 7, 8, byte(i)}))
|
||||
if err != nil {
|
||||
fmt.Printf("Could not query %s: %s", info.ID, err.Error())
|
||||
|
@ -114,14 +138,11 @@ func queryNode(ctx context.Context, node string, host1 host.Host, contentTopic s
|
|||
cnt += len(result.Messages)
|
||||
cursorIterations += 1
|
||||
|
||||
fmt.Println("Cursor has: ", len(result.Messages))
|
||||
|
||||
for _, r := range result.Messages {
|
||||
h, _, _ := r.Hash()
|
||||
//fmt.Println(h, hash1, hash2, hash3)
|
||||
if bytes.Equal(h, hash1) || bytes.Equal(h, hash2) || bytes.Equal(h, hash3) {
|
||||
fmt.Println("FOUND IN", node)
|
||||
break
|
||||
if messageExists(h) {
|
||||
fmt.Println("Message found in", node)
|
||||
return
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -135,4 +156,6 @@ func queryNode(ctx context.Context, node string, host1 host.Host, contentTopic s
|
|||
}
|
||||
}
|
||||
|
||||
fmt.Println("Message NOT found in", node)
|
||||
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue