Restructure decentralized examples directory structure (#3730)

This commit is contained in:
Aaron Boodman
2017-09-20 17:39:21 -07:00
committed by GitHub
parent 72da69ebce
commit ec302256b6
21 changed files with 37 additions and 29 deletions
+9
View File
@@ -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"
)