Socket
Socket
Sign inDemoInstall

@keymetrics/interdb

Package Overview
Dependencies
Maintainers
4
Versions
9
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@keymetrics/interdb - npm Package Compare versions

Comparing version 0.0.8 to 0.0.9

5

lib/db.js

@@ -94,6 +94,7 @@ 'use strict'

// Sha sum
getShaSum () {
getShaSum (data) {
try {
const hash = crypto.createHash('sha256')
hash.update(JSON.stringify(this.db.data))
hash.update(JSON.stringify(data || this.db.data))
return hash.digest('hex')

@@ -100,0 +101,0 @@ } catch (error) {

15

lib/interdb.js

@@ -31,5 +31,3 @@ 'use strict'

this.clients.once('peer:connected', (identity, socket) => {
this.syncDatabase(socket, () => {
this.emit('synced')
})
this.syncDatabase()
})

@@ -48,3 +46,3 @@ })

this.clients.router(cst.DB_SYNC, (reply) => {
reply(null, this.db.getDatabase())
reply(null, { db: this.db.getDatabase(), shasum: this.db.getShaSum() })
})

@@ -68,3 +66,3 @@

syncDatabase (socket, cb) {
syncDatabase () {
let lastUpdates = []

@@ -81,8 +79,9 @@ const peersNumber = this.clients.getPeers().length

})
if (lastUpdates[0].lastUpdate <= this.db.getLastUpdate()) return cb()
if (lastUpdates[0].lastUpdate <= this.db.getLastUpdate()) return this.emit('synced')
this.clients.send(lastUpdates[0].id, cst.DB_SYNC, (err, res, identity) => {
if (err) return console.log(err)
this.db.updateAll(res, () => {
cb()
if (this.db.getShaSum(res.db.data) !== res.shasum) return this.syncDatabase()
this.db.updateAll(res.db, () => {
this.emit('synced')
})

@@ -89,0 +88,0 @@ })

{
"name": "@keymetrics/interdb",
"version": "0.0.8",
"version": "0.0.9",
"description": "Shared and discoverable database services",

@@ -5,0 +5,0 @@ "main": "index.js",

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc