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:
parent
dde78e19e6
commit
b9c3cf3517
12
index.js
12
index.js
@ -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) => {
|
||||
const timer = setInterval(() => {
|
||||
getStatus(transaction.id, API_PATH)
|
||||
getStatus(tx_id, API_PATH)
|
||||
.then((res) => {
|
||||
console.log('Fetched transaction status:', res);
|
||||
if (res.status === 'valid') {
|
||||
clearInterval(timer);
|
||||
getTransaction(transaction.id, API_PATH)
|
||||
getTransaction(tx_id, API_PATH)
|
||||
.then((res) => {
|
||||
console.log('Fetched transaction:', res);
|
||||
resolve();
|
||||
resolve(res);
|
||||
});
|
||||
}
|
||||
})
|
||||
.catch((err) => {
|
||||
clearInterval(timer);
|
||||
reject(err);
|
||||
});
|
||||
}, 500)
|
||||
})
|
||||
|
Loading…
Reference in New Issue
Block a user