Conversation
|
Blocked on OpenBazaar/go-onion-transport#3. |
| @@ -0,0 +1,14 @@ | |||
| deps: | |||
| go get -u github.com/libp2p/go-libp2p | |||
There was a problem hiding this comment.
You should be able to just run go get -u ./.... Does that not work?
| go get -u github.com/OpenBazaar/openbazaar-go/net | ||
|
|
||
| build: | ||
| go build -o libp2p-demo *.go |
| @@ -0,0 +1,15 @@ | |||
| # libp2p-chat-app | |||
| # libp2p-chat-app | ||
| Chat app demo based on @whyrusleeping's gist. | ||
|
|
||
| # Instructions |
There was a problem hiding this comment.
Should probably be heading level 2.
| Install deps and build: | ||
|
|
||
| ```shell | ||
| $ make deps |
There was a problem hiding this comment.
Given that we're not using gx, I'd almost just remove the make file and tell users to run:
> go get -u ./...
> go build # or maybe just `go run`?| To start, make sure you have Go installed and set up. Then install libp2p and some other dependencies we need with: | ||
|
|
||
| ```shell | ||
| $ make deps |
There was a problem hiding this comment.
Same, go get -u ./... should work. Also note that we have a convention of using > as the shell prefix for reasons I can't recall.
| "github.com/libp2p/go-libp2p-peerstore" | ||
| "github.com/libp2p/go-libp2p-transport" | ||
| "github.com/multiformats/go-multiaddr" | ||
| "github.com/multiformats/go-multihash" |
There was a problem hiding this comment.
Yeah, we really need to start using type aliases. This is nasty!
|
|
||
| Next up, lets start constructing the pieces! First, we will set up our libp2p host. The host is the main abstraction that users of go-libp2p will deal with, It lets you connect to other peers, open new streams, and register protocol stream handlers. | ||
|
|
||
| Next up, some configuration and initialization. We parse our command-line flags and start working on constructing our libp2p [`Host`](https://godoc.org/github.com/libp2p/go-libp2p-host#Host). We copy the user-provided addresses to listen on and optionally add a tor onion address to listen on if we're using the tor transport. **Note**: Due to some specifics of the tor transport layer's implementation, your local tor instance must be configured such that the SOCKS5 proxy and controller have the **same password**. |
There was a problem hiding this comment.
Is there any documentation we can link to?
| With our new transport configured (in the event that we're using tor), we can create our `Host`. The `Host` object will be most developer's primary point-of-contact with `libp2p`. The `Host` is so-named because it is both a client and a server. Behind the scenes, it manages a whole host (groan) of difficult tasks, including connection management and reuse, stream multiplexing, and encryption. After creating our host, we print out all of the addresses at which it can be reached so that we might tell other clients. This subtly showcases some of `libp2p`'s power, potentially many transports and protocols supported by a single, simple abstraction. | ||
|
|
||
| ```go | ||
| tptOptions := libp2p.Transports(tpts...) |
There was a problem hiding this comment.
FYI, multiple transport/listen options will be merged into one. You can actually just declare an "options" slice and start appending random options to it (transports, listen addresses, etc).
However, this also works.
| @@ -0,0 +1,188 @@ | |||
| package main | |||
There was a problem hiding this comment.
Make sure to keep this code up-to-date with the code in the readme!
|
Is there still interest in this PR? |
unsure if we want to have this as
chat-with-toror replace the oldchatbut given recent conversations about having a dead simple peer discovery example, it may make sense to leave thechatexample alone and update it later.