wait for sync from other peers
This commit is contained in:
parent
675e133e1f
commit
9e2dbcc84b
@ -17,7 +17,14 @@ module.exports = class P2PStore {
|
||||
this.id = rows[0].mx + 1;
|
||||
|
||||
console.log('store db index', this.id)
|
||||
|
||||
const syncTimeout = setInterval(() => {
|
||||
if(this.p2p.size <= 0)
|
||||
return
|
||||
|
||||
clearInterval(syncTimeout)
|
||||
this.sync()
|
||||
}, 10000)
|
||||
})
|
||||
|
||||
this.p2p.on('dbStore', (record, callback) => {
|
||||
@ -60,6 +67,7 @@ module.exports = class P2PStore {
|
||||
|
||||
sync()
|
||||
{
|
||||
console.log('sync db on version', this.id)
|
||||
this.p2p.emit('dbSync', {id: this.id}, (data) => {
|
||||
if(!data || !data.records)
|
||||
return
|
||||
|
Loading…
Reference in New Issue
Block a user