1
0
mirror of https://github.com/bigchaindb/js-bigchaindb-driver.git synced 2024-11-22 01:36:56 +01:00

cached fetch of outputs

This commit is contained in:
diminator 2017-03-19 14:41:14 +01:00
parent dde78e19e6
commit b9c3cf3517

View File

@ -311,20 +311,24 @@ export function listTransactions({ asset_id, operation }, API_PATH) {
}) })
} }
export function pollStatusAndFetchTransaction(transaction, API_PATH) { export function pollStatusAndFetchTransaction(tx_id, API_PATH) {
return new Promise((resolve, reject) => { return new Promise((resolve, reject) => {
const timer = setInterval(() => { const timer = setInterval(() => {
getStatus(transaction.id, API_PATH) getStatus(tx_id, API_PATH)
.then((res) => { .then((res) => {
console.log('Fetched transaction status:', res); console.log('Fetched transaction status:', res);
if (res.status === 'valid') { if (res.status === 'valid') {
clearInterval(timer); clearInterval(timer);
getTransaction(transaction.id, API_PATH) getTransaction(tx_id, API_PATH)
.then((res) => { .then((res) => {
console.log('Fetched transaction:', res); console.log('Fetched transaction:', res);
resolve(); resolve(res);
}); });
} }
})
.catch((err) => {
clearInterval(timer);
reject(err);
}); });
}, 500) }, 500)
}) })