mediachain / concat

Mediachain daemons
MIT License
42 stars 13 forks source link

Step 0: ping pong in the localhost #7

Closed vyzo closed 7 years ago

vyzo commented 7 years ago

This is the first experiment, with a basic ping pong scenario working.

The are two programs: the directory (mcdir) and the node (mcnode). First you need a directory running; you can do that by running mcdir. Then you can start a couple of nodes, by running mcnode (you need to pass the directory handle printed by mcdir).

Each node exports a RESTful clinet API; it currently supports two methods:

A small example illustrating usage:

shell0 $ mcdir
2016/09/09 21:20:02 Generating key pair
2016/09/09 21:20:02 ID: QmbF87NnyoN3msnmifXhCMUpCRK6C8uXxqAgr93QVa67xS
2016/09/09 21:20:02 I am /ip4/127.0.0.1/tcp/9000/QmbF87NnyoN3msnmifXhCMUpCRK6C8uXxqAgr93QVa67xS`
...

shell1 $ mcnode /ip4/127.0.0.1/tcp/9000/QmbF87NnyoN3msnmifXhCMUpCRK6C8uXxqAgr93QVa67xS
2016/09/09 21:20:30 Generating key pair
2016/09/09 21:20:30 ID: QmXdkCFvS4EzuSF3XeaWAS5HxM2uPC9TKWcTZGoiBERobU
2016/09/09 21:20:30 I am /ip4/127.0.0.1/tcp/9001/QmXdkCFvS4EzuSF3XeaWAS5HxM2uPC9TKWcTZGoiBERobU
2016/09/09 21:20:30 Serving client interface at 127.0.0.1:9002
2016/09/09 21:20:30 Registering with directory
...

shell2 $ mcnode -l 9003 -c 9004 /ip4/127.0.0.1/tcp/9000/QmbF87NnyoN3msnmifXhCMUpCRK6C8uXxqAgr93QVa67xS
2016/09/09 21:21:13 Generating key pair
2016/09/09 21:21:13 ID: QmQg6PiJ6ouBK6pEukZ9rsVRJC7gnt8gvp78gp7XtippJ6
2016/09/09 21:21:13 I am /ip4/127.0.0.1/tcp/9003/QmQg6PiJ6ouBK6pEukZ9rsVRJC7gnt8gvp78gp7XtippJ6
2016/09/09 21:21:13 Serving client interface at 127.0.0.1:9004
2016/09/09 21:21:13 Registering with directory
...

shell3 $ curl http://127.0.0.1:9002/ping/QmQg6PiJ6ouBK6pEukZ9rsVRJC7gnt8gvp78gp7XtippJ6
OK
yusefnapora commented 7 years ago

Got this working locally, but had to do a gx install to get all the deps first. Works as advertised 👍

vyzo commented 7 years ago

I think a setup script that installs the dependencies might be in order.

parkan commented 7 years ago

I can run setup successfully but both build and install give me

[vyzo-ping-pong¹//concat]% ./install.sh                                             (arkadiy@molybdenum:~/mine/concat/)
mc/util.go:4:2: cannot find package "context" in any of:
    /usr/local/Cellar/go/1.6.3/libexec/src/context (from $GOROOT)
    /Users/arkadiy/go/src/context (from $GOPATH)
mc/message.go:4:2: cannot find package "github.com/mediachain/concat/proto" in any of:
    /usr/local/Cellar/go/1.6.3/libexec/src/github.com/mediachain/concat/proto (from $GOROOT)
    /Users/arkadiy/go/src/github.com/mediachain/concat/proto (from $GOPATH)
progs/mcdir/main.go:6:2: cannot find package "github.com/mediachain/concat/mc" in any of:
    /usr/local/Cellar/go/1.6.3/libexec/src/github.com/mediachain/concat/mc (from $GOROOT)
    /Users/arkadiy/go/src/github.com/mediachain/concat/mc (from $GOPATH)

also these rewrites are really not git-friendly, hmm

yusefnapora commented 7 years ago

oh, I think you need go 1.7 - they moved context into the standard lib from a google contrib repo or something

parkan commented 7 years ago

lgtm, let's merge