This repository was archived by the owner on Feb 8, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 30
This repository was archived by the owner on Feb 8, 2023. It is now read-only.
DSL for specifying a libp2p node #209
Copy link
Copy link
Open
Labels
Description
@diasdavid showed me https://github.com/ipfs/js-libp2p-ipfs-nodejs/blob/master/src/index.js
I wonder if there is room for a DSL here (or using either js or go as the DSL) for specifying a libp2p node construction, which then can have a compiler/transpiler to the libp2p language of choice.
Example
take something like this (this is obviously wrong, and though it's go-ish, it does not adhere to any language, just a toy example)
import (
Peer "libp2p/core/peer"
Kademlia "libp2p/other/kademlia"
ip6 "libp2p/transports/ip6"
ip4 "libp2p/transports/ip4"
tcp "libp2p/transports/tcp"
udp "libp2p/transports/udp"
utp "libp2p/transports/utp"
mDNS "libp2p/peerDiscovery/mDNS"
Bootstrap "libp2p/peerDiscovery/bootstrap"
Providers "libp2p/contentRouting/providers"
upnp "libp2p/nat/upnp"
natpmp "libp2p/nat/natpmp"
holepunch "libp2p/nat/basicHolepunch"
circuitRelay "libp2p/relay/circuitRelay"
)
type IPFSPeer Peer {
const kad = Kademlia(this.config.Kademlia)
transports {
{ip6,ip4}/{tcp,udp/{utp, udt, quic}} // <--- compact protocol combinations.
// ^ brace combination notation means the same as v
ip4/tcp
ip4/udp/utp
ip4/udp/udt
ip4/udp/quic
ip6/tcp
ip6/udp/utp
ip6/udp/udt
ip6/udp/quic
}
peerDiscovery {
mDNS()
kad
Bootstrap(this.config.Bootstrap)
}
peerRouting {
kad
}
recordStores {
kad
}
contentRouting {
Providers(this.config.Providing, this.recordStores)
}
natTraversal {
upnp()
natpmp()
holepunch()
circuitRelay(this.config.CircuitRelay)
}
}And the above could be compiled to relevant Go code and JS code.
More trouble than it's worth
After sleeping over it, this seems like more trouble than it's worth, but i'll log this idea just in case.
Reactions are currently unavailable