Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
async _publishPublicKey (key, publicKey) {
if ((!Key.isKey(key))) {
const errMsg = 'datastore key does not have a valid format'
log.error(errMsg)
throw errcode(new Error(errMsg), 'ERR_INVALID_DATASTORE_KEY')
}
if (!publicKey || !publicKey.bytes) {
const errMsg = 'one or more of the provided parameters are not defined'
log.error(errMsg)
throw errcode(new Error(errMsg), 'ERR_UNDEFINED_PARAMETER')
}
// Add public key to routing (buffer key)
try {
const res = await this._routing.put(key.toBuffer(), publicKey.bytes)
async _publishEntry (key, entry) {
if (!(Key.isKey(key))) {
const errMsg = 'datastore key does not have a valid format'
log.error(errMsg)
throw errcode(new Error(errMsg), 'ERR_INVALID_DATASTORE_KEY')
}
let entryData
try {
// Marshal record
entryData = ipns.marshal(entry)
} catch (err) {
log.error(err)
throw err
}