How to use the libp2p-record.validator function in libp2p-record

To help you get started, we’ve selected a few libp2p-record examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github libp2p / js-libp2p-distributed-record-store / src / index.js View on Github external
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()
  }
}
github libp2p / js-libp2p-distributed-record-store / src / index.js View on Github external
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

libp2p-record

libp2p record implementation

MIT
Latest version published 3 years ago

Package Health Score

48 / 100
Full package analysis