bitpay / bitcore-p2p

Interface to the bitcoin P2P network for bitcore
MIT License
79 stars 275 forks source link

P2P not getting INV message #88

Closed susannaHayrapetyan closed 7 years ago

susannaHayrapetyan commented 7 years ago

Hi, we're using your bitcore-p2p module, to get INV messages.

Our p2p pool is getting INV messages fine, but after some time stops getting them without any error. We have tried to save connection of our pool and bitcoin network using ping and pong messages, but it haven't take any effect.

Code example:

var pool = new Pool({
    network: Networks.livenet,
    maxSize: 150,
    dnsSeed: false,
    addrs: hosts
});

pool.connect();

pool.on('peerinv', function (peer, message) {

                   var Invs = message.inventory;
                    async.eachLimit(Invs, 20, function (inv, cb) {
                        var invHash = lib.util.buffer.bufferToHex(lib.util.buffer.reverse(inv.hash));
                        //console.log(invHash);
                        cb();
                    }, function (err) {
                        assert.equal(null, err); 
                    })

                    peer.sendMessage(messages.Ping());
                    peer.on('ping', function (message) {
                        console.log(message.nonce);
                        peer._sendPong(message.nonce);
                    });

                    peer.on('ready', function() {
                        console.log("ready",pool.inspect());
                        peer.sendMessage(messages.GetAddresses());
                    });

                    peer.on('addr', function(message) {
                        message.addresses.forEach(function(addr) {
                            console.log(addr);
                            pool._connectPeer(addr);
                            console.log(pool.inspect());
                        });
                    });
})
susannaHayrapetyan commented 7 years ago

Sorry, the issue was MongoDb related and has been resolved. So I'm closing it.