little sync protection

This commit is contained in:
Alexey Kasyanchuk 2018-04-18 01:08:47 +03:00
parent d9cbebe556
commit 57de180bfd

View File

@ -27,7 +27,15 @@ module.exports = class P2PStore {
}, 10000) }, 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) => { this.p2p.on('dbSync', ({id} = {}, callback) => {
console.log('ask to sync db from', id, 'version') console.log('ask to sync db from', id, 'version')