diff --git a/examples/basic2/go.mod b/examples/basic2/go.mod index 165c70d8..431708b0 100644 --- a/examples/basic2/go.mod +++ b/examples/basic2/go.mod @@ -5,5 +5,5 @@ go 1.15 require ( github.com/ethereum/go-ethereum v1.9.5 github.com/ipfs/go-log v1.0.5 - github.com/status-im/go-waku v0.0.0-20210404170848-47752170e9df + github.com/status-im/go-waku v0.0.0-20210411234359-f9e7589ffdd9 ) diff --git a/examples/basic2/go.sum b/examples/basic2/go.sum index 12bfa3d4..844bfae1 100644 --- a/examples/basic2/go.sum +++ b/examples/basic2/go.sum @@ -171,6 +171,7 @@ github.com/hpcloud/tail v1.0.0/go.mod h1:ab1qPbhIpdTxEkNHXyeSf5vhxWSCs/tWer42PpO github.com/huin/goupnp v1.0.0 h1:wg75sLpL6DZqwHQN6E1Cfk6mtfzS45z8OV+ic+DtHRo= github.com/huin/goupnp v1.0.0/go.mod h1:n9v9KO1tAxYH82qOn+UTIFQDmx5n1Zxd/ClZDMX7Bnc= github.com/huin/goutil v0.0.0-20170803182201-1ca381bf3150/go.mod h1:PpLOETDnJ0o3iZrZfqZzyLl6l7F3c6L1oWn7OICBi6o= +github.com/inconshreveable/mousetrap v1.0.0 h1:Z8tu5sraLXCXIcARxBp/8cbvlwVa7Z1NHg9XEKhtSvM= github.com/inconshreveable/mousetrap v1.0.0/go.mod h1:PxqpIevigyE2G7u3NXJIT2ANytuPF1OarO4DADm73n8= github.com/ipfs/go-cid v0.0.1/go.mod h1:GHWU/WuQdMPmIosc4Yn1bcCT7dSeX4lBafM7iqUPQvM= github.com/ipfs/go-cid v0.0.2/go.mod h1:GHWU/WuQdMPmIosc4Yn1bcCT7dSeX4lBafM7iqUPQvM= @@ -391,6 +392,7 @@ github.com/libp2p/go-openssl v0.0.2/go.mod h1:v8Zw2ijCSWBQi8Pq5GAixw6DbFfa9u6VIY github.com/libp2p/go-openssl v0.0.3/go.mod h1:unDrJpgy3oFr+rqXsarWifmJuNnJR4chtO1HmaZjggc= github.com/libp2p/go-openssl v0.0.4/go.mod h1:unDrJpgy3oFr+rqXsarWifmJuNnJR4chtO1HmaZjggc= github.com/libp2p/go-openssl v0.0.5/go.mod h1:unDrJpgy3oFr+rqXsarWifmJuNnJR4chtO1HmaZjggc= +github.com/libp2p/go-openssl v0.0.7 h1:eCAzdLejcNVBzP/iZM9vqHnQm+XyCEbSSIheIPRGNsw= github.com/libp2p/go-openssl v0.0.7/go.mod h1:unDrJpgy3oFr+rqXsarWifmJuNnJR4chtO1HmaZjggc= github.com/libp2p/go-reuseport v0.0.1/go.mod h1:jn6RmB1ufnQwl0Q1f+YxAj8isJgDCQzaaxIFYDhcYEA= github.com/libp2p/go-reuseport v0.0.2 h1:XSG94b1FJfGA01BUrT82imejHQyTxO4jEWqheyCXYvU= @@ -399,6 +401,7 @@ github.com/libp2p/go-reuseport-transport v0.0.2/go.mod h1:YkbSDrvjUVDL6b8XqriyA2 github.com/libp2p/go-reuseport-transport v0.0.3/go.mod h1:Spv+MPft1exxARzP2Sruj2Wb5JSyHNncjf1Oi2dEbzM= github.com/libp2p/go-reuseport-transport v0.0.4 h1:OZGz0RB620QDGpv300n1zaOcKGGAoGVf8h9txtt/1uM= github.com/libp2p/go-reuseport-transport v0.0.4/go.mod h1:trPa7r/7TJK/d+0hdBLOCGvpQQVOU74OXbNCIMkufGw= +github.com/libp2p/go-sockaddr v0.0.2 h1:tCuXfpA9rq7llM/v834RKc/Xvovy/AqM9kHvTV/jY/Q= github.com/libp2p/go-sockaddr v0.0.2/go.mod h1:syPvOmNs24S3dFVGJA1/mrqdeijPxLV2Le3BRLKd68k= github.com/libp2p/go-stream-muxer v0.0.1/go.mod h1:bAo8x7YkSpadMTbtTaxGVHWUQsR/l5MEaHbKaliuT14= github.com/libp2p/go-stream-muxer-multistream v0.2.0/go.mod h1:j9eyPol/LLRqT+GPLSxvimPhNph4sfYfMoDPd7HkzIc= @@ -565,6 +568,7 @@ github.com/smartystreets/goconvey v1.6.4/go.mod h1:syvi0/a8iFYH4r/RixwvyeAJjdLS9 github.com/smola/gocompat v0.2.0/go.mod h1:1B0MlxbmoZNo3h8guHp8HztB3BSYR5itql9qtVc0ypY= github.com/soheilhy/cmux v0.1.4/go.mod h1:IM3LyeVVIOuxMH7sFAkER9+bJ4dT7Ms6E4xg4kGIyLM= github.com/spacemonkeygo/openssl v0.0.0-20181017203307-c2dcc5cca94a/go.mod h1:7AyxJNCJ7SBZ1MfVQCWD6Uqo2oubI2Eq2y2eqf+A5r0= +github.com/spacemonkeygo/spacelog v0.0.0-20180420211403-2296661a0572 h1:RC6RW7j+1+HkWaX/Yh71Ee5ZHaHYt7ZP4sQgUrm6cDU= github.com/spacemonkeygo/spacelog v0.0.0-20180420211403-2296661a0572/go.mod h1:w0SWMsp6j9O/dk4/ZpIhL+3CkG8ofA2vuv7k+ltqUMc= github.com/spaolacci/murmur3 v0.0.0-20180118202830-f09979ecbc72/go.mod h1:JwIasOWyU6f++ZhiEuf87xNszmSA2myDM2Kzu9HwQUA= github.com/spaolacci/murmur3 v1.1.0 h1:7c1g84S4BPRrfL5Xrdp6fOJ206sU9y293DDHaoy0bLI= @@ -591,6 +595,8 @@ github.com/spf13/viper v1.7.1/go.mod h1:8WkrPz2fc9jxqZNCJI/76HCieCp4Q8HaLFoCha5q github.com/src-d/envconfig v1.0.0/go.mod h1:Q9YQZ7BKITldTBnoxsE5gOeB5y66RyPXeue/R4aaNBc= github.com/status-im/go-waku v0.0.0-20210404170848-47752170e9df h1:wm5+68DGiRMvZULb1tel/5lQmqSTS4NOb3BnRuNPGHY= github.com/status-im/go-waku v0.0.0-20210404170848-47752170e9df/go.mod h1:949jqEGfl0gWv8NMWJU5xhW0hSRJicDxYWQAZkJMsqQ= +github.com/status-im/go-waku v0.0.0-20210411234359-f9e7589ffdd9 h1:smFp8UIU5OYZuWNxyNfIKcCbP74NSqi6EqVmcqh6Zlo= +github.com/status-im/go-waku v0.0.0-20210411234359-f9e7589ffdd9/go.mod h1:2fHIqaNF8M8W/DQL5J3R9dXbrTLpOefvD5tbKSvoxBg= github.com/status-im/go-wakurelay-pubsub v0.4.2 h1:F4UGcP80H0PGaeJ0mRMzA1Ux3DKYiyv/qu3bOR/efTg= github.com/status-im/go-wakurelay-pubsub v0.4.2/go.mod h1:LSCVYR7mnBBsxVJghrGpQ3yJAAATEe6XeQQqGCZhwrE= github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME= diff --git a/examples/basic2/main.go b/examples/basic2/main.go index a70169dc..560b5e6a 100644 --- a/examples/basic2/main.go +++ b/examples/basic2/main.go @@ -67,19 +67,24 @@ func randomHex(n int) (string, error) { } func write(wakuNode *node.WakuNode, msgContent string) { - var contentTopic uint32 = 1 + var contentTopic string = "test" var version uint32 = 0 var timestamp float64 = float64(time.Now().UnixNano()) - payload, err := node.Encode([]byte(wakuNode.ID()+": "+msgContent), &node.KeyInfo{Kind: node.None}, 0) + p := new(node.Payload) + p.Data = []byte(wakuNode.ID() + ": " + msgContent) + p.Key = &node.KeyInfo{Kind: node.None} + + payload, err := p.Encode(version) + msg := &protocol.WakuMessage{ Payload: payload, - Version: &version, - ContentTopic: &contentTopic, - Timestamp: ×tamp, + Version: version, + ContentTopic: contentTopic, + Timestamp: timestamp, } - err = wakuNode.Publish(msg, nil) + _, err = wakuNode.Publish(msg, nil) if err != nil { log.Error("Error sending a message: ", err) } @@ -106,6 +111,6 @@ func readLoop(wakuNode *node.WakuNode) { return } - log.Info("Received msg, ", string(payload)) + log.Info("Received msg, ", string(payload.Data)) } } diff --git a/examples/chat2/chat.go b/examples/chat2/chat.go index 25526f18..920121a9 100644 --- a/examples/chat2/chat.go +++ b/examples/chat2/chat.go @@ -84,7 +84,9 @@ func (cr *Chat) Publish(message string) error { Timestamp: timestamp, } - return cr.node.Publish(wakuMsg, nil) + _, err = cr.node.Publish(wakuMsg, nil) + + return err } // readLoop pulls messages from the pubsub topic and pushes them onto the Messages channel. diff --git a/examples/chat2/go.mod b/examples/chat2/go.mod index 556b9ba9..2579778a 100644 --- a/examples/chat2/go.mod +++ b/examples/chat2/go.mod @@ -10,6 +10,6 @@ require ( github.com/ipfs/go-log/v2 v2.1.1 github.com/libp2p/go-libp2p-core v0.8.5 github.com/rivo/tview v0.0.0-20210312174852-ae9464cc3598 - github.com/status-im/go-waku v0.0.0-20210408220731-ff8d4ef8a4e8 + github.com/status-im/go-waku v0.0.0-20210411234359-f9e7589ffdd9 google.golang.org/protobuf v1.25.0 ) diff --git a/examples/chat2/go.sum b/examples/chat2/go.sum index 0856e78c..9b9e414e 100644 --- a/examples/chat2/go.sum +++ b/examples/chat2/go.sum @@ -772,6 +772,8 @@ github.com/status-im/go-waku v0.0.0-20210407211629-9c224c1849b7 h1:I7SKeIuqUum7y github.com/status-im/go-waku v0.0.0-20210407211629-9c224c1849b7/go.mod h1:2fHIqaNF8M8W/DQL5J3R9dXbrTLpOefvD5tbKSvoxBg= github.com/status-im/go-waku v0.0.0-20210408220731-ff8d4ef8a4e8 h1:EB+dNeKJovYLJxnj7dPrhysrhGMkTucdlk2iqPE+XMc= github.com/status-im/go-waku v0.0.0-20210408220731-ff8d4ef8a4e8/go.mod h1:2fHIqaNF8M8W/DQL5J3R9dXbrTLpOefvD5tbKSvoxBg= +github.com/status-im/go-waku v0.0.0-20210411234359-f9e7589ffdd9 h1:smFp8UIU5OYZuWNxyNfIKcCbP74NSqi6EqVmcqh6Zlo= +github.com/status-im/go-waku v0.0.0-20210411234359-f9e7589ffdd9/go.mod h1:2fHIqaNF8M8W/DQL5J3R9dXbrTLpOefvD5tbKSvoxBg= github.com/status-im/go-wakurelay-pubsub v0.4.2 h1:F4UGcP80H0PGaeJ0mRMzA1Ux3DKYiyv/qu3bOR/efTg= github.com/status-im/go-wakurelay-pubsub v0.4.2/go.mod h1:LSCVYR7mnBBsxVJghrGpQ3yJAAATEe6XeQQqGCZhwrE= github.com/status-im/keycard-go v0.0.0-20190316090335-8537d3370df4/go.mod h1:RZLeN1LMWmRsyYjvAu+I6Dm9QmlDaIIt+Y+4Kd7Tp+Q=