Merge pull request #11 from avishkarabhishek786/master_hotfix_polishing_for_production
Master hotfix polishing for production
This commit is contained in:
commit
afc9b58b6c
@ -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,43 +12856,51 @@
|
|||||||
) {
|
) {
|
||||||
// updateByVectorClock==true will not return Obj back.
|
// updateByVectorClock==true will not return Obj back.
|
||||||
// Return value will be undefined
|
// Return value will be undefined
|
||||||
try {
|
return new Promise((resolve, reject) => {
|
||||||
if (typeof Obj.vectorClock == "undefined") {
|
|
||||||
Obj.vectorClock = 0;
|
try {
|
||||||
} else if (increaseVectorClock === false) {
|
if (typeof Obj.vectorClock == "undefined") {
|
||||||
// leave the vector clock field unchanged
|
Obj.vectorClock = 0;
|
||||||
} else {
|
} else if (increaseVectorClock === false) {
|
||||||
Obj.vectorClock += 1;
|
// leave the vector clock field unchanged
|
||||||
}
|
} else {
|
||||||
if (typeof Obj.timestamp !== "number") {
|
Obj.vectorClock += 1;
|
||||||
Obj.timestamp = +new Date();
|
|
||||||
}
|
|
||||||
var request = db.transaction([tablename], "readwrite");
|
|
||||||
let store = request.objectStore(tablename);
|
|
||||||
if (updateByVectorClock === true) {
|
|
||||||
if (typeof key == "undefined") {
|
|
||||||
key = Obj[store.keyPath];
|
|
||||||
}
|
|
||||||
let objectStoreRequest = store.get(key);
|
|
||||||
objectStoreRequest.onsuccess = async function(event) {
|
|
||||||
var myRecord = objectStoreRequest.result;
|
|
||||||
if (typeof myRecord !== "object") {
|
|
||||||
Obj.vectorClock = 1;
|
|
||||||
await store.put(Obj);
|
|
||||||
await request.complete;
|
|
||||||
} else if (myRecord.vectorClock + 1 < Obj.vectorClock) {
|
|
||||||
await store.put(Obj);
|
|
||||||
await request.complete;
|
|
||||||
}
|
}
|
||||||
};
|
if (typeof Obj.timestamp !== "number") {
|
||||||
} else {
|
Obj.timestamp = +new Date();
|
||||||
await store.put(Obj);
|
}
|
||||||
await request.complete;
|
var request = db.transaction([tablename], "readwrite");
|
||||||
|
let store = request.objectStore(tablename);
|
||||||
|
if (updateByVectorClock === true) {
|
||||||
|
if (typeof key == "undefined") {
|
||||||
|
key = Obj[store.keyPath];
|
||||||
|
}
|
||||||
|
let objectStoreRequest = store.get(key);
|
||||||
|
objectStoreRequest.onsuccess = function(event) {
|
||||||
|
var myRecord = objectStoreRequest.result;
|
||||||
|
if (typeof myRecord !== "object") {
|
||||||
|
Obj.vectorClock = 1;
|
||||||
|
store.put(Obj);
|
||||||
|
} else if (myRecord.vectorClock + 1 < Obj.vectorClock) {
|
||||||
|
store.put(Obj);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
} else {
|
||||||
|
store.put(Obj);
|
||||||
|
}
|
||||||
|
|
||||||
|
store.onsuccess = function() {
|
||||||
|
resolve(Obj);
|
||||||
|
}
|
||||||
|
|
||||||
|
store.onerror = function(e) {
|
||||||
|
reject(e);
|
||||||
|
}
|
||||||
|
} catch (error) {
|
||||||
|
reject(error);
|
||||||
|
return new Error(error);
|
||||||
}
|
}
|
||||||
return Obj;
|
});
|
||||||
} catch (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
Loading…
Reference in New Issue
Block a user