- continuation of funds not storing correctly in IDB
This commit is contained in:
sairajzero 2021-05-13 20:25:44 +05:30
parent a546e216bf
commit 6d0b5a7d95

View File

@ -10631,33 +10631,32 @@ Bitcoin.Util = {
txid: true, txid: true,
filter: d => d.startsWith(floGlobals.productStr) filter: d => d.startsWith(floGlobals.productStr)
}).then(result => { }).then(result => {
Promise.all(result.data.reverse().map(d => new Promise((res, rej) => { compactIDB.searchData("funds", {
lowerKey: floID + "|",
upperKey: floID + "||"
}).then(funds => {
let writeKeys = new Set();
result.data.reverse().forEach(d => {
if (/continue: /i.test(d[1])) { if (/continue: /i.test(d[1])) {
let ctx = d[1].match(/continue: [0-9a-z]{64}/i).toString().split(": ")[1]; let ctx = d[1].match(/continue: [0-9a-z]{64}/i).toString().split(": ")[1];
console.info(floID + "|" + ctx) funds[floID + "|" + ctx].push({
compactIDB.readData('funds', floID + "|" + ctx).then(fd => {
fd.push({
txid: d[0], txid: d[0],
data: d[1] data: d[1]
}) })
compactIDB.writeData('funds', fd, floID + "|" + ctx) writeKeys.add(floID + "|" + ctx);
.then(r => res([floID + "|" + ctx, fd]))
.catch(e => rej(e))
}).catch(error => rej(error))
} else { } else {
let fd = [{ funds[floID + "|" + d[0]] = [{
txid: d[0], txid: d[0],
data: d[1] data: d[1]
}] }]
compactIDB.addData('funds', fd, floID + "|" + d[0]) writeKeys.add(floID + "|" + d[0]);
.then(r => res([floID + "|" + d[0], fd]))
.catch(e => rej(e))
} }
}))).then(results => { })
writeKeys = Array.from(writeKeys);
Promise.all(writeKeys.map(k => compactIDB.writeData("funds", funds[k], k))).then(results => {
compactIDB.writeData('appendix', result.totalTxs, "lastTx|" + floID); compactIDB.writeData('appendix', result.totalTxs, "lastTx|" + floID);
let data = {}; resolve(writeKeys.map(k => funds[k]))
results.forEach(r => data[r[0]] = r[1]) }).catch(error => reject(error))
resolve(data);
}).catch(error => reject(error)) }).catch(error => reject(error))
}).catch(error => reject(error)) }).catch(error => reject(error))
}).catch(error => reject(error)) }).catch(error => reject(error))