Adding register

This commit is contained in:
Anthony Laibe 2018-07-27 09:25:01 +01:00
parent 9a7d0f1d5b
commit 4fb2cbe683
1 changed files with 16 additions and 1 deletions

View File

@ -132,10 +132,25 @@ __embarkIPFS.resolve = function (name, callback) {
return callback(name + " is not registered");
}
callback(err, res.value);
})
});
};
__embarkIPFS.lookup = function () {
console.error("Not Available");
};
__embarkIPFS.register = function(addr, callback) {
callback = callback || function () {};
if (!this._ipfsConnection) {
var connectionError = new Error('No IPFS connection. Please ensure to call Embark.Names.setProvider()');
return callback(connectionError);
}
this._ipfsConnection.name.publish(addr, function (err, res) {
if (err) {
return callback(addr + " is not publ");
}
callback(err, `https://gateway.ipfs.io/ipns/${res.name}`);
});
};