为什么这段NodeJs代码在Win7上出现了蓝屏?
Why this piece of NodeJs code has given a BSOD on Win7?
我实际上是在使用 nodejs 中的区块链(使用 WebStorm IDE)。
以下代码在 Win7 上产生了“BAD_POOL_CALLER”蓝屏。你知道为什么吗?谢谢
const Web3 = require('web3');
const web3 = new Web3('https://bsc-dataseed1.binance.org:443');
// Parcourir tous les blocs entre bloc courant et bloc-1000 et lister toutes les transactions de chaque bloc
web3.eth.getBlockNumber().then(blockNumber => {
for(let i=blockNumber-1000; i<=blockNumber; i++) {
web3.eth.getBlock(i).then(block => {
block.transactions.forEach(function(t) {
web3.eth.getTransaction(t).then(transaction => {
console.log(i + ' ' + transaction.hash + ' ' + transaction.from + ' ' + transaction.to)
})
})
})
}
});
我认为使用 setTimeout 函数改进了处理...不确定,但现在似乎工作得更好了。这远非完美,因为我面临另一个问题,但似乎我走在正确的道路上:
// Parcourir tous les blocs entre bloc courant et bloc-1000 et lister
// toutes les transactions de chaque bloc, avec temporisation de 5
// secondes entre chaque bloc.
let index = 0
web3.eth.getBlockNumber().then(blockNumber => {
for (let i = blockNumber - 1000; i <= blockNumber; i++) {
setTimeout(function(index) {
getBlockInfo(i).then()
console.log('next')
console.log("index=" + index)
}, 5000 * index, index)
index = index+1
}
});
async function getBlockInfo(i) {
await web3.eth.getBlock(i).then(block => {
block.transactions.forEach(function (t) {
web3.eth.getTransaction(t).then(transaction => {
console.log(i + ' ' + transaction.hash + ' ' + transaction.from + ' ' + transaction.to)
}).catch((error) => {
console.log('erreur')
})
})
}).catch((error) => {console.log(error)})
}
我实际上是在使用 nodejs 中的区块链(使用 WebStorm IDE)。 以下代码在 Win7 上产生了“BAD_POOL_CALLER”蓝屏。你知道为什么吗?谢谢
const Web3 = require('web3');
const web3 = new Web3('https://bsc-dataseed1.binance.org:443');
// Parcourir tous les blocs entre bloc courant et bloc-1000 et lister toutes les transactions de chaque bloc
web3.eth.getBlockNumber().then(blockNumber => {
for(let i=blockNumber-1000; i<=blockNumber; i++) {
web3.eth.getBlock(i).then(block => {
block.transactions.forEach(function(t) {
web3.eth.getTransaction(t).then(transaction => {
console.log(i + ' ' + transaction.hash + ' ' + transaction.from + ' ' + transaction.to)
})
})
})
}
});
我认为使用 setTimeout 函数改进了处理...不确定,但现在似乎工作得更好了。这远非完美,因为我面临另一个问题,但似乎我走在正确的道路上:
// Parcourir tous les blocs entre bloc courant et bloc-1000 et lister
// toutes les transactions de chaque bloc, avec temporisation de 5
// secondes entre chaque bloc.
let index = 0
web3.eth.getBlockNumber().then(blockNumber => {
for (let i = blockNumber - 1000; i <= blockNumber; i++) {
setTimeout(function(index) {
getBlockInfo(i).then()
console.log('next')
console.log("index=" + index)
}, 5000 * index, index)
index = index+1
}
});
async function getBlockInfo(i) {
await web3.eth.getBlock(i).then(block => {
block.transactions.forEach(function (t) {
web3.eth.getTransaction(t).then(transaction => {
console.log(i + ' ' + transaction.hash + ' ' + transaction.from + ' ' + transaction.to)
}).catch((error) => {
console.log('erreur')
})
})
}).catch((error) => {console.log(error)})
}