From 5927845f7c7089f88b9b49f0e6fa6c5e5b843815 Mon Sep 17 00:00:00 2001 From: Abhishek Sinha Date: Thu, 17 Oct 2019 12:54:47 +0530 Subject: [PATCH] added code in exportUserDataFromOneSupernodeToAnother to remove users from kbucket and kbucktStore, added code to remove is_deletable data during primary sync --- supernode/index.html | 35 ++++++++++++++++++++++++----------- 1 file changed, 24 insertions(+), 11 deletions(-) diff --git a/supernode/index.html b/supernode/index.html index b9adcc3..90b5631 100644 --- a/supernode/index.html +++ b/supernode/index.html @@ -12580,12 +12580,6 @@ } } else { - // const oldSupernodeKbucket = await localbitcoinplusplus.kademlia.restoreKbucket( - // myFloId, - // "FLO_TEST", - // KBucket - // ); - const allUsersData = await readAllDB("userPublicData"); const supernodesFloList = localbitcoinplusplus.master_configurations.supernodesPubKeys @@ -12616,12 +12610,24 @@ immigrants_data ) .then(server_sync_response => doSend(server_sync_response)); + + // Delete this user from kBucketStore datastore and Kbucket + const UintID = localbitcoinplusplus.kademlia.floIdToKbucketId('FLO_TEST', closestSu[0].data.id); + await removeinDB('kBucketStore', UintID); + KBucket.remove(UintID); } } } localbitcoinplusplus.kademlia.updateClosestSupernodeSeeds(myFloId); + // Rebuild KBucket + // localbitcoinplusplus.kademlia.restoreKbucket( + // myFloId, + // "FLO_TEST", + // KBucket + // ); + } }, @@ -22507,17 +22513,23 @@ if (obj.length > 0) { for (var prop in obj) { if (!obj.hasOwnProperty(prop)) continue; + + if(typeof obj[prop].is_deletable==="boolean" + && obj[prop].is_deletable===true) { + removeinDB(tableStoreName, obj[prop].id); + continue; + } + await updateinDB( tableStoreName, obj[prop], obj[prop].id, true, false - ).then(() => { - showMessage( - `INFO: "${tableStoreName}" datastore syncing is complete.` - ); - }); + ); + showMessage( + `INFO: "${tableStoreName}" datastore syncing is complete.` + ); } } @@ -28363,6 +28375,7 @@ }; this.request.onerror = function (event) { + console.trace(event); reject(event); } } catch (error) {