This commit is contained in:
sairajzero 2022-02-06 01:34:09 +05:30
parent e04672d401
commit a75fbc067f
2 changed files with 5 additions and 5 deletions

View File

@ -149,7 +149,7 @@ function Database(user, password, dbname, host = 'localhost') {
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.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, {
pubKey: a.PUB_KEY,
uri: a.URI

View File

@ -170,13 +170,13 @@ function readAppSubAdminListFromAPI(base) {
for (let app in base.appList) {
promises.push(new Promise((resolve, reject) => {
floBlockchainAPI.readData(base.appList[app], {
ignoreOld: base.lastTx[`${app}_${base.appList[app]}`],
ignoreOld: base.lastTx[`${app}_${base.appList[app]}`] || 0,
sentOnly: true,
pattern: app
}).then(result => {
let subAdmins = new Set(base.appSubAdmins[app]);
result.data.reverse().forEach(data => {
let content = JSON.parse(result.data[i])[app];
let content = JSON.parse(data)[app];
if (Array.isArray(content.removeSubAdmin))
content.removeSubAdmin.forEach(sa => subAdmins.delete(sa));
if (Array.isArray(content.addSubAdmin))
@ -198,8 +198,8 @@ function readAppSubAdminListFromAPI(base) {
Promise.allSettled(promises).then(results => {
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));
console.error(JSON.stringify(error));
reject(`subAdmin List for APPS(${Object.keys(error)} might not have loaded correctly`);
console.debug(error);
reject(`subAdmin List for APPS(${Object.keys(error)}) might not have loaded correctly`);
} else
resolve("Loaded subAdmin List for all APPs successfully");
});