Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
self.put = function (key, recordSignature, callback) {
// 1. check if valid
// 2. do the mapping
// 3. add to other recordStores if any
var recordSignatureMH = multihashing(ipld.marshal(recordSignature), 'sha2-256')
var isValid = iprs.validator(recordSignatureMH, self.mdagStore)
if (!isValid) {
return callback(new Error('record is not valid'))
}
if (!self.mapping[key]) {
self.mapping[key] = []
}
self.mapping[key].push(recordSignature)
callback()
}
}
self.mapping[key].forEach(function (recordSignature) {
var recordSignatureMH = multihashing(ipld.marshal(recordSignature), 'sha2-256')
var isValid = iprs.validator(recordSignatureMH, self.mdagStore)
if (isValid) {
stillValid.push(recordSignature)
}
return
})
self.mapping[key] = stillValid