Questions tagged [go-libp2p]

16 questions
3
votes
1 answer

go-libp2p - receiving bytes from stream

I'm building my first go-libp2p application and trying to modify the echo example to read a []byte instead of a string as in the example. In my code, I changed the doEcho function to run io.ReadAll(s) instead of bufio.NewReader(s) followed by…
chnski
  • 557
  • 1
  • 4
  • 20
2
votes
1 answer

Program using libp2p to connect using TCP, QUIC or both

I a m writting a P2P application, and I want to decide to send a message to a peer using TCP or QUIC, for a benchmark of the protocols and also for leting the user decide (I want the quic protocol to the the pefered one). But i am having trouble to…
2
votes
1 answer

Remove bootstrapped peers from DHT

I am using golang-libp2p in my project where I am using Kadmelia DHT for peer discovery. I can access info of bootstrapped peers in the following manner. import ( "github.com/libp2p/go-libp2p/core/peer" ) for _, peerAddr := range…
1
vote
0 answers

Unable to connect to peers via DHT if I run my node on MacOS

I'm working on a simple project to get to know how to use DHT. Here it is: https://github.com/ashish10677/dht-implementation This project simply runs a libp2p node and and publishes it's peer id. Other machines can run the same program using the…
1
vote
0 answers

libp2p: Do I need multiple protocols or can I reuse the same, for 2 near-identical functions?

I am new to libp2p. I am designing a new libp2p protocol. I have 2 different message types, which means, messages with different structure and content. Do I need a different protocol for each and therefore and independent handler, or can I reuse…
loophole
  • 37
  • 4
1
vote
1 answer

Can I keep the same ID in libp2p across restarts?

I am writing a test app. For this, it would be ideal if my libp2p nodes would keep their IDs across restarts - otherwise I need to think of some intermediate service which keeps track of NodeIDs for the nodes to connect during a test. Can I do…
loophole
  • 37
  • 4
1
vote
1 answer

Why two stream are required when connecting nodes with libp2p? When handler is called after the peer is connected?

I am following this example - https://github.com/libp2p/go-libp2p/tree/master/examples/chat-with-mdns Here we are initiating a node and using mdns for discovering other nodes on the same local network. I am a bit confused about the connection…
Dhairya Verma
  • 661
  • 1
  • 9
  • 15
1
vote
0 answers

Effective relayed / hole-punching connection between NAT-ed hosts

I want to connect two hosts (libp2p nodes), each of them behind a home router (thus, NAT). The relay example in the official Go implementation repo simulates two undialable hosts and spawns a relay node, which is used to establish the connection…
Fabio B.
  • 9,138
  • 25
  • 105
  • 177
1
vote
1 answer

Troubles on constructing HLS using libp2p-http

I intend to implement a classic HLS example with libp2p, which is as follows https://hackernoon.com/building-a-media-streaming-server-using-go-and-hls-protocol-j85h3wem But I encountered the following errors: 404 page not found My code…
kou
  • 31
  • 3
1
vote
0 answers

Why am I getting a type-error in this libp2p code?

I'm trying to initialize a connection between two libp2p.Host instances. For this I need to get a peerstore.PeerInfo. The obvious way to do this is to take a multiaddr.Multiaddr instance returned by Host.Addrs and pass it to…
Louis Thibault
  • 20,240
  • 25
  • 83
  • 152
0
votes
0 answers

go-libp2p pubsub example not working in multithreaded environment

I am a beginner and am currently playing with the pubsub example from libp2p given here https://github.com/libp2p/go-libp2p/tree/master/examples/pubsub/basic-chat-with-rendezvous I have been able to build the code and run the binary in different…
babla34
  • 15
  • 4
0
votes
1 answer

Undefined: ctx was encountered while running go libp2p

The code is following,it is the an offical demo of go-libp2p.And I didn't encounter any other references or undefined errors // if a remote peer has been passed on the command line, connect to it // and send it 5 ping messages, otherwise…
kou
  • 31
  • 3
0
votes
0 answers

Attempting to marshal and unmarshal libp2p AddrInfo

I am using the libp2p Go library to make a p2p networking stack. I need to unicast messages to other peers on my network. I want to store the AddrInfo struct on my message I unicast so I can send a response back. The below is libp2p library…
pocockn
  • 1,965
  • 5
  • 21
  • 36
0
votes
1 answer

The use of Buffer before saving to IPFS

I am following an IPFS github example to save to IPFS: 'use strict' const IPFS = require('ipfs') const all = require('it-all') async function main () { const node = await IPFS.create() const version = await node.version() …
user938363
  • 9,990
  • 38
  • 137
  • 303
0
votes
1 answer

How can I get a PeerInfo from a Host?

I'm trying to get a PeerInfo from a libp2p.Host instance. I'm able to get a list of multiaddr.Multiaddrs by calling Host.Addrs(), but I'm unable to convert these into a valid peerstore.PeerInfo. Here is my attempt, which panics with the error…
Louis Thibault
  • 20,240
  • 25
  • 83
  • 152
1
2