Skip to content
This repository has been archived by the owner on Aug 28, 2021. It is now read-only.

Latest commit

 

History

History
46 lines (32 loc) · 1.68 KB

demo-p2p-chat.md

File metadata and controls

46 lines (32 loc) · 1.68 KB

Home » Use Cases » Decentralized »

About  |  Quickstart  |  Architectures  |  P2P Chat Demo  |  IPFS Chat Demo

Demo App: P2P Decentralized Chat

This sample demonstrates the simplest possible case of building a p2p app on top of Noms. Each node stores a complete copy of the data it is interested in, and peers find each other using IPFS pubsub.

Currently, nodes have to have a publicly routable IP, but it should be possible to use libP2P or similar to connect to most nodes.

Build and Run

Demo app code is in the p2p directory. To get it up and running take the following steps:

  • Use git to clone the noms repository onto your computer:
go get github.com/attic-labs/noms/samples/go/decent/p2p-chat
  • From the noms/samples/go/decent/p2p-chat directory, build the program with the following command:
go build
  • Run the p2p client with the following command:
mkdir /tmp/noms1
./p2p-chat client --username=<aname1> --node-idx=1 /tmp/noms1 >& /tmp/err1
  • Run a second p2p client with the following command:
mkdir /tmp/noms2
./p2p-chat client --username=<aname2> --node-idx=2 /tmp/noms2 >& /tmp/err2

Note: the p2p client relies on IPFS for it's pub/sub implementation. The 'node-idx' argument ensures that each IPFS-based node uses a distinct set of ports. This is useful when running multiple IPFS-based programs on the same machine.