I have a small network, including bootstrap nodes created with go-libp2p, and a pubsub is setup and working. I can send small messages to other peers by making them subscribe to topics with their own peer ID. This works in my implementation. As I understand, transferring whole files in this way would be very inefficient, though. If I understood this correctly, I also cannot assume that all peers in the network will be connected - when the network grows larger, messages will be routed without direct connection. Right?
So, suppose A knows B’s peer ID, i.e., what host.ID() returns, and vice versa. Could someone explain to me how I would exchange files between A and B, e.g. for A to send a file to B? How do I make A connect to B? How do I send the file from A to B as efficiently as the network allows? Should I exchange more information via the pubsub first? Which file transport method would you recommend? If I have a direct stream connection like in the Ping example, does this mean I can send arbitrary long data over the stream (e.g. 5 GB)? Or is it better to chunk the data?
Lots of questions. I’d be happy about any hints, advice, or additional tutorials.