Merge pull request #11 from avishkarabhishek786/master_hotfix_polishing_for_production

Master hotfix polishing for production
This commit is contained in:
Abhishek Sinha 2019-09-29 21:31:47 +05:30 committed by GitHub
commit afc9b58b6c
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 660 additions and 410 deletions

View File

@ -12411,11 +12411,10 @@
localbitcoinplusplus.master_configurations.supernodeSeeds; localbitcoinplusplus.master_configurations.supernodeSeeds;
if (typeof supernodeSeeds !== "object") if (typeof supernodeSeeds !== "object")
reject("Failed to get supernode seeds."); reject("Failed to get supernode seeds.");
let supernodeSeedsObj = JSON.parse(supernodeSeeds); nearestSupernodeAddresslist = Object.values(supernodeSeeds);
nearestSupernodeAddresslist = Object.values(supernodeSeedsObj);
nearestSupernodeAddresslist.map((m, i) => { nearestSupernodeAddresslist.map((m, i) => {
m.id = i + 1; let sl = Object.assign({id: i+1}, m);
updateinDB("supernodesList", m).catch(e => { updateinDB("supernodesList", sl).catch(e => {
throw new Error(e); throw new Error(e);
}); });
}); });
@ -12848,7 +12847,7 @@
} }
} }
async function updateinDB( function updateinDB(
tablename, tablename,
Obj, Obj,
key, key,
@ -12857,6 +12856,8 @@
) { ) {
// updateByVectorClock==true will not return Obj back. // updateByVectorClock==true will not return Obj back.
// Return value will be undefined // Return value will be undefined
return new Promise((resolve, reject) => {
try { try {
if (typeof Obj.vectorClock == "undefined") { if (typeof Obj.vectorClock == "undefined") {
Obj.vectorClock = 0; Obj.vectorClock = 0;
@ -12875,25 +12876,31 @@
key = Obj[store.keyPath]; key = Obj[store.keyPath];
} }
let objectStoreRequest = store.get(key); let objectStoreRequest = store.get(key);
objectStoreRequest.onsuccess = async function(event) { objectStoreRequest.onsuccess = function(event) {
var myRecord = objectStoreRequest.result; var myRecord = objectStoreRequest.result;
if (typeof myRecord !== "object") { if (typeof myRecord !== "object") {
Obj.vectorClock = 1; Obj.vectorClock = 1;
await store.put(Obj); store.put(Obj);
await request.complete;
} else if (myRecord.vectorClock + 1 < Obj.vectorClock) { } else if (myRecord.vectorClock + 1 < Obj.vectorClock) {
await store.put(Obj); store.put(Obj);
await request.complete;
} }
}; };
} else { } else {
await store.put(Obj); store.put(Obj);
await request.complete; }
store.onsuccess = function() {
resolve(Obj);
}
store.onerror = function(e) {
reject(e);
} }
return Obj;
} catch (error) { } catch (error) {
reject(error);
return new Error(error); return new Error(error);
} }
});
} }
async function removeinDB(tablename, id) { async function removeinDB(tablename, id) {

File diff suppressed because it is too large Load Diff