Skip to content

Instantly share code, notes, and snippets.

@next-marianmoldovan
Created August 20, 2015 06:54
Show Gist options
  • Save next-marianmoldovan/aefa29b8d81a9ded3c0b to your computer and use it in GitHub Desktop.
Save next-marianmoldovan/aefa29b8d81a9ded3c0b to your computer and use it in GitHub Desktop.
var th = require("telehash");
function startMesh(keys){
th.mesh({id:keys}, function(err, mesh){
if(err) return console.log("mesh failed to initialize",err);
// use mesh.* now
console.log(mesh.uri());
});
}
var FileStore = require("file-store")
, store = FileStore("data.json");
store.get("keys", function (err, value) {
if(!value) {
th.generate(function(err, endpoint){
if(err) return console.log("endpoint generation failed",err);
else {
store.set('keys', endpoint);
console.log('Keys created and saved...');
}
});
}
else {
startMesh(value);
}
})
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment