fixed errors in determineClosestSupernode function

This commit is contained in:
Abhishek Sinha 2019-11-28 14:41:53 +05:30
parent 51cb3cefa5
commit 00d1cd9b6e

View File

@ -12935,7 +12935,7 @@
} }
try { try {
if (flo_addr.length < 0) { if (flo_addr.length !== 34) {
showMessage( showMessage(
`WARNING: No Flo Id provided to determine closest Supenode.` `WARNING: No Flo Id provided to determine closest Supenode.`
); );
@ -15087,7 +15087,7 @@
) { ) {
if (typeof flo_id !== null || typeof flo_id !== "undefined") { if (typeof flo_id !== null || typeof flo_id !== "undefined") {
localbitcoinplusplus.kademlia localbitcoinplusplus.kademlia
.determineClosestSupernode(flo_id, 4) .determineClosestSupernode('', '', '', flo_id)
.then(my_closest_su => { .then(my_closest_su => {
if (user_keys.address === my_closest_su[0].data.id) { if (user_keys.address === my_closest_su[0].data.id) {
return callback(true); return callback(true);
@ -22840,15 +22840,20 @@
) { ) {
(async function() { (async function() {
let su_db_data = res_obj.params[0]; let su_db_data = res_obj.params[0];
const primarySuObj = await localbitcoinplusplus.kademlia.determineClosestSupernode(
localbitcoinplusplus.wallets.my_local_flo_address);
const MCS = await localbitcoinplusplus.kademlia.determineClosestSupernode( const MCS = await localbitcoinplusplus.kademlia.determineClosestSupernode(
localbitcoinplusplus.wallets.my_local_flo_address, "",
10 localbitcoinplusplus.master_configurations.supernodesPubKeys.length,
); supernodeKBucket,
primarySuObj[0].data.id
);
// If user is already connected to primary return back // If user is already connected to primary return back
if ( if (
localbitcoinplusplus.MY_SUPERNODE_FLO_ADDRESS == localbitcoinplusplus.MY_SUPERNODE_FLO_ADDRESS ==
MCS[0].data.id primarySuObj[0].data.id
) )
return; return;
@ -24642,7 +24647,7 @@
let getNextClosestSuObj = await localbitcoinplusplus.kademlia.determineClosestSupernode( let getNextClosestSuObj = await localbitcoinplusplus.kademlia.determineClosestSupernode(
"", "",
3, localbitcoinplusplus.master_configurations.MaxBackups,
supernodeKBucket, supernodeKBucket,
req_dt.leaving_supernode_flo_id req_dt.leaving_supernode_flo_id
); );
@ -24728,7 +24733,7 @@
let getSupernodeClosestSuObj = await localbitcoinplusplus.kademlia.determineClosestSupernode( let getSupernodeClosestSuObj = await localbitcoinplusplus.kademlia.determineClosestSupernode(
"", "",
3, localbitcoinplusplus.master_configurations.MaxBackups,
supernodeKBucket, supernodeKBucket,
primarySuFloId primarySuFloId
); );
@ -24871,10 +24876,15 @@
) { ) {
(async function() { (async function() {
let su_db_data = res_obj.params[0]; let su_db_data = res_obj.params[0];
const primarySuObj = await localbitcoinplusplus.kademlia.determineClosestSupernode(
localbitcoinplusplus.wallets.my_local_flo_address);
const MCS = await localbitcoinplusplus.kademlia.determineClosestSupernode( const MCS = await localbitcoinplusplus.kademlia.determineClosestSupernode(
localbitcoinplusplus.wallets.my_local_flo_address, "",
10 localbitcoinplusplus.master_configurations.supernodesPubKeys.length,
); supernodeKBucket,
primarySuObj[0].data.id
);
// If user is already connected to primary return back // If user is already connected to primary return back
if ( if (
@ -26490,8 +26500,7 @@
localbitcoinplusplus.kademlia localbitcoinplusplus.kademlia
.determineClosestSupernode( .determineClosestSupernode(
res_obj.params[0].trader_flo_address, res_obj.params[0].trader_flo_address
localbitcoinplusplus.master_configurations.supernodesPubKeys.length
) )
.then(async subject_floId_closest_su_list => { .then(async subject_floId_closest_su_list => {
const primarySupernodeOfThisUser = subject_floId_closest_su_list[0].data.id; const primarySupernodeOfThisUser = subject_floId_closest_su_list[0].data.id;
@ -28666,7 +28675,8 @@
modifiedRecord.is_deletable = true; modifiedRecord.is_deletable = true;
this.request.objectStore(tablename).put(modifiedRecord); this.db.transaction([tablename], "readwrite")
.objectStore(tablename).put(modifiedRecord);
return resolve(id); return resolve(id);
} }
reject(false); reject(false);