go-textile icon indicating copy to clipboard operation
go-textile copied to clipboard

Bootstrap from previous/existing peers

Open carsonfarmer opened this issue 5 years ago • 3 comments

Right now, any peer that is shutdown and then restarted will try to bootstrap off the default bootstrap peerlist. However, given the social network nature of many Textile applications (sharing photos, files, etc), it might make more sense to attempt to connect to, and bootstrap from, peers we have previously interacted with. This has the benefit of potentially more quickly finding peers you regularly share with, which is critical in a mobile environment (fast warmup). It additionally may avoid peers trying to connect to Cafes that are difficult or even impossible to reach in some cases.

Possible way forward?

It is not immediately clear where to intercept the boostrapping step of libp2p, but there appears to be a bootstrap libp2p service that can be used? The other possibility is simply letting the default boostrapping happen, and adding an additional Textile Boostrap service connect to peers on top of/in addition to this?

carsonfarmer avatar Jun 20 '19 17:06 carsonfarmer

A suggestion from postables on IRC:

that functionality should really be trivial to add if you have access to peerstore.Peerstore and the peerstore.Peerstore is stored persisently somewhere, (ie using peerstore/pstoreds probably would look something like:

function (s *Service) Bootstrap() {
    if len(s.peerstore.GetPeers()) > 0 {
         // pull individual peers, connect to them
         return 
    }
    // no peers stored so trigger default bootstrapping
    return
}

carsonfarmer avatar Jun 20 '19 17:06 carsonfarmer

See also https://github.com/libp2p/go-libp2p/issues/410 and https://github.com/ipfs/go-ipfs/blob/master/core/bootstrap/bootstrap.go#L63

carsonfarmer avatar Jun 20 '19 17:06 carsonfarmer

Awesome, looks like RTradeLtd has built something similar (untested): https://github.com/RTradeLtd/bootstrap

carsonfarmer avatar Jun 21 '19 17:06 carsonfarmer