- 增加功能:工作量证明
通过增加延迟函数setTimeout来延迟resolve的返回
// 确认这条链是否有效
validateChain() {
// Add your code here
let errorlog = [];
let self = this;
return new Promise(function (resolve, reject) {
self.getBlockHeight()
.then(height => {
for (let i = 1; i < height; i++) {
self.getBlock(i)
.then(now_block => {
self.getBlock(now_block.height - 1).then(previousBlock => {
if(!self.isValidNewBlock(now_block, previousBlock)) errorlog.push(i)
})
});
}
setTimeout(function () {
resolve(errorlog)
}, 1 * 1000);
})
})
}