libp2p | Libraries and utilities
kandi X-RAY | libp2p Summary
kandi X-RAY | libp2p Summary
Libraries and utilities for distributed (peer-to-peer) applications.
Support
Quality
Security
License
Reuse
Top functions reviewed by kandi - BETA
Currently covering the most popular Java, JavaScript and Python libraries. See a Sample of libp2p
libp2p Key Features
libp2p Examples and Code Snippets
Community Discussions
Trending Discussions on libp2p
QUESTION
I want to try "Runtime Upgrade" and "Storage Migration". I tried by steps as following,but "on_runtime_upgrade" function did not work. Unable to verify that the "on_runtime_upgrade" function is called. The implemented debug log is not output.
- Download "substrate-node-template 3.0".
- Compile it.
- I ran the node with the following command. "target/release/node-template --dev -l runtime = debug".
- Implement "on_runtime_upgrade" in "palet-template".The program I tried "substrate-node-template/pallets/template/lib.rs" is listed below.
- Compile it by "cargo build --release -p node-template-runtime" command.
- Upload "node_template_runtime.compact.wasm" by using "sudo" & "setcode" command.
- I checked the execution log of the node, but I couldn't check the log set to "on_runtime_upgrade".
--lib.rs--
...ANSWER
Answered 2021-Apr-13 at 11:38This Code works. But "debug::info!" does not work. The value of "Something" would be "32".
QUESTION
I am trying to make this example work. It is supposed to create two nodes with mdns support. Mdns is supposed to announce the peer every second, each peer is setup to print a statement once a peer is found.
When running it, the console output is merely empty. It prints out some garbage error in my concern: (node:51841) ExperimentalWarning: Readable[Symbol.asyncIterator] is an experimental feature. This feature could change at any time
How do i enable debugging log so that i can try to understand what is going on under the hood ? I would like to verify the mdns announce packets are issued, and possibly received, or not.
Alternatively, i am trying to use the bootstrap module to begin over wan peers, though expect it to be much slower, thus i would prefer to use mdns.
I tried to add various configuration and modules without much success, it is not clear to me if i am required to use the gossip module if i only want to announce some data on the dht. stuff like that.
any help is appreciated.
...ANSWER
Answered 2020-Oct-18 at 10:57- Logging
To enable debugging, configure the DEBUG
environment variable. Start with DEBUG=*
, it prints log lines like:
QUESTION
I'm trying to implement libp2p inside an electron application, which (obviously) has node support turned on.
I tried catching errors with the following code:
...ANSWER
Answered 2020-Sep-18 at 07:26As it turns out, the error was handled correctly, however the event was connected to a form, which by default refreshes the page if submitted. I had to cancel the default event by:
QUESTION
I'm using this code to play around with IPFS in the browser. I'm wondering how I can access the ip addresses of the webRTC peers? or even know if the peers are actually webRTC, or http peers?
...ANSWER
Answered 2020-Sep-02 at 17:22Looking at your config, it seems that you did not configure any swarm address. A swarm address must be configured for your peer to be diable from other peers in the network.
Some context, in this specific case, you are dealing with a browser environment. Currently, Browsers do not allow listening for connections. One of the limitations is actually that a browser does not provide an "IP Address" that someone can use to reach to it. They are designed in a client-server model where the server IP Address is known and the client will establish the connection with it.
As one of the ways to solve the issue above, there is libp2p-webrtc-star transport. It basically uses a server that will be responsible for listening for connections on behalf of browser nodes. You can use one of the available servers for experimenting https://github.com/libp2p/js-libp2p-webrtc-star#hosted-rendezvous-server. Basically, you should add to your swarm addresses, a multiaddr such as /dns4/wrtc-star1.par.dwebops.pub/tcp/443/wss/p2p-webrtc-star
. Once your node starts, your browser node will establish a connection with the server and the server will inform all the other peers about the peer who joined. These peers can dial your peer via this star server and the multiaddrs will look something like: /dns4/wrtc-star1.par.dwebops.pub/tcp/443/wss/p2p-webrtc-star/p2p/QmSoLPppuBtQSGwKDZT2M73ULpjvfd3aZ6ha4oFGL1KrGM
.
With this setup, you should be able to open multiple browsers and peers discover and connect to each other. If you run the ipfs.swarm.peers
you should see the addresses of the other nodes peers via the star server.
I hope this helps you move forward. I also highly recommend you to check the following examples:
- https://github.com/ipfs/js-ipfs/tree/master/examples/browser-exchange-files
- https://github.com/libp2p/js-libp2p/blob/master/examples/libp2p-in-the-browser
As a complement, there are a few new features being worked on that aim to improve the browser experience in this regard. You can follow the developments on: https://github.com/libp2p/js-libp2p/issues/703
QUESTION
I'm using this code in the browser. It seems to be connecting to ipfs.io via http?. I'm looking to only connect to DHT webRTC peers. I'm guessing I need to pass some option to Ipfs.create? I see an example of custom libp2p here but the amount of options are overwhelming. https://github.com/ipfs/js-ipfs/blob/master/examples/custom-libp2p/index.js
...ANSWER
Answered 2020-Sep-02 at 09:57You can pass the IPFS config options when creating the instance, which enables you to specify the remote WebRTC addresses you want to listen on, and remove/change the Bootstrap nodes to initially connect to. You can see this in the file exchange example at https://github.com/ipfs/js-ipfs/blob/ipfs%400.49.1/examples/browser-exchange-files/public/app.js#L48. So your config might look like this:
QUESTION
I'm trying to decode the buffer stored in the addr key found in the output returned by the IPFS swarm peers function back to the original string. I tried to use the toString() method with all supported encodings, but the output I'm getting is not correctly decoded.
...ANSWER
Answered 2020-Feb-02 at 21:32You should not call toString()
on raw buffer
, but on addr
object:
QUESTION
I think the underlying connection of a stream should have a direction, so how do I know the host is at a server side or client side when the host gets a stream in go-libp2p?
for example, I want to know how I can get the information that the host is at the server side or client side according to the underlying transport connection of a stream in the stream handler function.
...ANSWER
Answered 2019-Nov-29 at 15:45In go-libp2p every steam has a reference to the tranport connection it belongs to, and the transport connection has a stat attribute. so you can get the information like this below, if the connection's stat is DirInbound, then the host is at the server side, if the connection's stat is DirOutbound, then the host is at the client side.
QUESTION
I am using IPFS and trying to understand its structure.
ISSUE: 1 The issue I am facing is that when I am trying to shrink the storage size of IPFS (for testing it is taking so long time, hence I just want to shrink File System for a while) but is unable to shrink.
I tried to configure the config file by changing the StorageMax limit using this command
ipfs config Datastore.StorageMax 1GB
but still it does not work, it accepting (ipfs add ) the files after the 1GB also, why he is not limiting the file-storage?
anyone, please suggest me How to reduce file-system size?
ISSUE: 2 Even in case of IPFS's default storage limit (Which is 10 GB), I saw when I am adding the files on IPFS it is not stopping to store files after crosses 10GB (which was limit). It should not be cross after the limit ends, for this what to do?
below is the config file
...ANSWER
Answered 2019-Nov-14 at 00:43It looks like StorageMax
does not actually limit the size of the IPFS node, instead it's used to determine whether or not to run garbage collection. IPFS will write until the disk is full.
QUESTION
I need to pull this commit into my go project.
I've tried multiple versions of go.mod
:
ANSWER
Answered 2019-Aug-08 at 23:36For your most recent hash aca080dccfc2
, was that merged to master, or what does that hash correspond to? From quick look, aca080dccfc2
does not appear to be on master
, but I'm not sure what your expectations are regarding that commit.
There are restrictions on what hashes are allowed with modules, for example from this slightly older comment in #27043:
It is present in Git if you look at refs/pulls/nnnnn or whatever the ref is, but not in the main branches and tags. Recent changes cut the search down to main branches and tags, which is more appropriate.
Trying to get that aca080dccfc2
hash does not work for me:
QUESTION
my question refers to the libp2p library in golang: https://github.com/libp2p/go-libp2p
This video explains the background: https://www.youtube.com/watch?v=hP0hSZ7E7_Y
The peers in the network communicate via buffered streams rw
. For each new connecting peer there is a new stream created that connects him to an existing peer using addresses. This means there are multiple streams but not all peers are directly connected with each other. Using those streams, the peers can read and write data from it via
rw := bufio.NewReadWriter(bufio.NewReader(stream),bufio.NewWriter(stream))
by writing messages `rw.WriteString("message"),
rw.Flush()``
and reading this messages via message := rw.ReadString(rw)
.
As the peers are not all connected, they only receive messages from directly connected peers and not even all of them if there are multiple connections.
Exactly this problem is mentioned in the video, around time 09:45. The author of the video says that this could be easily modified to send messages not only to directly connected peers but also to multiple hosts. But how can this be done?
My goal is to send message from one peer and that all other peers in the network, also the not directly connected ones, can receive (and answer) it.
...ANSWER
Answered 2019-Jul-31 at 12:40The best way to send multicast or broadcast messages in libp2p is to use PubSub, So every node subscribed to a topic will be notified about sent messages despite not being directly connected to sender node.
You can find an example implementation using Pubsub here. It uses gossibSub implementation from libp2p.
Community Discussions, Code Snippets contain sources that include Stack Exchange Network
Vulnerabilities
No vulnerabilities reported
Install libp2p
Support
Reuse Trending Solutions
Find, review, and download reusable Libraries, Code Snippets, Cloud APIs from over 650 million Knowledge Items
Find more librariesStay Updated
Subscribe to our newsletter for trending solutions and developer bootcamps
Share this Page