Fix for flosight changes
This commit is contained in:
parent
fd6e09b157
commit
42f30a12bb
@ -2,7 +2,7 @@
|
||||
|
||||
CREATE TABLE LastTx(
|
||||
floID CHAR(34) NOT NULL,
|
||||
num INT,
|
||||
txid VARCHAR(128),
|
||||
PRIMARY KEY(floID)
|
||||
);
|
||||
|
||||
|
||||
@ -1737,13 +1737,15 @@
|
||||
trusted = new Set();
|
||||
assets = new Set();
|
||||
tags = new Set();
|
||||
lastTx = 0;
|
||||
lastTx = undefined;
|
||||
}
|
||||
floBlockchainAPI.readData(DEFAULT.marketID, {
|
||||
ignoreOld: lastTx,
|
||||
sentOnly: true,
|
||||
pattern: DEFAULT.marketApp
|
||||
}).then(result => {
|
||||
|
||||
var query_options = { sentOnly: true, pattern: DEFAULT.marketApp };
|
||||
if (typeof lastTx == 'string' && /^[0-9a-f]{64}/i.test(lastTx))//lastTx is txid of last tx
|
||||
query_options.after = lastTx;
|
||||
else if (!isNaN(lastTx))//lastTx is tx count (*backward support)
|
||||
query_options.ignoreOld = parseInt(lastTx);
|
||||
floBlockchainAPI.readData(DEFAULT.marketID, query_options).then(result => {
|
||||
result.data.reverse().forEach(data => {
|
||||
var content = JSON.parse(data)[DEFAULT.marketApp];
|
||||
//Node List
|
||||
|
||||
19
src/main.js
19
src/main.js
@ -40,13 +40,16 @@ function refreshData(startup = false) {
|
||||
|
||||
function refreshDataFromBlockchain() {
|
||||
return new Promise((resolve, reject) => {
|
||||
DB.query("SELECT num FROM LastTx WHERE floID=?", [floGlobals.adminID]).then(result => {
|
||||
let lastTx = result.length ? result[0].num : 0;
|
||||
floBlockchainAPI.readData(floGlobals.adminID, {
|
||||
ignoreOld: lastTx,
|
||||
sentOnly: true,
|
||||
pattern: floGlobals.application
|
||||
}).then(result => {
|
||||
DB.query("SELECT txid FROM LastTx WHERE floID=?", [floGlobals.adminID]).then(result => {
|
||||
var query_options = { sentOnly: true, pattern: floGlobals.application };
|
||||
|
||||
let lastTx = result.length ? result[0].txid : undefined;
|
||||
if (typeof lastTx == 'string' && /^[0-9a-f]{64}/i.test(lastTx))//lastTx is txid of last tx
|
||||
query_options.after = lastTx;
|
||||
else if (!isNaN(lastTx))//lastTx is tx count (*backward support)
|
||||
query_options.ignoreOld = parseInt(lastTx);
|
||||
|
||||
floBlockchainAPI.readData(floGlobals.adminID, query_options).then(result => {
|
||||
let promises = [],
|
||||
nodes_change = false,
|
||||
assets_change = false,
|
||||
@ -96,7 +99,7 @@ function refreshDataFromBlockchain() {
|
||||
promises.push(`UPDATE TagList WHERE tag=? SET ${a}=?`, [t, content.Tag.update[t][a]]);
|
||||
}
|
||||
});
|
||||
promises.push(DB.query("INSERT INTO LastTx (floID, num) VALUE (?) ON DUPLICATE KEY UPDATE num=?", [[floGlobals.adminID, result.totalTxs], result.totalTxs]));
|
||||
promises.push(DB.query("INSERT INTO LastTx (floID, txid) VALUE (?) ON DUPLICATE KEY UPDATE txid=?", [[floGlobals.adminID, result.lastItem], result.lastItem]));
|
||||
//Check if all save process were successful
|
||||
Promise.allSettled(promises).then(results => {
|
||||
//console.debug(results.filter(r => r.status === "rejected"));
|
||||
|
||||
@ -203,16 +203,21 @@ bobsFund.config = {
|
||||
|
||||
function refreshBlockchainData(nodeList = []) {
|
||||
return new Promise((resolve, reject) => {
|
||||
DB.query("SELECT num FROM LastTx WHERE floID=?", [bobsFund.config.adminID]).then(result => {
|
||||
let lastTx = result.length ? result[0].num : 0;
|
||||
floBlockchainAPI.readData(bobsFund.config.adminID, {
|
||||
ignoreOld: lastTx,
|
||||
senders: nodeList.concat(bobsFund.config.adminID), //sentOnly: true,
|
||||
tx: true,
|
||||
filter: d => d.startsWith(bobsFund.productStr)
|
||||
}).then(result => {
|
||||
DB.query("SELECT txid FROM LastTx WHERE floID=?", [bobsFund.config.adminID]).then(result => {
|
||||
|
||||
var query_options = {
|
||||
senders: nodeList.concat(bobsFund.config.adminID),
|
||||
tx: true, filter: d => d.startsWith(bobsFund.productStr)
|
||||
};
|
||||
let lastTx = result.length ? result[0].txid : undefined;
|
||||
if (typeof lastTx == 'string' && /^[0-9a-f]{64}/i.test(lastTx))//lastTx is txid of last tx
|
||||
query_options.after = lastTx;
|
||||
else if (!isNaN(lastTx))//lastTx is tx count (*backward support)
|
||||
query_options.ignoreOld = parseInt(lastTx);
|
||||
|
||||
floBlockchainAPI.readData(bobsFund.config.adminID, query_options).then(result => {
|
||||
let txQueries = [];
|
||||
result.data.reverse().forEach(d => {
|
||||
result.items.reverse().forEach(d => {
|
||||
let fund = bobsFund.parse(d.data);
|
||||
if (d.senders.has(bobsFund.config.adminID) && !/close:/.test(d.data)) {
|
||||
let fund_id = d.data.match(/continue: [a-z0-9]{64}\|/);
|
||||
@ -240,10 +245,10 @@ function refreshBlockchainData(nodeList = []) {
|
||||
}
|
||||
}
|
||||
});
|
||||
txQueries.push(["INSERT INTO LastTx (floID, num) VALUE (?) ON DUPLICATE KEY UPDATE num=?",
|
||||
[[bobsFund.config.adminID, result.totalTxs], result.totalTxs]])
|
||||
txQueries.push(["INSERT INTO LastTx (floID, txid) VALUE (?) ON DUPLICATE KEY UPDATE txid=?",
|
||||
[[bobsFund.config.adminID, result.lastItem], result.lastItem]])
|
||||
DB.transaction(txQueries)
|
||||
.then(_ => resolve(result.totalTxs))
|
||||
.then(_ => resolve(result.lastItem))
|
||||
.catch(error => reject(["Bobs-Fund refresh data failed!", error]));
|
||||
}).catch(error => reject(error))
|
||||
}).catch(error => reject(error))
|
||||
|
||||
@ -186,16 +186,21 @@ blockchainBond.config = {
|
||||
|
||||
function refreshBlockchainData(nodeList = []) {
|
||||
return new Promise((resolve, reject) => {
|
||||
DB.query("SELECT num FROM LastTx WHERE floID=?", [blockchainBond.config.adminID]).then(result => {
|
||||
let lastTx = result.length ? result[0].num : 0;
|
||||
floBlockchainAPI.readData(blockchainBond.config.adminID, {
|
||||
ignoreOld: lastTx,
|
||||
senders: nodeList.concat(blockchainBond.config.adminID), //sentOnly: true,
|
||||
tx: true,
|
||||
filter: d => d.startsWith(blockchainBond.productStr)
|
||||
}).then(result => {
|
||||
DB.query("SELECT txid FROM LastTx WHERE floID=?", [blockchainBond.config.adminID]).then(result => {
|
||||
|
||||
var query_options = {
|
||||
senders: nodeList.concat(blockchainBond.config.adminID),
|
||||
tx: true, filter: d => d.startsWith(blockchainBond.productStr)
|
||||
};
|
||||
let lastTx = result.length ? result[0].txid : undefined;
|
||||
if (typeof lastTx == 'string' && /^[0-9a-f]{64}/i.test(lastTx))//lastTx is txid of last tx
|
||||
query_options.after = lastTx;
|
||||
else if (!isNaN(lastTx))//lastTx is tx count (*backward support)
|
||||
query_options.ignoreOld = parseInt(lastTx);
|
||||
|
||||
floBlockchainAPI.readData(blockchainBond.config.adminID, query_options).then(result => {
|
||||
let txQueries = [];
|
||||
result.data.reverse().forEach(d => {
|
||||
result.items.reverse().forEach(d => {
|
||||
let bond = d.senders.has(blockchainBond.config.adminID) ? blockchainBond.parse.main(d.data) : null;
|
||||
if (bond && bond.amount)
|
||||
txQueries.push(["INSERT INTO BlockchainBonds(bond_id, floID, amount_in, begin_date, btc_base, usd_base, gain_cut, min_ipa, max_period, lockin_period) VALUE (?) ON DUPLICATE KEY UPDATE bond_id=bond_id",
|
||||
@ -207,10 +212,10 @@ function refreshBlockchainData(nodeList = []) {
|
||||
[d.txid, details.amountFinal, details.bondID]]);
|
||||
}
|
||||
});
|
||||
txQueries.push(["INSERT INTO LastTx (floID, num) VALUE (?) ON DUPLICATE KEY UPDATE num=?",
|
||||
[[blockchainBond.config.adminID, result.totalTxs], result.totalTxs]])
|
||||
txQueries.push(["INSERT INTO LastTx (floID, txid) VALUE (?) ON DUPLICATE KEY UPDATE txid=?",
|
||||
[[blockchainBond.config.adminID, result.lastItem], result.lastItem]])
|
||||
DB.transaction(txQueries)
|
||||
.then(_ => resolve(result.totalTxs))
|
||||
.then(_ => resolve(result.lastItem))
|
||||
.catch(error => reject(["Blockchain-bonds refresh data failed!", error]));
|
||||
}).catch(error => reject(error))
|
||||
}).catch(error => reject(error))
|
||||
|
||||
Loading…
Reference in New Issue
Block a user