Both the browser demo and the nodejs demos should work now.
To run the example code (currently only cli-demo is working):
- checkout bee
master. in thenode.gofile, comment out the part of passing a key to libp2p - there's a key incompatibility issue where bee uses a key type that isn't supported in libp2p js - this was changed a year ago and for some reason bee migrated to an unsupported key type instead of ed25519. libp2p.ShareTCPListener()needs to be added to the options array of libp2p so that the tcp and ws can use the same tcp port.- run the node with some config, probably testnet or what have you, upload some content (preferably with the bytes endpoint).
- build the project with
pnpm build
To run the cli demo:
cd cli-demoandpnpm start -- /ip4/127.0.0.1/tcp/1634
To run the browser demo:
pnpm --filter @wasp/demo serve- open the browser and navigate to
127.0.0.1:3000and open thedemo.htmlfile. - then have a look at the local listening ports of bee with
curl localhost:1633/addresses | jqand pick the top127.0.0.1underlay that has a websocket transport. paste that into the browser and click connect after intializing the client - pop a chunk address into the textbox and try to retrieve. it assumes the content is plaintest and it will join the content with the joiner and display it in the box below.
Notes: The example in the cli-demo connects to the node via the tcp port, uses ed25519 and will try to download a predefined hash. you can change the hash address in the cli demo to whatever content addressed hash you want to download. just be aware that it will not do automatic manifest indirection for now. just joining. Also be aware that bee, due to some reason, takes 10 seconds to handshake, this is due to some detail in the libp2p abstraction on bee side which isn't very clear on why it takes so long. In any case - don't abort the connection, just wait and it will duely connect.
Diff applied over the bee branch of autotls-v2:
diff --git a/pkg/node/node.go b/pkg/node/node.go
index 5f2a1086..552a05ec 100644
--- a/pkg/node/node.go
+++ b/pkg/node/node.go
@@ -661,7 +661,7 @@ func NewBee(
}
p2ps, err := libp2p.New(ctx, signer, networkID, swarmAddress, addr, addressbook, stateStore, lightNodes, logger, tracer, libp2p.Options{
- PrivateKey: libp2pPrivateKey,
+ // PrivateKey: libp2pPrivateKey,
NATAddr: o.NATAddr,
NATWSSAddr: o.NATWSSAddr,
EnableWS: o.EnableWS,
diff --git a/pkg/p2p/libp2p/libp2p.go b/pkg/p2p/libp2p/libp2p.go
index 74ee3d2b..c6030d10 100644
--- a/pkg/p2p/libp2p/libp2p.go
+++ b/pkg/p2p/libp2p/libp2p.go
@@ -298,7 +298,7 @@ func New(ctx context.Context, signer beecrypto.Signer, networkID uint64, overlay
// of different registers.
storagePath := filepath.Join(o.AutoTLSStorageDir, o.AutoTLSDomain)
- if err := os.MkdirAll(storagePath, 0700); err != nil {
+ if err := os.MkdirAll(storagePath, 0o700); err != nil {
return nil, fmt.Errorf("create certificate storage directory %s: %w", storagePath, err)
}
@@ -339,6 +339,7 @@ func New(ctx context.Context, signer beecrypto.Signer, networkID uint64, overlay
}
opts := []libp2p.Option{
+ libp2p.ShareTCPListener(),
libp2p.ListenAddrStrings(listenAddrs...),
security,
// Use dedicated peerstore instead the global DefaultPeerstore
diff --git a/pkg/topology/kademlia/kademlia.go b/pkg/topology/kademlia/kademlia.go
index 4761b155..b057a1e2 100644
--- a/pkg/topology/kademlia/kademlia.go
+++ b/pkg/topology/kademlia/kademlia.go
@@ -745,7 +745,7 @@ func (k *Kad) Start(ctx context.Context) error {
k.wg.Add(1)
go k.manage()
- k.AddPeers(k.previouslyConnected()...)
+ // k.AddPeers(k.previouslyConnected()...)
go func() {
select {