Skip to content

[Idea/Discussion] "Managed" libp2p node #197

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

Closed
mkg20001 opened this issue May 23, 2018 · 2 comments
Closed

[Idea/Discussion] "Managed" libp2p node #197

mkg20001 opened this issue May 23, 2018 · 2 comments
Labels
status/deferred Conscious decision to pause or backlog

Comments

@mkg20001
Copy link
Member

  • Version: none, yet
  • Platform: *
  • Subsystem: config?

Type: feature

Severity: low/med

Description: "Managed" libp2p node

Basically every time when a project gets created that only uses libp2p and not IPFS the creator has to reinvent a good way to store and read the config, among other things.

In IPFS this is already handled as the config simply gets stored in the repo and additionally gets auto-created, therefore simplifying the process of creating an application on top of IPFS drastically.

For libp2p this process is still manual and involves basically reinventing the wheel of config storage. Sure there are good libraries for this task out there already, but why bother with yet another library if this functionality would be integrated (possibly using one of those libraries). Additionally applications that run in both non-browser and browser environments wouldn't have to worry about creating and testing a config storage mechanism for both.

Example syntax:

const Libp2p = require('libp2p')

const TCP = require('libp2p-tcp')
const SECIO = require('libp2p-secio')
const SPDY = require('libp2p-spdy')
const MPLEX = require('libp2p-mplex')

const modules = {
  transport: [
    new TCP()
  ],
  connection: {
    muxer: [
      SPDY,
      MPLEX
    ],
    crypto: [
      SECIO
    ]
  }
}

const Node = new Libp2p.Managed({
  storage: '$HOME/.my-awesome-app', // this could also be reduced to an 'appID' property based on which the path for the storage folder could be created.
  // appID: 'my-awesome-app', // would set storage on linux to $HOME/.config/libp2p/$appID, win %APPDATA%\Libp2p\%appID%, etc...
  modules: modules, // include the modules. the user-config could allow the user to disable specific modules (e.x. mdns - or some could be off-by-default)
  multiaddrs: ['/ip4/127.0.0.1/tcp/5343', '/ip4/0.0.0.0/tcp/5234/ws'], // multiaddrs to listen on (needs to be specified here as the peerId gets created at a later stage, can also be modified via user-config)
  // autoinit/autostart: true // could be added to simplify things even more
})

Node.init({ignoreIfAlreadyExists: true}, err => {
  if (err) throw err
  Node.start(err => {
    if (err) throw err
    Node.peerInfo.multiaddrs.toArray().forEach(a => console.log('Listening on %s', a.toString()))
  })
})
@daviddias daviddias added the status/deferred Conscious decision to pause or backlog label Jun 4, 2018
@daviddias
Copy link
Member

@mkg20001 I believe what you really want is libp2p/libp2p#22

@achingbrain
Copy link
Member

Closing because #22 has further developments on this topic.

maschad pushed a commit to maschad/js-libp2p that referenced this issue Jun 21, 2023
Updates the interface and symbol return type
maschad pushed a commit to maschad/js-libp2p that referenced this issue Jun 21, 2023
## [8.0.0](libp2p/js-libp2p-mdns@v7.0.5...v8.0.0) (2023-05-04)

### ⚠ BREAKING CHANGES

* update @libp2p/interface-peer-discovery to 2.0.0 (libp2p#197)

### Dependencies

* update @libp2p/interface-peer-discovery to 2.0.0 ([libp2p#197](libp2p/js-libp2p-mdns#197)) ([e8172af](libp2p/js-libp2p-mdns@e8172af))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
status/deferred Conscious decision to pause or backlog
Projects
None yet
Development

No branches or pull requests

3 participants