perf(peerdb): faster store sync

This commit is contained in:
Alexey Kasyanchuk
2018-04-21 01:02:45 +03:00
parent c66dc88962
commit 0768e8d3e0
2 changed files with 19 additions and 6 deletions

View File

@ -5,10 +5,12 @@ const net = require('net')
const JsonSocket = require('json-socket')
const os = require('os');
const isPortReachable = require('./isPortReachable')
const EventEmitter = require('events');
class p2p {
constructor(send = () => {})
{
this.events = new EventEmitter
this.peers = []
this.ignoreAddresses = ['127.0.0.1']
this.messageHandlers = {}
@ -263,6 +265,7 @@ class p2p {
size: this.size,
torrents: data.info ? data.info.torrents || 0 : 0
})
this.events.emit('peer', address)
console.log('new peer', address)
// add some other peers