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