removed code to add kb users of other supernodes
This commit is contained in:
parent
c3dd189499
commit
8408be332a
@ -11130,6 +11130,7 @@
|
|||||||
this.rpc_req_id = id;
|
this.rpc_req_id = id;
|
||||||
|
|
||||||
(async function(request) {
|
(async function(request) {
|
||||||
|
|
||||||
if (typeof localbitcoinplusplus.wallets.my_local_flo_address == "string") {
|
if (typeof localbitcoinplusplus.wallets.my_local_flo_address == "string") {
|
||||||
request.globalParams.senderFloId = localbitcoinplusplus.wallets.my_local_flo_address;
|
request.globalParams.senderFloId = localbitcoinplusplus.wallets.my_local_flo_address;
|
||||||
|
|
||||||
@ -11157,7 +11158,7 @@
|
|||||||
if (typeof params[0].receiver_flo_address == "string") {
|
if (typeof params[0].receiver_flo_address == "string") {
|
||||||
request.globalParams.receiverFloId = params[0].receiver_flo_address;
|
request.globalParams.receiverFloId = params[0].receiver_flo_address;
|
||||||
}
|
}
|
||||||
|
|
||||||
return resolve(request.toString());
|
return resolve(request.toString());
|
||||||
|
|
||||||
})(request);
|
})(request);
|
||||||
@ -11174,11 +11175,11 @@
|
|||||||
if (typeof user_keys == "object" && typeof user_keys.pubKeyHex == "string") {
|
if (typeof user_keys == "object" && typeof user_keys.pubKeyHex == "string") {
|
||||||
if (localbitcoinplusplus.master_configurations.supernodesPubKeys.includes(user_keys.pubKeyHex)) {
|
if (localbitcoinplusplus.master_configurations.supernodesPubKeys.includes(user_keys.pubKeyHex)) {
|
||||||
if (typeof flo_id !== null || typeof flo_id !== 'undefined') {
|
if (typeof flo_id !== null || typeof flo_id !== 'undefined') {
|
||||||
let karr = KBucket.toArray();
|
// let karr = KBucket.toArray();
|
||||||
let karr_floIds = karr.map(f=>f.data.id);
|
// let karr_floIds = karr.map(f=>f.data.id);
|
||||||
if (!karr_floIds.includes(flo_id)) {
|
// if (!karr_floIds.includes(flo_id)) {
|
||||||
return callback(false);
|
// return callback(false);
|
||||||
}
|
// }
|
||||||
|
|
||||||
localbitcoinplusplus.kademlia.determineClosestSupernode(flo_id)
|
localbitcoinplusplus.kademlia.determineClosestSupernode(flo_id)
|
||||||
.then(my_closest_su=>{
|
.then(my_closest_su=>{
|
||||||
@ -15438,8 +15439,6 @@
|
|||||||
case "trade_balance_updates":
|
case "trade_balance_updates":
|
||||||
if (typeof res_obj.params == "object" && typeof res_obj.params[0] == "object") {
|
if (typeof res_obj.params == "object" && typeof res_obj.params[0] == "object") {
|
||||||
const trade_balance_res = res_obj.params[0];
|
const trade_balance_res = res_obj.params[0];
|
||||||
// Only the relevent user node should get response
|
|
||||||
if(res_obj.params[0].trader_flo_address !== localbitcoinplusplus.wallets.my_local_flo_address) return;
|
|
||||||
// Verify data
|
// Verify data
|
||||||
let trade_info_str = JSON.stringify(trade_balance_res.trade_infos);
|
let trade_info_str = JSON.stringify(trade_balance_res.trade_infos);
|
||||||
let buyer_cash_data_str = JSON.stringify(trade_balance_res.buyer_cash_data);
|
let buyer_cash_data_str = JSON.stringify(trade_balance_res.buyer_cash_data);
|
||||||
@ -15778,6 +15777,51 @@
|
|||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
case "updateUserCryptoBalanceRequest":
|
||||||
|
if (typeof res_obj.params == "object" && typeof res_obj.params[0] == "object") {
|
||||||
|
|
||||||
|
let updateUserCryptoBalanceResponseObject = res_obj.params[0];
|
||||||
|
|
||||||
|
if(typeof res_obj.params[0].trader_flo_address !="string") return;
|
||||||
|
localbitcoinplusplus.kademlia.determineClosestSupernode(res_obj.params[0].trader_flo_address)
|
||||||
|
.then(my_closest_su_list=>{
|
||||||
|
const primarySupernodeOfThisUser = my_closest_su_list[0].data.id;
|
||||||
|
const backup_server_db_instance = localbitcoinplusplus.newBackupDatabase.db[primarySupernodeOfThisUser];
|
||||||
|
|
||||||
|
if(typeof backup_server_db_instance !== "object") {
|
||||||
|
let backup_db_error_msg = `WARNING: Unknown DB instance. DB Backup failed.`;
|
||||||
|
showMessage(backup_db_error_msg);
|
||||||
|
throw new Error(backup_db_error_msg);
|
||||||
|
};
|
||||||
|
|
||||||
|
let SuPubKey = backup_server_db_instance.backup_readDB('userPublicData', updateUserCryptoBalanceResponseObject.trader_flo_address)
|
||||||
|
.then(user_data => {
|
||||||
|
if (typeof user_data !== "object" || user_data.supernode_flo_public_key.length <
|
||||||
|
1)
|
||||||
|
throw new Error(`No such user exists.`);
|
||||||
|
let updateUserCryptoBalanceResponseString = JSON.stringify(
|
||||||
|
updateUserCryptoBalanceResponseObject.updatedBTCBalanceObject);
|
||||||
|
let isBalanceLegit = RM_WALLET.verify(updateUserCryptoBalanceResponseString,
|
||||||
|
updateUserCryptoBalanceResponseObject.updatedBTCBalanceObjectSign,
|
||||||
|
user_data.supernode_flo_public_key
|
||||||
|
);
|
||||||
|
if (isBalanceLegit) {
|
||||||
|
backup_server_db_instance.backup_updateinDB("crypto_balances", updateUserCryptoBalanceResponseObject.updatedBTCBalanceObject,
|
||||||
|
user_data.trader_flo_address);
|
||||||
|
if (localbitcoinplusplus.wallets.my_local_flo_address ==
|
||||||
|
updateUserCryptoBalanceResponseObject.trader_flo_address) {
|
||||||
|
displayBalances(updateUserCryptoBalanceResponseObject.trader_flo_address);
|
||||||
|
showMessage(`INFO: Your balance is updated.`);
|
||||||
|
}
|
||||||
|
return true;
|
||||||
|
} else {
|
||||||
|
showMessage(`WARNING: Failed to update balance in your DB. Please refresh.`);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
});
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
|
||||||
default:
|
default:
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
@ -16020,13 +16064,13 @@
|
|||||||
return;
|
return;
|
||||||
} else if(typeof res_obj.globalParams.primarySupernode=="string"
|
} else if(typeof res_obj.globalParams.primarySupernode=="string"
|
||||||
&& res_obj.globalParams.primarySupernode !== localbitcoinplusplus.MY_SUPERNODE_FLO_ADDRESS) {
|
&& res_obj.globalParams.primarySupernode !== localbitcoinplusplus.MY_SUPERNODE_FLO_ADDRESS) {
|
||||||
processBackupUserOnMesssageRequest(response);
|
if (typeof res_obj.globalParams.receiverFloId !== 'string' ||
|
||||||
return;
|
res_obj.globalParams.receiverFloId !== localbitcoinplusplus.MY_SUPERNODE_FLO_ADDRESS) {
|
||||||
|
processBackupUserOnMesssageRequest(response);
|
||||||
|
return;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Temporary. Remove this line
|
|
||||||
showMessage(`INFO: PRIMARY SUPERNODE FLO ID: ${res_obj.globalParams.primarySupernode}.`);
|
|
||||||
|
|
||||||
if (typeof res_obj.method !== "undefined") {
|
if (typeof res_obj.method !== "undefined") {
|
||||||
let response_from_sever;
|
let response_from_sever;
|
||||||
|
|
||||||
@ -16723,6 +16767,8 @@
|
|||||||
break;
|
break;
|
||||||
|
|
||||||
case "addNewKbucketNode":
|
case "addNewKbucketNode":
|
||||||
|
if (!localbitcoinplusplus.master_configurations.supernodesPubKeys
|
||||||
|
.includes(localbitcoinplusplus.wallets.my_local_flo_public_key)) return;
|
||||||
try {
|
try {
|
||||||
let mss = '';
|
let mss = '';
|
||||||
let tid = res_obj.params[0].trader_flo_address || res_obj.globalParams.senderFloId;
|
let tid = res_obj.params[0].trader_flo_address || res_obj.globalParams.senderFloId;
|
||||||
@ -17029,10 +17075,7 @@
|
|||||||
console.log(res_obj);
|
console.log(res_obj);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Temporary. Remove this line
|
|
||||||
showMessage(`INFO: PRIMARY SUPERNODE FLO ID: ${res_obj.globalParams.primarySupernode}.`);
|
|
||||||
|
|
||||||
if (typeof res_obj.method !== "undefined") {
|
if (typeof res_obj.method !== "undefined") {
|
||||||
let response_from_sever;
|
let response_from_sever;
|
||||||
|
|
||||||
@ -17878,11 +17921,15 @@
|
|||||||
break;
|
break;
|
||||||
|
|
||||||
case "addNewKbucketNode":
|
case "addNewKbucketNode":
|
||||||
|
if (!localbitcoinplusplus.master_configurations.supernodesPubKeys
|
||||||
|
.includes(localbitcoinplusplus.wallets.my_local_flo_public_key)) return;
|
||||||
try {
|
try {
|
||||||
let mss = '';
|
let mss = '';
|
||||||
let tid = res_obj.params[0].trader_flo_address || res_obj.globalParams.senderFloId;
|
let tid = res_obj.params[0].trader_flo_address || res_obj.globalParams.senderFloId;
|
||||||
localbitcoinplusplus.kademlia.determineClosestSupernode(tid)
|
localbitcoinplusplus.kademlia.determineClosestSupernode(tid)
|
||||||
.then(async my_closest_su=>{
|
.then(async my_closest_su=>{
|
||||||
|
|
||||||
|
if (my_closest_su[0].data.id !== localbitcoinplusplus.wallets.my_local_flo_address) return;
|
||||||
|
|
||||||
const newKbucketObjectObj = res_obj.params[0];
|
const newKbucketObjectObj = res_obj.params[0];
|
||||||
const primarySupernodeOfThisUser = my_closest_su_list[0].data.id;
|
const primarySupernodeOfThisUser = my_closest_su_list[0].data.id;
|
||||||
@ -18311,9 +18358,7 @@
|
|||||||
if (!request_array.includes(msgObj.method)) {
|
if (!request_array.includes(msgObj.method)) {
|
||||||
const RM_WALLET = new localbitcoinplusplus.wallets;
|
const RM_WALLET = new localbitcoinplusplus.wallets;
|
||||||
|
|
||||||
if (typeof message !== "string") {
|
message = JSON.stringify(msgObj);
|
||||||
message = JSON.stringify(message);
|
|
||||||
}
|
|
||||||
const message256hash = Crypto.SHA256(message);
|
const message256hash = Crypto.SHA256(message);
|
||||||
|
|
||||||
if(typeof localbitcoinplusplus.wallets.MY_SUPERNODE_PRIVATE_KEY !== "string")
|
if(typeof localbitcoinplusplus.wallets.MY_SUPERNODE_PRIVATE_KEY !== "string")
|
||||||
@ -19356,10 +19401,10 @@
|
|||||||
// Build Supernodes KBuckets
|
// Build Supernodes KBuckets
|
||||||
launchSupernodesKBuckects = await localbitcoinplusplus.kademlia.launchSupernodesKBucket();
|
launchSupernodesKBuckects = await localbitcoinplusplus.kademlia.launchSupernodesKBucket();
|
||||||
// Request other supernodes KBucket data
|
// Request other supernodes KBucket data
|
||||||
let requestSupernodeKBData = await localbitcoinplusplus.rpc.prototype
|
// let requestSupernodeKBData = await localbitcoinplusplus.rpc.prototype
|
||||||
.send_rpc
|
// .send_rpc
|
||||||
.call(this, "requestSupernodesKBucketData", {});
|
// .call(this, "requestSupernodesKBucketData", {});
|
||||||
doSend(requestSupernodeKBData);
|
// doSend(requestSupernodeKBData);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Send your id to Supernode kbucket
|
// Send your id to Supernode kbucket
|
||||||
@ -19965,6 +20010,7 @@
|
|||||||
}
|
}
|
||||||
|
|
||||||
let explorer;
|
let explorer;
|
||||||
|
let decimal = 100000000;
|
||||||
switch (trader_deposits.product) {
|
switch (trader_deposits.product) {
|
||||||
case "BTC":
|
case "BTC":
|
||||||
explorer = localbitcoinplusplus.server.btc_mainnet;
|
explorer = localbitcoinplusplus.server.btc_mainnet;
|
||||||
@ -19974,18 +20020,23 @@
|
|||||||
break;
|
break;
|
||||||
case "FLO":
|
case "FLO":
|
||||||
explorer = localbitcoinplusplus.server.flo_mainnet;
|
explorer = localbitcoinplusplus.server.flo_mainnet;
|
||||||
|
decimal = 1;
|
||||||
break;
|
break;
|
||||||
case "FLO_TEST":
|
case "FLO_TEST":
|
||||||
explorer = localbitcoinplusplus.server.flo_testnet;
|
explorer = localbitcoinplusplus.server.flo_testnet;
|
||||||
|
decimal = 1;
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
try {
|
try {
|
||||||
let url = `${explorer}/api/addr/${trader_deposits.btc_address}/balance`;
|
let url = `${explorer}/api/addr/${trader_deposits.btc_address}/balance`;
|
||||||
|
console.log(url);
|
||||||
helper_functions.ajaxGet(url).then(balance => {
|
helper_functions.ajaxGet(url).then(balance => {
|
||||||
if (!isNaN(balance) && parseFloat(balance) > 0) {
|
if (!isNaN(balance) && parseFloat(balance) > 0) {
|
||||||
balance = parseFloat(balance);
|
balance = Number(parseFloat(balance/decimal));
|
||||||
|
console.log(balance);
|
||||||
|
|
||||||
|
|
||||||
/************************ Case of dispute *****************/
|
/************************ Case of dispute *****************/
|
||||||
if (0) {
|
if (0) {
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user