一段时间后,程序不会在 setInterval() 方法中调用 console.log(infos)。它在几分钟后继续工作,但间隔值与设置值不同,例如,如果我将间隔设置为 200 毫秒,它将在 10 分钟或更长时间后调用 console.log(infos)。我做错了什么?这是我的代码
var bitcore = require('bitcore');
var p2p = require('bitcore-p2p');
var Peer = p2p.Peer;
var Pool = p2p.Pool;
var Networks = bitcore.Networks;
var messages = new p2p.Messages();
peer = new Peer('127.0.0.1', 8333);
pool = new Pool(Networks.livenet);
pool.connect();
var Infos = [],
process.nextTick(function(){
setInterval(function(){
console.log(Infos);
Infos = [];
} , 200);
});
pool.on('peerinv', function (peer, message) {
peer.sendMessage(messages.GetData(message.inventory));
peer.on('tx', function (tx) {
var transaction = tx.transaction;
console.log(transaction.id);
Infos.push({ "txId" : transaction.id });
})
});