Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

WIP: getting interop between js and go swarm #12

Closed
wants to merge 2 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
35 changes: 35 additions & 0 deletions examples/swarm-setup.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
package main

import (
metrics "github.com/ipfs/go-libp2p/p2p/metrics"
tu "github.com/ipfs/go-libp2p/testutil"
ma "github.com/jbenet/go-multiaddr"
swarm "go-libp2p/p2p/net/swarm"
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Trying to understand why for swarm and peer it didn't complain that I didn't add github.com/ipfs to the path

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

does this build? That seems wrong to me...

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yeah, this doesnt build for me

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Shed some light :) I'm trying to get it to work too. I was hoping that I could use gx, but installing globally is hanging whyrusleeping/gx#23

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

just add github.com/ipfs/ to the imports, and make sure that GO15VENDOREXPERIMENT is set to 1. it should work. (i'll try it too)

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

you'll also need to change the multiaddr import to use the vendored one:

    ma "gx/QmVUi2ncqnU48zsPgR1rQosDGwY3SSZ1Ndp33j33YjXdsj/go-multiaddr"

This is because of go's stupid insistence that the import path of a type is part of the type.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If you dont want to type this manually, just run gx-go rewrite from the go-libp2p directory (the one with the package.json in it)

peer "go-libp2p/p2p/peer"
context "golang.org/x/net/context"
)

func main() {
ctx, cancel := context.WithCancel(context.Background())
defer cancel()

laddr, err := ma.NewMultiaddr("/ip4/0.0.0.0/tcp/0")
if err != nil {
panic(err)
}

id, err := tu.RandIdentity()
if err != nil {
panic(err)
}

ps := peer.NewPeerstore()

bwc := metrics.NewBandwidthCounter()

netw, err := swarm.NewNetwork(ctx, []ma.Multiaddr{laddr}, id.ID(), ps, bwc)
if err != nil {
panic(err)
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import (
"os"
"time"

ps "github.com/jbenet/go-peerstream"
ps "gx/QmQMkNFMuh1UJbdaggASZpLtCroTnAYcWNenYL5hrzLJrT/go-peerstream"
spdy "gx/QmRmT6MSnfhRDW1PTUGSd3z4fqXK48GUequQAZzeT4c5iC/go-stream-muxer/spdystream"
)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import (
"net"
"os"

ps "github.com/jbenet/go-peerstream"
ps "gx/QmQMkNFMuh1UJbdaggASZpLtCroTnAYcWNenYL5hrzLJrT/go-peerstream"
spdy "gx/QmRmT6MSnfhRDW1PTUGSd3z4fqXK48GUequQAZzeT4c5iC/go-stream-muxer/spdystream"
)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ import (
"sync"
"testing"

ps "github.com/jbenet/go-peerstream"
ps "gx/QmQMkNFMuh1UJbdaggASZpLtCroTnAYcWNenYL5hrzLJrT/go-peerstream"

smux "gx/QmRmT6MSnfhRDW1PTUGSd3z4fqXK48GUequQAZzeT4c5iC/go-stream-muxer"
)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ import (
"syscall"
"unsafe"

"golang.org/x/net/internal/iana"
"gx/Qmbm2LFhcRyHzRqwefzBeazcK2EfUowfeYEAgEvr7N8hAh/go-net/internal/iana"
)

func marshalDst(b []byte, cm *ControlMessage) []byte {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ import (
"os"
"unsafe"

"golang.org/x/net/internal/iana"
"gx/Qmbm2LFhcRyHzRqwefzBeazcK2EfUowfeYEAgEvr7N8hAh/go-net/internal/iana"
)

func setsockoptIPMreq(fd, name int, ifi *net.Interface, grp net.IP) error {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import (
"syscall"
"unsafe"

"golang.org/x/net/internal/iana"
"gx/Qmbm2LFhcRyHzRqwefzBeazcK2EfUowfeYEAgEvr7N8hAh/go-net/internal/iana"
)

func marshal2292HopLimit(b []byte, cm *ControlMessage) []byte {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import (
"syscall"
"unsafe"

"golang.org/x/net/internal/iana"
"gx/Qmbm2LFhcRyHzRqwefzBeazcK2EfUowfeYEAgEvr7N8hAh/go-net/internal/iana"
)

type sysSockoptLen int32
Expand Down