mirror of
https://github.com/dolthub/dolt.git
synced 2026-05-12 19:39:32 -05:00
Restructure decentralized examples directory structure (#3730)
This commit is contained in:
@@ -12,23 +12,23 @@ This sample app demonstrates backing a P2P noms app by a decentralized blockstor
|
||||
# Build and Run
|
||||
|
||||
Demo app code is in the
|
||||
[ipfs-chat](https://github.com/attic-labs/noms/tree/master/samples/go/ipfs-chat/)
|
||||
[ipfs-chat](https://github.com/attic-labs/noms/tree/master/samples/go/decent/ipfs-chat/)
|
||||
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/ipfs-chat
|
||||
go get github.com/attic-labs/noms/samples/go/decent/ipfs-chat
|
||||
```
|
||||
* From the noms/samples/go/ipfs-chat directory, build the program with the following command:
|
||||
* From the noms/samples/go/decent/ipfs-chat directory, build the program with the following command:
|
||||
```
|
||||
go build
|
||||
```
|
||||
* Run the ipfs-chat client with the following command:
|
||||
```
|
||||
./ipfs-chat client --username <aname1> --node-idx=2 ipfs:/tmp/ipfs1::chat >& /tmp/err1
|
||||
./ipfs-chat client --username <aname1> --node-idx=1 ipfs:/tmp/ipfs1::chat >& /tmp/err1
|
||||
```
|
||||
* Run a second ipfs-chat client with the following command:
|
||||
```
|
||||
./ipfs-chat client --username <aname2> --node-idx=3 ipfs:/tmp/ipfs2::chat >& /tmp/err2
|
||||
./ipfs-chat client --username <aname2> --node-idx=2 ipfs:/tmp/ipfs2::chat >& /tmp/err2
|
||||
```
|
||||
|
||||
If desired, ipfs-chat can be run as a daemon which will replicate all
|
||||
|
||||
@@ -14,25 +14,25 @@ Currently, nodes have to have a publicly routable IP, but it should be possible
|
||||
# Build and Run
|
||||
|
||||
Demo app code is in the
|
||||
[p2p](https://github.com/attic-labs/noms/tree/master/samples/go/ipfs-chat/p2p)
|
||||
[p2p](https://github.com/attic-labs/noms/tree/master/samples/go/decent/p2p-chat)
|
||||
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/ipfs-chat/p2p
|
||||
go get github.com/attic-labs/noms/samples/go/decent/p2p-chat
|
||||
```
|
||||
* From the noms/samples/go/ipfs-chat/p2p directory, build the program with the following command:
|
||||
* 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 client --username=<aname1> --node-idx=2 /tmp/noms1 >& /tmp/err1
|
||||
./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 client --username=<aname2> --node-idx=3 /tmp/noms2 >& /tmp/err2
|
||||
./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
|
||||
|
||||
+1
-1
@@ -19,7 +19,7 @@ import (
|
||||
"github.com/attic-labs/noms/go/chunks"
|
||||
"github.com/attic-labs/noms/go/d"
|
||||
"github.com/attic-labs/noms/go/hash"
|
||||
"github.com/attic-labs/noms/samples/go/ipfs-chat/dbg"
|
||||
"github.com/attic-labs/noms/samples/go/decent/dbg"
|
||||
"github.com/ipfs/go-ipfs/blocks/blockstore"
|
||||
"github.com/ipfs/go-ipfs/blockservice"
|
||||
"github.com/ipfs/go-ipfs/core"
|
||||
|
||||
@@ -0,0 +1,9 @@
|
||||
# About
|
||||
|
||||
This directory contains two sample applications that demonstrate using Noms in a decentralized environment.
|
||||
|
||||
Both applications implement multiuser chat, using different strategies.
|
||||
|
||||
`p2p-chat` is the simplest possible example: a fully local noms replica is run on each node, and all nodes synchronize continuously with each other over HTTP.
|
||||
|
||||
`ipfs-chat` backs Noms with the [IPFS](https://ipfs.io/) network, so that nodes don't have to keep a full local replica of all data. However, because [Filecoin](http://filecoin.io/) doesn't yet exist, *some node* does have to keep a full replica, so ipfs-chat has a `daemon` mode so that you can run a persistent node somewhere to be the replica of last resort.
|
||||
@@ -17,8 +17,8 @@ import (
|
||||
"github.com/attic-labs/noms/go/datas"
|
||||
"github.com/attic-labs/noms/go/ipfs"
|
||||
"github.com/attic-labs/noms/go/spec"
|
||||
"github.com/attic-labs/noms/samples/go/ipfs-chat/dbg"
|
||||
"github.com/attic-labs/noms/samples/go/ipfs-chat/lib"
|
||||
"github.com/attic-labs/noms/samples/go/decent/dbg"
|
||||
"github.com/attic-labs/noms/samples/go/decent/lib"
|
||||
"github.com/ipfs/go-ipfs/core"
|
||||
"github.com/jroimartin/gocui"
|
||||
"gopkg.in/alecthomas/kingpin.v2"
|
||||
@@ -17,7 +17,7 @@ import (
|
||||
"github.com/attic-labs/noms/go/spec"
|
||||
"github.com/attic-labs/noms/go/types"
|
||||
"github.com/attic-labs/noms/go/util/math"
|
||||
"github.com/attic-labs/noms/samples/go/ipfs-chat/dbg"
|
||||
"github.com/attic-labs/noms/samples/go/decent/dbg"
|
||||
"github.com/ipfs/go-ipfs/core"
|
||||
)
|
||||
|
||||
@@ -83,7 +83,7 @@ func ProcessChatEvents(node *core.IpfsNode, ds datas.Dataset, events chan ChatEv
|
||||
case SearchEvent:
|
||||
processSearch(t, node, ds, event.Event, cInfo)
|
||||
case QuitEvent:
|
||||
dbg.Debug("QuitEvent received, stopping program")
|
||||
dbg.Debug("QuitEvent received, stopping program")
|
||||
stopChan <- struct{}{}
|
||||
return
|
||||
}
|
||||
@@ -10,7 +10,7 @@ import (
|
||||
"os"
|
||||
|
||||
"github.com/attic-labs/noms/go/d"
|
||||
"github.com/attic-labs/noms/samples/go/ipfs-chat/dbg"
|
||||
"github.com/attic-labs/noms/samples/go/decent/dbg"
|
||||
)
|
||||
|
||||
func NewLogger(username string) *log.Logger {
|
||||
@@ -15,7 +15,7 @@ import (
|
||||
"github.com/attic-labs/noms/go/marshal"
|
||||
"github.com/attic-labs/noms/go/types"
|
||||
"github.com/attic-labs/noms/go/util/datetime"
|
||||
"github.com/attic-labs/noms/samples/go/ipfs-chat/dbg"
|
||||
"github.com/attic-labs/noms/samples/go/decent/dbg"
|
||||
)
|
||||
|
||||
type Root struct {
|
||||
@@ -11,7 +11,7 @@ import (
|
||||
|
||||
"github.com/attic-labs/noms/go/d"
|
||||
"github.com/attic-labs/noms/go/hash"
|
||||
"github.com/attic-labs/noms/samples/go/ipfs-chat/dbg"
|
||||
"github.com/attic-labs/noms/samples/go/decent/dbg"
|
||||
"github.com/ipfs/go-ipfs/core"
|
||||
"github.com/jbenet/go-base58"
|
||||
)
|
||||
@@ -71,11 +71,11 @@ func ReceiveMessages(node *core.IpfsNode, events chan ChatEvent, cInfo ClientInf
|
||||
// Publish asks the delegate to format a hash/ClientInfo into a suitable msg
|
||||
// and publishes that using IPFS pubsub.
|
||||
func Publish(node *core.IpfsNode, cInfo ClientInfo, h hash.Hash) {
|
||||
defer func() {
|
||||
if r := recover(); r != nil {
|
||||
dbg.Debug("Publish failed, error: %s", r)
|
||||
}
|
||||
}()
|
||||
defer func() {
|
||||
if r := recover(); r != nil {
|
||||
dbg.Debug("Publish failed, error: %s", r)
|
||||
}
|
||||
}()
|
||||
msgData := cInfo.Delegate.GenMessageData(cInfo, h)
|
||||
m, err := json.Marshal(map[string]string{"user": cInfo.Username, "data": msgData})
|
||||
if err != nil {
|
||||
@@ -14,7 +14,7 @@ import (
|
||||
"github.com/attic-labs/noms/go/datas"
|
||||
"github.com/attic-labs/noms/go/types"
|
||||
"github.com/attic-labs/noms/go/util/math"
|
||||
"github.com/attic-labs/noms/samples/go/ipfs-chat/dbg"
|
||||
"github.com/attic-labs/noms/samples/go/decent/dbg"
|
||||
"github.com/jroimartin/gocui"
|
||||
)
|
||||
|
||||
@@ -13,16 +13,15 @@ import (
|
||||
"path"
|
||||
"syscall"
|
||||
|
||||
"github.com/attic-labs/noms/go/spec"
|
||||
"github.com/attic-labs/noms/samples/go/ipfs-chat/dbg"
|
||||
"github.com/attic-labs/noms/samples/go/ipfs-chat/lib"
|
||||
"github.com/jroimartin/gocui"
|
||||
|
||||
"github.com/attic-labs/noms/go/config"
|
||||
"github.com/attic-labs/noms/go/d"
|
||||
"github.com/attic-labs/noms/go/datas"
|
||||
"github.com/attic-labs/noms/go/ipfs"
|
||||
"github.com/attic-labs/noms/go/spec"
|
||||
"github.com/attic-labs/noms/go/util/profile"
|
||||
"github.com/attic-labs/noms/samples/go/decent/dbg"
|
||||
"github.com/attic-labs/noms/samples/go/decent/lib"
|
||||
"github.com/jroimartin/gocui"
|
||||
"gopkg.in/alecthomas/kingpin.v2"
|
||||
)
|
||||
|
||||
Reference in New Issue
Block a user