libp2p / go-libp2p-examples

Example libp2p applications
MIT License
338 stars 145 forks source link

how to build a bootstrap node? #22

Closed BenDerPan closed 5 years ago

BenDerPan commented 5 years ago

chat-with-rendezvous example defined a default bootstrap node list , how can I make my PC as the bootstrap node?

...
kadDht,err:=dht.New(ctx,host)
if err !=nil {
    panic(err)
}
//Will this work???
err=kadDht.Bootstrap(ctx)
if err !=nil {
    panic(err)
}
...
zhizouxiao commented 5 years ago

There is no difference between bootstrap nodes and normal nodes. So the only thing you need to do is adding the peerid of your PC node to the variable "bootstrapPeers".

var bootstrapPeers = []string{
    "/ip4/127.0.0.1/tcp/4001/ipfs/Qmeuja1ukLr9KG1A94T2n9y2RYb8KdVpgyUvYgQDV4UQLr",
    "/ip4/104.131.131.82/tcp/4001/ipfs/QmaCpDMGvV2BGHeYERUEnRQAwe3N8SzbUtfsmvsqQLuvuJ",
    "/ip4/104.236.179.241/tcp/4001/ipfs/QmSoLPppuBtQSGwKDZT2M73ULpjvfd3aZ6ha4oFGL1KrGM",
    "/ip4/104.236.76.40/tcp/4001/ipfs/QmSoLV4Bbm51jM9C4gDYZQ9Cy3U6aXMJDAbzgu2fzaDs64",
    "/ip4/128.199.219.111/tcp/4001/ipfs/QmSoLSafTMBsPKadTEgaXctDQVcqN88CNLHXMkTNwMKPnu",
    "/ip4/178.62.158.247/tcp/4001/ipfs/QmSoLer265NRgSp2LA3dPaeykiS1J6DifTC88f5uVQKNAd",
}
BenDerPan commented 5 years ago

@zhizouxiao you mean I need to run ipfs on my PC ? but if there is an minimal example of how to build a bootstrap node is much better.

zhizouxiao commented 5 years ago

You don't need to run ipfs. I mean if you want to run the example chat-with-rendezvous, then add your peerid to bootstrapPeers which is in the front of chat-with-rendezvous.go.

BenDerPan commented 5 years ago

@zhizouxiao great, it works. thx. I will close this issue now.

My implement of a simple bootstrap node simple-bootstrap-node