Collect application list from blockchain
Supernode now collect list of applications with their adminID from blockchain data
This commit is contained in:
parent
a7d45c32da
commit
bfb86f6085
91
index.html
91
index.html
@ -33,6 +33,8 @@
|
||||
supernodes: {}, //each supnernode must be stored as floID : {uri:<uri>,pubKey:<publicKey>}
|
||||
diskList : ["General"],
|
||||
defaultDisk : "General",
|
||||
applicationList:{},
|
||||
appSubAdmins:{},
|
||||
serveList : [],
|
||||
storedList : [],
|
||||
supernodeConfig : {},
|
||||
@ -6038,30 +6040,27 @@
|
||||
|
||||
initIndexedDBforSupernodeConfig().then(result => {
|
||||
console.log(result)
|
||||
readSupernodeListFromAPI().then(result => {
|
||||
refreshBlockchainData().then(result => {
|
||||
console.log(result)
|
||||
floSupernode.kBucket.launch().then(result => {
|
||||
console.log(result)
|
||||
if (myFloID in floGlobals.supernodes) {
|
||||
initIndexedDBforSupernodeDataStorage(myFloID).then(result => {
|
||||
if (myFloID in floGlobals.supernodes) {
|
||||
initIndexedDBforSupernodeDataStorage(myFloID).then(result => {
|
||||
console.log(result)
|
||||
serverPwd = prompt("Enter Server Pass!")
|
||||
setInterval(autoRefreshBlockchainData, 3600000);
|
||||
floSupernode.initSupernode(serverPwd, myFloID).then(async result => {
|
||||
console.log(result)
|
||||
serverPwd = prompt("Enter Server Pass!")
|
||||
setInterval(refreshBlockchainData, 3600000);
|
||||
floSupernode.initSupernode(serverPwd, myFloID).then(async result => {
|
||||
floGlobals.serveList.push(myFloID)
|
||||
floGlobals.storedList.push(myFloID)
|
||||
await sleep(5000)
|
||||
connectToAllBackupSupernode().then(async result => {
|
||||
console.log(result)
|
||||
floGlobals.serveList.push(myFloID)
|
||||
floGlobals.storedList.push(myFloID)
|
||||
await sleep(5000)
|
||||
connectToAllBackupSupernode().then(async result => {
|
||||
console.log(result)
|
||||
await sleep(2000)
|
||||
reactor.dispatchEvent("indicate_supernode_up",myFloID)
|
||||
})
|
||||
})
|
||||
})
|
||||
}
|
||||
})
|
||||
})
|
||||
await sleep(2000)
|
||||
reactor.dispatchEvent("indicate_supernode_up",myFloID)
|
||||
}).catch(error => console.log(error))
|
||||
}).catch(error => console.log(error))
|
||||
}).catch(error => console.log(error))
|
||||
}
|
||||
}).catch(error => console.log(error))
|
||||
}).catch(error => console.log(error))
|
||||
}
|
||||
|
||||
@ -6073,6 +6072,10 @@
|
||||
config:{},
|
||||
supernodes:{
|
||||
indexes:{ uri:null, pubKey:null }
|
||||
},
|
||||
applications:{},
|
||||
appSubAdmins:{
|
||||
indexes:{ app:null, subAdminID:null }
|
||||
}
|
||||
}
|
||||
compactIDB.setDefaultDB("SupernodeConfig")
|
||||
@ -6100,16 +6103,25 @@
|
||||
})
|
||||
}
|
||||
|
||||
function refreshBlockchainData(){
|
||||
readSupernodeListFromAPI().then(result => {
|
||||
console.log(result)
|
||||
floSupernode.kBucket.launch().then(result => {
|
||||
console.log(result)
|
||||
})
|
||||
}).catch(error => console.log(error))
|
||||
function autoRefreshBlockchainData(){
|
||||
refreshBlockchainData()
|
||||
.then(result => console.log(result))
|
||||
.catch(error => console.log(error))
|
||||
}
|
||||
|
||||
function readSupernodeListFromAPI(){
|
||||
function refreshBlockchainData(){
|
||||
return new Promise((resolve,reject) => {
|
||||
readSupernodeDataFromAPI().then(result => {
|
||||
console.log(result)
|
||||
floSupernode.kBucket.launch().then(result => {
|
||||
console.log(result)
|
||||
resolve("Refreshed Data from blockchain")
|
||||
}).catch(error => reject(error))
|
||||
}).catch(error => reject(error))
|
||||
})
|
||||
}
|
||||
|
||||
function readSupernodeDataFromAPI(){
|
||||
return new Promise((resolve,reject) => {
|
||||
compactIDB.readData("lastTx",floGlobals.adminID).then(lastTx => {
|
||||
floBlockchainAPI.readData(floGlobals.adminID,{ignoreOld:lastTx,sendOnly:true,pattern:"SuperNodeStorage"}).then(result => {
|
||||
@ -6121,16 +6133,21 @@
|
||||
compactIDB.writeData("supernodes",content.addNodes[sn],sn);
|
||||
for(c in content.config)
|
||||
compactIDB.writeData("config",content.config[c],c)
|
||||
for(app in content.application)
|
||||
compactIDB.writeData("applications",content.application[app],app)
|
||||
}
|
||||
compactIDB.writeData("lastTx",result.totalTxs,floGlobals.adminID);
|
||||
compactIDB.readAllData("supernodes").then(result => {
|
||||
floGlobals.supernodes = result
|
||||
compactIDB.readAllData("config").then(result => {
|
||||
floGlobals.supernodeConfig = result
|
||||
resolve("Read supernode from blockchain");
|
||||
})
|
||||
})
|
||||
})
|
||||
compactIDB.readAllData("supernodes").then(supernodes => {
|
||||
floGlobals.supernodes = supernodes
|
||||
compactIDB.readAllData("config").then(config => {
|
||||
floGlobals.supernodeConfig = config
|
||||
compactIDB.readAllData("applications").then(applications => {
|
||||
floGlobals.applicationList = applications
|
||||
resolve("Read supernode from blockchain");
|
||||
}).catch(error => reject(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