poll address summary until balance non-zero or timeout

This commit is contained in:
Wei Lu 2015-05-30 21:19:57 +08:00
parent 70d423f596
commit 9a921ad181
2 changed files with 17 additions and 2 deletions
test/integration

View file

@ -19,10 +19,24 @@ function pollUnspent(blockchain, address, done) {
done(null, unspents)
})
}
function pollSummary(blockchain, address, done) {
blockchain.addresses.summary(address, function (err, result) {
if (err) return done(err)
if(result.balance == 0) {
return setTimeout(function() {
pollSummary(blockchain, address, done)
}, 200)
}
done(null, result)
})
}
module.exports = {
faucetWithdraw: faucetWithdraw,
pollUnspent: pollUnspent
pollUnspent: pollUnspent,
pollSummary: pollSummary
}