Bug fix
This commit is contained in:
parent
e04672d401
commit
a75fbc067f
@ -149,7 +149,7 @@ function Database(user, password, dbname, host = 'localhost') {
|
|||||||
result.lastTx = Object.fromEntries(tmp.LastTxs.map(a => [a.ID, a.N]));
|
result.lastTx = Object.fromEntries(tmp.LastTxs.map(a => [a.ID, a.N]));
|
||||||
result.sn_config = Object.fromEntries(tmp.Configs.map(a => [a.NAME, a.VAL]));
|
result.sn_config = Object.fromEntries(tmp.Configs.map(a => [a.NAME, a.VAL]));
|
||||||
result.appList = Object.fromEntries(tmp.Applications.map(a => [a.APP_NAME, a.ADMIN_ID]));
|
result.appList = Object.fromEntries(tmp.Applications.map(a => [a.APP_NAME, a.ADMIN_ID]));
|
||||||
result.appSubAdmins = Object.fromEntries(tmp.Applications.map(a => [a.APP_NAME, a.SUB_ADMINS.split(",")]));
|
result.appSubAdmins = Object.fromEntries(tmp.Applications.map(a => [a.APP_NAME, a.SUB_ADMINS ? a.SUB_ADMINS.split(",") : []]));
|
||||||
result.supernodes = Object.fromEntries(tmp.SuperNodes.map(a => [a.FLO_ID, {
|
result.supernodes = Object.fromEntries(tmp.SuperNodes.map(a => [a.FLO_ID, {
|
||||||
pubKey: a.PUB_KEY,
|
pubKey: a.PUB_KEY,
|
||||||
uri: a.URI
|
uri: a.URI
|
||||||
|
|||||||
@ -170,13 +170,13 @@ function readAppSubAdminListFromAPI(base) {
|
|||||||
for (let app in base.appList) {
|
for (let app in base.appList) {
|
||||||
promises.push(new Promise((resolve, reject) => {
|
promises.push(new Promise((resolve, reject) => {
|
||||||
floBlockchainAPI.readData(base.appList[app], {
|
floBlockchainAPI.readData(base.appList[app], {
|
||||||
ignoreOld: base.lastTx[`${app}_${base.appList[app]}`],
|
ignoreOld: base.lastTx[`${app}_${base.appList[app]}`] || 0,
|
||||||
sentOnly: true,
|
sentOnly: true,
|
||||||
pattern: app
|
pattern: app
|
||||||
}).then(result => {
|
}).then(result => {
|
||||||
let subAdmins = new Set(base.appSubAdmins[app]);
|
let subAdmins = new Set(base.appSubAdmins[app]);
|
||||||
result.data.reverse().forEach(data => {
|
result.data.reverse().forEach(data => {
|
||||||
let content = JSON.parse(result.data[i])[app];
|
let content = JSON.parse(data)[app];
|
||||||
if (Array.isArray(content.removeSubAdmin))
|
if (Array.isArray(content.removeSubAdmin))
|
||||||
content.removeSubAdmin.forEach(sa => subAdmins.delete(sa));
|
content.removeSubAdmin.forEach(sa => subAdmins.delete(sa));
|
||||||
if (Array.isArray(content.addSubAdmin))
|
if (Array.isArray(content.addSubAdmin))
|
||||||
@ -198,8 +198,8 @@ function readAppSubAdminListFromAPI(base) {
|
|||||||
Promise.allSettled(promises).then(results => {
|
Promise.allSettled(promises).then(results => {
|
||||||
if (results.reduce((a, r) => r.status === "rejected" ? ++a : a, 0)) {
|
if (results.reduce((a, r) => r.status === "rejected" ? ++a : a, 0)) {
|
||||||
let error = Object.fromEntries(results.filter(r => r.status === "rejected").map(r => r.reason));
|
let error = Object.fromEntries(results.filter(r => r.status === "rejected").map(r => r.reason));
|
||||||
console.error(JSON.stringify(error));
|
console.debug(error);
|
||||||
reject(`subAdmin List for APPS(${Object.keys(error)} might not have loaded correctly`);
|
reject(`subAdmin List for APPS(${Object.keys(error)}) might not have loaded correctly`);
|
||||||
} else
|
} else
|
||||||
resolve("Loaded subAdmin List for all APPs successfully");
|
resolve("Loaded subAdmin List for all APPs successfully");
|
||||||
});
|
});
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user