2019-04-08 13:40:43 +08:00
|
|
|
package main
|
|
|
|
|
2019-04-08 15:26:58 +08:00
|
|
|
//import "context"
|
|
|
|
import (
|
|
|
|
"github.com/ethereum/go-ethereum/swarm/pss"
|
|
|
|
"context"
|
|
|
|
"fmt"
|
2019-04-09 12:39:23 +08:00
|
|
|
"crypto/ecdsa"
|
2019-04-08 15:26:58 +08:00
|
|
|
"os"
|
|
|
|
"time"
|
2019-04-09 12:39:23 +08:00
|
|
|
"io/ioutil"
|
2019-04-09 13:39:37 +08:00
|
|
|
//"log"
|
|
|
|
"github.com/ethereum/go-ethereum/log"
|
2019-04-09 12:39:23 +08:00
|
|
|
"strconv"
|
|
|
|
"github.com/ethereum/go-ethereum/common/hexutil"
|
2019-04-09 12:53:18 +08:00
|
|
|
"github.com/ethereum/go-ethereum/p2p/nat"
|
|
|
|
"github.com/ethereum/go-ethereum/common"
|
2019-04-08 15:26:58 +08:00
|
|
|
"github.com/ethereum/go-ethereum/crypto"
|
|
|
|
"github.com/ethereum/go-ethereum/node"
|
|
|
|
//import "github.com/ethereum/go-ethereum/log"
|
|
|
|
"github.com/ethereum/go-ethereum/p2p"
|
|
|
|
//import "github.com/ethereum/go-ethereum/p2p/enode"
|
|
|
|
//import "github.com/ethereum/go-ethereum/rpc"
|
|
|
|
"github.com/ethereum/go-ethereum/swarm"
|
|
|
|
//import "github.com/ethereum/go-ethereum/swarm/network"
|
|
|
|
bzzapi "github.com/ethereum/go-ethereum/swarm/api"
|
|
|
|
)
|
2019-04-08 13:40:43 +08:00
|
|
|
|
2019-04-09 12:39:23 +08:00
|
|
|
// Two different node processes
|
2019-04-08 13:40:43 +08:00
|
|
|
// So A sends to B, and B receives it
|
|
|
|
// Later also use Feeds to post to own so B can check/pull
|
|
|
|
|
2019-04-09 13:39:37 +08:00
|
|
|
var (
|
|
|
|
// logger
|
|
|
|
Log = log.New("hello-pss", "*")
|
|
|
|
)
|
|
|
|
|
2019-04-09 12:39:23 +08:00
|
|
|
// XXX: Warning, this is bad design. Should use keystore for this.
|
|
|
|
func getHexPrivateKey() string {
|
|
|
|
privateKey, err := crypto.GenerateKey()
|
|
|
|
if err != nil {
|
2019-04-09 13:39:37 +08:00
|
|
|
Log.Crit("can't generate private key", err)
|
2019-04-09 12:39:23 +08:00
|
|
|
}
|
|
|
|
privateKeyBytes := crypto.FromECDSA(privateKey)
|
|
|
|
|
|
|
|
// Debugging, etc
|
|
|
|
fmt.Println("Private Key: ", hexutil.Encode(privateKeyBytes))
|
|
|
|
fmt.Println("Private Key alt: ", hexutil.Encode(privateKeyBytes)[2:])
|
|
|
|
publicKey := privateKey.Public()
|
|
|
|
publicKeyECDSA, ok := publicKey.(*ecdsa.PublicKey)
|
|
|
|
if !ok {
|
2019-04-09 13:39:37 +08:00
|
|
|
log.Crit("error casting public key to ECDSA", err)
|
2019-04-09 12:39:23 +08:00
|
|
|
}
|
|
|
|
publicKeyBytes := crypto.FromECDSAPub(publicKeyECDSA)
|
|
|
|
fmt.Println("Public Key: ", hexutil.Encode(publicKeyBytes[4:]))
|
|
|
|
address := crypto.PubkeyToAddress(*publicKeyECDSA).Hex()
|
|
|
|
fmt.Println("Address: ", address)
|
|
|
|
|
|
|
|
return hexutil.Encode(privateKeyBytes)
|
|
|
|
}
|
|
|
|
|
|
|
|
func getPrivateKeyFromFile(keyfile string) *ecdsa.PrivateKey {
|
|
|
|
contents, err := ioutil.ReadFile(keyfile)
|
|
|
|
if err != nil {
|
2019-04-09 13:39:37 +08:00
|
|
|
log.Crit("Unable to read keyfile", keyfile)
|
2019-04-09 12:39:23 +08:00
|
|
|
}
|
|
|
|
println(string(contents))
|
|
|
|
privateKeyBytes, err := hexutil.Decode(string(contents))
|
|
|
|
if err != nil {
|
2019-04-09 13:39:37 +08:00
|
|
|
log.Crit("Unable to get private key bytes", err)
|
2019-04-09 12:39:23 +08:00
|
|
|
}
|
|
|
|
privateKey, err := crypto.ToECDSA(privateKeyBytes)
|
|
|
|
if err != nil {
|
2019-04-09 13:39:37 +08:00
|
|
|
log.Crit("Unable to get private key", err)
|
2019-04-09 12:39:23 +08:00
|
|
|
}
|
|
|
|
publicKey := privateKey.Public()
|
|
|
|
publicKeyECDSA, ok := publicKey.(*ecdsa.PublicKey)
|
|
|
|
if !ok {
|
2019-04-09 13:39:37 +08:00
|
|
|
log.Crit("error casting public key to ECDSA", err)
|
2019-04-09 12:39:23 +08:00
|
|
|
}
|
|
|
|
publicKeyBytes := crypto.FromECDSAPub(publicKeyECDSA)
|
|
|
|
address := crypto.PubkeyToAddress(*publicKeyECDSA).Hex()
|
|
|
|
fmt.Println("Private Key: ", hexutil.Encode(privateKeyBytes))
|
|
|
|
fmt.Println("Public Key: ", hexutil.Encode(publicKeyBytes[4:]))
|
|
|
|
fmt.Println("Address: ", address)
|
|
|
|
|
|
|
|
return privateKey
|
|
|
|
}
|
|
|
|
|
2019-04-09 12:53:18 +08:00
|
|
|
/////////////////////////////////////////////////////////////////////////////
|
|
|
|
|
2019-04-09 13:39:37 +08:00
|
|
|
//
|
2019-04-09 12:53:18 +08:00
|
|
|
func getp2pConfig(listenaddr string) p2p.Config {
|
|
|
|
return p2p.Config{
|
|
|
|
ListenAddr: listenaddr,
|
|
|
|
MaxPeers: 25,
|
|
|
|
NAT: nat.Any(),
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2019-04-09 12:39:23 +08:00
|
|
|
// Create a node
|
|
|
|
func newNode(port int) (*node.Node, error) {
|
2019-04-08 15:26:58 +08:00
|
|
|
cfg := &node.DefaultConfig
|
2019-04-09 12:39:23 +08:00
|
|
|
cfg.DataDir = fmt.Sprintf("%s%d", ".data_", port)
|
2019-04-09 12:53:18 +08:00
|
|
|
|
|
|
|
// XXX: Lol
|
2019-04-09 13:39:37 +08:00
|
|
|
// XXX: cfg.P2P.ListenAddr = fmt.Sprintf(":%d", port), should work
|
2019-04-09 12:53:18 +08:00
|
|
|
if port == 9600 {
|
|
|
|
cfg.P2P = getp2pConfig(":30400")
|
|
|
|
} else if port == 9601 {
|
|
|
|
cfg.P2P = getp2pConfig(":30401")
|
|
|
|
} else {
|
2019-04-09 13:39:37 +08:00
|
|
|
log.Crit("Ports be fucked up", "yeah")
|
2019-04-09 12:53:18 +08:00
|
|
|
}
|
|
|
|
|
2019-04-09 12:39:23 +08:00
|
|
|
cfg.HTTPPort = port
|
2019-04-09 14:21:27 +08:00
|
|
|
// XXX
|
|
|
|
cfg.IPCPath = "bzz.ipc"
|
2019-04-09 12:39:23 +08:00
|
|
|
fmt.Printf("Current data directory is %s\n", cfg.DataDir)
|
|
|
|
|
2019-04-08 15:26:58 +08:00
|
|
|
return node.New(cfg)
|
|
|
|
}
|
2019-04-08 13:40:43 +08:00
|
|
|
|
2019-04-09 12:39:23 +08:00
|
|
|
// XXX: This is so sloppy, passing privatekey around
|
2019-04-09 12:43:32 +08:00
|
|
|
func newService(bzzdir string, bzzport int, privKey *ecdsa.PrivateKey) func(ctx *node.ServiceContext) (node.Service, error) {
|
2019-04-08 15:26:58 +08:00
|
|
|
return func(ctx *node.ServiceContext) (node.Service, error) {
|
|
|
|
// Create bzzconfig
|
|
|
|
// TODO: Setup swarm port
|
|
|
|
// XXX: What's difference between Privkey and EnodeKey in Init?
|
|
|
|
bzzconfig := bzzapi.NewConfig()
|
2019-04-09 12:43:32 +08:00
|
|
|
bzzconfig.Path = bzzdir
|
|
|
|
bzzconfig.Port = fmt.Sprintf("%d", bzzport)
|
2019-04-08 15:26:58 +08:00
|
|
|
bzzconfig.Init(privKey, privKey)
|
2019-04-08 13:40:43 +08:00
|
|
|
|
2019-04-08 15:26:58 +08:00
|
|
|
return swarm.NewSwarm(bzzconfig, nil)
|
|
|
|
}
|
2019-04-08 13:40:43 +08:00
|
|
|
}
|
|
|
|
|
2019-04-09 12:39:23 +08:00
|
|
|
// TODO: Ensure node starts in light node so it doesn't eat up a lot of disk space
|
2019-04-08 15:26:58 +08:00
|
|
|
|
2019-04-09 12:39:23 +08:00
|
|
|
func run(port int, privateKey *ecdsa.PrivateKey) {
|
2019-04-08 15:26:58 +08:00
|
|
|
// New node
|
2019-04-09 12:39:23 +08:00
|
|
|
node, err := newNode(port)
|
2019-04-08 15:26:58 +08:00
|
|
|
if err != nil {
|
|
|
|
fmt.Fprintf(os.Stderr, "Node failure: %v\n", err)
|
|
|
|
os.Exit(1)
|
|
|
|
}
|
|
|
|
fmt.Printf("Node: %v\n", node)
|
|
|
|
|
|
|
|
// New Swarm service
|
2019-04-09 12:39:23 +08:00
|
|
|
// XXX: Yuck privateKey
|
2019-04-09 12:43:32 +08:00
|
|
|
service := newService(node.InstanceDir(), port, privateKey)
|
2019-04-08 15:26:58 +08:00
|
|
|
// if err != nil {
|
|
|
|
// fmt.Fprint(os.Stderr, "Unable to start swarm service: %v\n", err)
|
|
|
|
// os.Exit(1)
|
|
|
|
// }
|
|
|
|
// fmt.Printf("Swarm service: %x\n", service)
|
|
|
|
|
|
|
|
// Register service
|
|
|
|
err = node.Register(service)
|
|
|
|
if err != nil {
|
|
|
|
fmt.Fprintf(os.Stderr, "Unable to register swarm service: %v\n", err)
|
|
|
|
os.Exit(1)
|
|
|
|
}
|
|
|
|
|
|
|
|
// Start the node
|
|
|
|
err = node.Start()
|
2019-04-08 13:40:43 +08:00
|
|
|
if err != nil {
|
2019-04-08 15:26:58 +08:00
|
|
|
fmt.Fprintf(os.Stderr, "Unable to start node: %v\n", err)
|
2019-04-08 13:40:43 +08:00
|
|
|
os.Exit(1)
|
|
|
|
}
|
|
|
|
|
2019-04-09 13:18:40 +08:00
|
|
|
// TODO: Add other peer?
|
2019-04-09 15:03:36 +08:00
|
|
|
// XXX: Weird because you are adding yourself
|
|
|
|
// XXX: How to detect/derive this? Right now just grepping enode
|
|
|
|
// XXX wrong, need enode data structure or use admin
|
|
|
|
// XXX: Shouldn't this be external IP?
|
|
|
|
|
|
|
|
//node.Server().AddPeer("enode://395a074c059143a68473bcf7edb3bae72bc930cfef5c92399401cedd76c493014d29e75ed1833fe45a2c0e04f0e9f9c64bf029c9c0fb646aa23690e945d70193@127.0.0.1:30400")
|
|
|
|
//node.Server().AddPeer("enode://f716c8cc7cc6674d8332ae1a3fb7f4776285095dc372c20a508e22e7d0a9c006b1626aab7b45802d99957b86bf1c0c14d9ba91df87528c735751e92dd96fa88f@127.0.0.1:30401")
|
|
|
|
|
2019-04-08 15:26:58 +08:00
|
|
|
|
|
|
|
// Get RPC Client
|
2019-04-09 15:03:36 +08:00
|
|
|
// ipcEndpoint
|
2019-04-08 15:26:58 +08:00
|
|
|
client, err := node.Attach()
|
|
|
|
if err != nil {
|
|
|
|
fmt.Fprintf(os.Stderr, "Unable to attach to client: %v\n", err)
|
|
|
|
}
|
2019-04-09 13:18:40 +08:00
|
|
|
// XXX: Not readable
|
2019-04-08 15:26:58 +08:00
|
|
|
fmt.Printf("RPC Client %v\v", client)
|
2019-04-09 15:03:36 +08:00
|
|
|
|
|
|
|
enodeA := "enode://395a074c059143a68473bcf7edb3bae72bc930cfef5c92399401cedd76c493014d29e75ed1833fe45a2c0e04f0e9f9c64bf029c9c0fb646aa23690e945d70193@127.0.0.1:30400"
|
|
|
|
enodeB := "enode://f716c8cc7cc6674d8332ae1a3fb7f4776285095dc372c20a508e22e7d0a9c006b1626aab7b45802d99957b86bf1c0c14d9ba91df87528c735751e92dd96fa88f@127.0.0.1:30401"
|
|
|
|
|
|
|
|
// Oops, wasn't running other node...
|
|
|
|
//enodeA := "enode://395a074c059143a68473bcf7edb3bae72bc930cfef5c92399401cedd76c493014d29e75ed1833fe45a2c0e04f0e9f9c64bf029c9c0fb646aa23690e945d70193@192.168.122.1:30400"
|
|
|
|
//enodeB := "enode://f716c8cc7cc6674d8332ae1a3fb7f4776285095dc372c20a508e22e7d0a9c006b1626aab7b45802d99957b86bf1c0c14d9ba91df87528c735751e92dd96fa88f@192.168.122.1:30401"
|
|
|
|
|
|
|
|
// XXX broken af
|
|
|
|
var res1 bool
|
|
|
|
err = client.Call(&res1, "admin_addPeer", enodeA)
|
|
|
|
if err != nil {
|
|
|
|
log.Crit("Unable to add peer", err)
|
|
|
|
}
|
|
|
|
|
|
|
|
var res2 bool
|
|
|
|
err = client.Call(&res2, "admin_addPeer", enodeB)
|
|
|
|
if err != nil {
|
|
|
|
log.Crit("Unable to add peer", err)
|
|
|
|
}
|
|
|
|
fmt.Println("**** broke af, added some peers mby ", res1, res2)
|
|
|
|
|
|
|
|
// TODO admin get peers here?
|
|
|
|
|
2019-04-08 15:26:58 +08:00
|
|
|
// Simpler, there should be a stdlib fn for waitHealthy anyway
|
2019-04-09 13:18:40 +08:00
|
|
|
time.Sleep(time.Second * 3)
|
2019-04-08 15:26:58 +08:00
|
|
|
|
2019-04-09 13:18:40 +08:00
|
|
|
// XXX: Not readable
|
2019-04-08 15:26:58 +08:00
|
|
|
var nodeinfo p2p.NodeInfo
|
|
|
|
err = client.Call(&nodeinfo, "admin_nodeInfo")
|
|
|
|
if err != nil {
|
|
|
|
fmt.Fprintf(os.Stderr, "Unable to get node info: %v\n", err)
|
|
|
|
}
|
2019-04-09 15:03:36 +08:00
|
|
|
// fmt.Println("*********nodeinfo %s", nodeinfo)
|
2019-04-08 15:26:58 +08:00
|
|
|
|
|
|
|
var baseaddr string
|
|
|
|
err = client.Call(&baseaddr, "pss_baseAddr")
|
|
|
|
if err != nil {
|
|
|
|
fmt.Fprintf(os.Stderr, "Unable to get base addr: %v\n", err)
|
|
|
|
}
|
|
|
|
fmt.Println("baseAddr", baseaddr)
|
|
|
|
|
|
|
|
var pubkey string
|
|
|
|
err = client.Call(&pubkey, "pss_getPublicKey")
|
|
|
|
if err != nil {
|
|
|
|
fmt.Fprintf(os.Stderr, "Unable to get pss public key: %v\n", err)
|
|
|
|
}
|
|
|
|
fmt.Println("PublicKey", pubkey)
|
|
|
|
|
2019-04-09 13:18:40 +08:00
|
|
|
// XXX: Same with baseaddr
|
|
|
|
// 0xd5ac92dd8f593ea7aabf5cfdb35d4d29d87316ffe3ae081750054168e147eb42
|
|
|
|
bobBaseAddr := "0xb208b76c916d5eb84c118c0076b35828f0728a416537786f4515dd6608c4874d"
|
|
|
|
fmt.Println("BobbaseAddr PSS", bobBaseAddr)
|
|
|
|
|
|
|
|
// XXX: This is separate from node generated key, so want to save this contacts or so
|
|
|
|
// f(alice/bob.key, 9600/9601), not confirmed if it is stable if port changes
|
|
|
|
// alice: 0x04c56131d8ded90e79b76b97f26e8fc032597886ff68ab6557f91c4bf1ae46eab94415c6df30bb6479cf40f811977bb2b237787f5b807d97191f7a994a558633e0
|
|
|
|
// bob: 0x04cbd6b75038f2d1e4e8e2754ffadecaaa8d2fdbbb29311dc82a8e1880fce4576f86e3d87ab360bcdde1aaf9a01a2cf232be95684a1152a735ccb4200495e4145c
|
|
|
|
|
2019-04-08 15:26:58 +08:00
|
|
|
var topic string
|
|
|
|
err = client.Call(&topic, "pss_stringToTopic", "foo")
|
|
|
|
|
2019-04-09 13:18:40 +08:00
|
|
|
// Ok, now what?
|
|
|
|
// XX: Also who is pubkey here
|
|
|
|
|
2019-04-08 15:26:58 +08:00
|
|
|
// XXX: Wrong pubkey
|
2019-04-09 13:18:40 +08:00
|
|
|
//receiver := pubkey
|
|
|
|
bobPubKey := "0x04cbd6b75038f2d1e4e8e2754ffadecaaa8d2fdbbb29311dc82a8e1880fce4576f86e3d87ab360bcdde1aaf9a01a2cf232be95684a1152a735ccb4200495e4145c"
|
|
|
|
receiver := bobPubKey
|
|
|
|
fmt.Println("BobPublicKey PSS", bobPubKey)
|
|
|
|
|
|
|
|
// XXX: I don't understand how baseAddr and public key interact
|
|
|
|
// XXX: I also don't understand why you need to register public key
|
|
|
|
err = client.Call(nil, "pss_setPeerPublicKey", bobPubKey, topic, bobBaseAddr)
|
|
|
|
|
|
|
|
// XXX: Shouldn't it at least send a message to itself?
|
|
|
|
// XXX: Add log stuff to see swarm state
|
|
|
|
|
2019-04-08 15:26:58 +08:00
|
|
|
|
2019-04-09 15:03:36 +08:00
|
|
|
// XXX: Blocking, etc? Yeah, so run in bg or so
|
|
|
|
|
|
|
|
// XXX top level for sub declaration teardown
|
2019-04-08 15:26:58 +08:00
|
|
|
msgC := make(chan pss.APIMsg)
|
2019-04-09 15:03:36 +08:00
|
|
|
sub, err := client.Subscribe(context.Background(), "pss", msgC, "receive", topic, false, false)
|
2019-04-08 15:26:58 +08:00
|
|
|
|
2019-04-09 15:03:36 +08:00
|
|
|
time.Sleep(time.Second * 3)
|
|
|
|
|
|
|
|
// XXX Lol
|
|
|
|
if port == 9600 {
|
|
|
|
fmt.Println("**** I AM ALICE, SENDING")
|
|
|
|
err = client.Call(nil, "pss_sendAsym", receiver, topic, common.ToHex([]byte("Hello world")))
|
|
|
|
} else if port == 9601 {
|
|
|
|
fmt.Println("**** I AM BOB, RECEIVING")
|
|
|
|
in := <-msgC
|
|
|
|
fmt.Println("Received message", string(in.Msg), "from", fmt.Sprintf("%x", in.Key))
|
|
|
|
|
|
|
|
} else {
|
|
|
|
fmt.Println("**** I don't know who you are")
|
|
|
|
os.Exit(1)
|
|
|
|
}
|
2019-04-08 15:26:58 +08:00
|
|
|
|
|
|
|
fmt.Printf("All operations successfully completed.\n")
|
|
|
|
|
|
|
|
// Teardown
|
|
|
|
sub.Unsubscribe()
|
|
|
|
client.Close()
|
|
|
|
node.Stop()
|
|
|
|
}
|
|
|
|
|
2019-04-09 13:39:37 +08:00
|
|
|
func init() {
|
|
|
|
// NOTE: taken from ethereum-samples
|
|
|
|
hs := log.StreamHandler(os.Stderr, log.TerminalFormat(true))
|
|
|
|
loglevel := log.LvlInfo
|
|
|
|
// TODO: Setup flag and -v option
|
|
|
|
// if *verbose {
|
|
|
|
// loglevel = log.LvlTrace
|
|
|
|
// }
|
|
|
|
// XXX Trace for now
|
2019-04-09 14:21:27 +08:00
|
|
|
// XXX: unable to forward to any peers volume is crazy
|
2019-04-09 15:03:36 +08:00
|
|
|
loglevel = log.LvlDebug //trace
|
2019-04-09 13:39:37 +08:00
|
|
|
hf := log.LvlFilterHandler(loglevel, hs)
|
|
|
|
h := log.CallerFileHandler(hf)
|
|
|
|
log.Root().SetHandler(h)
|
|
|
|
}
|
|
|
|
|
2019-04-09 12:39:23 +08:00
|
|
|
func main() {
|
|
|
|
fmt.Printf("Hello PSS\n")
|
|
|
|
|
|
|
|
// If 1 arg and it is new then generate new
|
|
|
|
// If 2 args, first is keyfile second port
|
|
|
|
|
|
|
|
/// XXX: Bad CLI design
|
2019-04-09 13:39:37 +08:00
|
|
|
// TODO: Use golang flags
|
2019-04-09 12:39:23 +08:00
|
|
|
// TODO: Pull this out to separate parseArgs function
|
|
|
|
args := os.Args[1:]
|
|
|
|
if len(args) == 1 {
|
|
|
|
if args[0] == "new" {
|
|
|
|
// TODO: Use keystore or something
|
|
|
|
privateKey := getHexPrivateKey()
|
|
|
|
ioutil.WriteFile("new.key", []byte(privateKey), 0644)
|
2019-04-09 13:39:37 +08:00
|
|
|
log.Crit("Thanks for the fish, your private key is now insecurely stored in new.key", args)
|
2019-04-09 12:39:23 +08:00
|
|
|
} else {
|
2019-04-09 13:39:37 +08:00
|
|
|
log.Crit("Unknown argument, please use 'new' or two arguments (keyfile and port)", args)
|
2019-04-09 12:39:23 +08:00
|
|
|
}
|
|
|
|
} else if len(args) == 2 {
|
|
|
|
keyfile := args[0]
|
|
|
|
portArg := args[1]
|
|
|
|
// XXX error handling
|
|
|
|
privateKey := getPrivateKeyFromFile(keyfile)
|
|
|
|
port, err := strconv.Atoi(portArg)
|
|
|
|
if err != nil {
|
2019-04-09 13:39:37 +08:00
|
|
|
log.Crit("Unable to parse port argument", portArg)
|
2019-04-09 12:39:23 +08:00
|
|
|
}
|
|
|
|
// Start engines
|
|
|
|
run(port, privateKey)
|
|
|
|
} else {
|
2019-04-09 13:39:37 +08:00
|
|
|
log.Crit("Wrong number of arguments, should be one (new) or two (keyfile and port)", args)
|
2019-04-09 12:39:23 +08:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2019-04-09 13:39:37 +08:00
|
|
|
// TODO: Here at the moment. Need to make sure it reads nodekey wrt right data dir DONE
|
|
|
|
// And then adjust ports DONE. Then we should be able to run
|
2019-04-08 15:26:58 +08:00
|
|
|
// go run hello_pss.go alice and hello_pss.go bob, and then it should be able to send and recv
|
|
|
|
//
|
2019-04-09 13:39:37 +08:00
|
|
|
// Then also integrate feeds
|
|
|
|
|
|
|
|
|
|
|
|
// XXX Ok the problem is https://github.com/ethereum/go-ethereum/blob/master/swarm/pss/pss.go#L766
|
|
|
|
// Which happens due to not being connected, so manually and possibly some local network stuff here
|
2019-04-09 14:21:27 +08:00
|
|
|
|
|
|
|
// Can't do this because IPC isn't running:
|
|
|
|
// geth attach <path to bzzd.ipc> --exec 'admin.peers'
|
|
|
|
// Not sure how to enable it from Go code, can do with CLI and then connect?
|
|
|
|
// Boom
|
|
|
|
// geth attach .data_9600/bzz.ipc --exec 'admin.peers' # []
|
2019-04-09 15:03:36 +08:00
|
|
|
|
|
|
|
// Ok, progress
|
|
|
|
// TRACE[04-09|14:40:21.249] Dial error task="staticdial 5dac9f05c8b4e3a2 127.0.0.1:30401" err="dial tcp 127.0.0.1:30401: connect: connection refused" caller=dial.go:299
|
|
|
|
// No idea why this is trace, but it makes sense. locally. So let's change.
|
|
|
|
|
|
|
|
// XXX: Seems like it resolves fine
|
|
|
|
// [oskarth@localhost hello-pss]$ ifconfig|grep netmask|awk '{print $2}'
|
|
|
|
// 127.0.0.1
|
|
|
|
// 192.168.122.1
|
|
|
|
// 192.168.10.186
|
|
|
|
|
|
|
|
// TODO: I didn't setup networkid, do I need to for swarm?
|
|
|
|
// Cool we both connected
|