From 57de180bfdd4873aafc92e5b63c03dcefd56274c Mon Sep 17 00:00:00 2001 From: Alexey Kasyanchuk Date: Wed, 18 Apr 2018 01:08:47 +0300 Subject: [PATCH] little sync protection --- src/background/store.js | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/src/background/store.js b/src/background/store.js index 5e9989f..f0d3570 100644 --- a/src/background/store.js +++ b/src/background/store.js @@ -27,7 +27,15 @@ module.exports = class P2PStore { }, 10000) }) - this.p2p.on('dbStore', (record) => this._syncRecord(record)) + this.p2p.on('dbStore', (record) => { + if(!record || record.id - 1 !== this.id) + { + console.log('out of range peerdb store', record.id) + return + } + + this._syncRecord(record) + }) this.p2p.on('dbSync', ({id} = {}, callback) => { console.log('ask to sync db from', id, 'version')