fix(peerdb): transfer data fix
This commit is contained in:
parent
9e2dbcc84b
commit
0aa2809f97
@ -77,9 +77,18 @@ module.exports = class P2PStore {
|
|||||||
if(!record.id)
|
if(!record.id)
|
||||||
return
|
return
|
||||||
|
|
||||||
if(record.id <= this.id)
|
if(record.id < this.id)
|
||||||
return
|
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
|
// push to db
|
||||||
this._pushToDb(record)
|
this._pushToDb(record)
|
||||||
}
|
}
|
||||||
@ -90,8 +99,8 @@ module.exports = class P2PStore {
|
|||||||
{
|
{
|
||||||
const data = this.sphinx.escape(JSON.stringify(value.data))
|
const data = this.sphinx.escape(JSON.stringify(value.data))
|
||||||
this.sphinx.query(
|
this.sphinx.query(
|
||||||
`insert into store(id, hash, peerId, data` + (value.index ? ', storeIndex' : '') + `)
|
`insert into store(id, hash, peerId, data` + (value.index || value.data._index ? ', storeIndex' : '') + `)
|
||||||
values('${value.id}', '${value.hash}', '${value.peerId}', ${data}` + (value.index ? ',' + this.sphinx.escape(value.index) : '') + ')',
|
values('${value.id}', '${value.hash}', '${value.peerId || value.peerid}', ${data}` + (value.index || value.data._index ? ',' + this.sphinx.escape(value.index || value.data._index) : '') + ')',
|
||||||
(err) => {
|
(err) => {
|
||||||
if(err)
|
if(err)
|
||||||
{
|
{
|
||||||
|
Loading…
Reference in New Issue
Block a user