Merge branch 'peerdb' of github.com:DEgITx/rats-search into peerdb
This commit is contained in:
commit
9dc7319cad
@ -79,8 +79,17 @@ module.exports = class P2PStore {
|
||||
if(!record.id)
|
||||
return
|
||||
|
||||
if(record.id <= this.id)
|
||||
if(record.id < this.id)
|
||||
return
|
||||
|
||||
record.data = JSON.parse(record.data)
|
||||
|
||||
// check hash
|
||||
if(objectHash(record.data) !== record.hash)
|
||||
{
|
||||
console.log('wrong hash for sync peerdb')
|
||||
return
|
||||
}
|
||||
|
||||
// push to db
|
||||
this._pushToDb(record)
|
||||
@ -92,8 +101,8 @@ module.exports = class P2PStore {
|
||||
{
|
||||
const data = this.sphinx.escape(JSON.stringify(value.data))
|
||||
this.sphinx.query(
|
||||
`insert into store(id, hash, peerId, data` + (value.index ? ', storeIndex' : '') + `)
|
||||
values('${value.id}', '${value.hash}', '${value.peerId}', ${data}` + (value.index ? ',' + this.sphinx.escape(value.index) : '') + ')',
|
||||
`insert into store(id, hash, peerId, data` + (value.index || value.data._index ? ', storeIndex' : '') + `)
|
||||
values('${value.id}', '${value.hash}', '${value.peerId || value.peerid}', ${data}` + (value.index || value.data._index ? ',' + this.sphinx.escape(value.index || value.data._index) : '') + ')',
|
||||
(err) => {
|
||||
if(err)
|
||||
{
|
||||
|
Loading…
Reference in New Issue
Block a user