update examples to create a wakunode with options

This commit is contained in:
Richard Ramos 2021-04-18 20:07:21 -04:00
parent ef67ff356f
commit e539439f16
No known key found for this signature in database
GPG Key ID: 80D4B01265FDFE8F
6 changed files with 17 additions and 12 deletions

View File

@ -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-20210415175540-7ba8c51bcafe
github.com/status-im/go-waku v0.0.0-20210419000316-ef67ff356f7e
)

View File

@ -609,6 +609,8 @@ github.com/status-im/go-waku v0.0.0-20210415021931-ed9ea4066839 h1:YmwrP2oky+Sio
github.com/status-im/go-waku v0.0.0-20210415021931-ed9ea4066839/go.mod h1:GjrbwNCdtae7sFmvFyXJPSRgnrcmJp3wVSjDZWOG8+s=
github.com/status-im/go-waku v0.0.0-20210415175540-7ba8c51bcafe h1:yGtEg5EzBpSLe5Knge1pHYHTqi59Dv68wOS/lWL6shw=
github.com/status-im/go-waku v0.0.0-20210415175540-7ba8c51bcafe/go.mod h1:GjrbwNCdtae7sFmvFyXJPSRgnrcmJp3wVSjDZWOG8+s=
github.com/status-im/go-waku v0.0.0-20210419000316-ef67ff356f7e h1:bb/99wDRvUQpKQQFGa4lxhJY3LRx821rqv0D4txuD1M=
github.com/status-im/go-waku v0.0.0-20210419000316-ef67ff356f7e/go.mod h1:GjrbwNCdtae7sFmvFyXJPSRgnrcmJp3wVSjDZWOG8+s=
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=

View File

@ -36,13 +36,12 @@ func main() {
prvKey, err := crypto.HexToECDSA(key)
ctx := context.Background()
wakuNode, err := node.New(ctx, prvKey, []net.Addr{hostAddr})
if err != nil {
log.Error(err)
return
}
wakuNode.MountRelay()
wakuNode, err := node.New(ctx,
node.WithPrivateKey(prvKey),
node.WithHostAddress([]net.Addr{hostAddr}),
node.WithWakuRelay(),
)
go writeLoop(wakuNode)
go readLoop(wakuNode)

View File

@ -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-20210415175540-7ba8c51bcafe
github.com/status-im/go-waku v0.0.0-20210419000316-ef67ff356f7e
google.golang.org/protobuf v1.25.0
)

View File

@ -787,6 +787,8 @@ github.com/status-im/go-waku v0.0.0-20210415021931-ed9ea4066839 h1:YmwrP2oky+Sio
github.com/status-im/go-waku v0.0.0-20210415021931-ed9ea4066839/go.mod h1:GjrbwNCdtae7sFmvFyXJPSRgnrcmJp3wVSjDZWOG8+s=
github.com/status-im/go-waku v0.0.0-20210415175540-7ba8c51bcafe h1:yGtEg5EzBpSLe5Knge1pHYHTqi59Dv68wOS/lWL6shw=
github.com/status-im/go-waku v0.0.0-20210415175540-7ba8c51bcafe/go.mod h1:GjrbwNCdtae7sFmvFyXJPSRgnrcmJp3wVSjDZWOG8+s=
github.com/status-im/go-waku v0.0.0-20210419000316-ef67ff356f7e h1:bb/99wDRvUQpKQQFGa4lxhJY3LRx821rqv0D4txuD1M=
github.com/status-im/go-waku v0.0.0-20210419000316-ef67ff356f7e/go.mod h1:GjrbwNCdtae7sFmvFyXJPSRgnrcmJp3wVSjDZWOG8+s=
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=

View File

@ -50,15 +50,17 @@ func main() {
prvKey, err := crypto.HexToECDSA(nodekey)
ctx := context.Background()
wakuNode, err := node.New(ctx, prvKey, []net.Addr{hostAddr})
wakuNode, err := node.New(ctx,
node.WithPrivateKey(prvKey),
node.WithHostAddress([]net.Addr{hostAddr}),
node.WithWakuRelay(),
node.WithWakuStore(false),
)
if err != nil {
fmt.Print(err)
return
}
wakuNode.MountRelay()
wakuNode.MountStore(false, nil)
// use the nickname from the cli flag, or a default if blank
nick := *nickFlag
if len(nick) == 0 {