Skip to content
Snippets Groups Projects
Commit f0fb7f83 authored by Benoit Lavenier's avatar Benoit Lavenier
Browse files

[fix] Network controller: try code optimization (add a refresh function) (wip)

parent df92a825
No related branches found
No related tags found
1 merge request!647[enh] If node unreachable, select a random UP fallback peer
Pipeline #16725 skipped
...@@ -19,7 +19,7 @@ ...@@ -19,7 +19,7 @@
"helptip": { "helptip": {
"enable": true, "enable": true,
"installDocUrl": { "installDocUrl": {
"fr-FR": "https://duniter.org/fr/miner-des-blocs/installer/", "fr-FR": "https://duniter.fr/wiki/doc/installer/",
"en": "https://duniter.org/en/wiki/duniter/install/" "en": "https://duniter.org/en/wiki/duniter/install/"
} }
}, },
...@@ -27,7 +27,9 @@ ...@@ -27,7 +27,9 @@
"en": "license/license_g1-en", "en": "license/license_g1-en",
"fr-FR": "license/license_g1-fr-FR", "fr-FR": "license/license_g1-fr-FR",
"es-ES": "license/license_g1-es-ES", "es-ES": "license/license_g1-es-ES",
"eo-EO": "license/license_g1-eo-EO" "eo-EO": "license/license_g1-eo-EO",
"it-IT": "license/license_g1-it-IT",
"pt-PT": "license/license_g1-pt-PT"
}, },
"feed": { "feed": {
"jsonFeed": { "jsonFeed": {
...@@ -117,15 +119,17 @@ ...@@ -117,15 +119,17 @@
"helptip": { "helptip": {
"enable": true, "enable": true,
"installDocUrl": { "installDocUrl": {
"fr-FR": "https://duniter.org/fr/miner-des-blocs/installer/", "fr-FR": "https://duniter.fr/wiki/doc/installer/",
"en": "https://duniter.org/en/wiki/duniter/install/" "en": "https://duniter.org/en/wiki/duniter/install/"
} }
}, },
"license": { "license": {
"fr-FR": "license/license_g1-fr-FR",
"en": "license/license_g1-en", "en": "license/license_g1-en",
"fr-FR": "license/license_g1-fr-FR",
"es-ES": "license/license_g1-es-ES", "es-ES": "license/license_g1-es-ES",
"eo-EO": "license/license_g1-eo-EO" "eo-EO": "license/license_g1-eo-EO",
"it-IT": "license/license_g1-it-IT",
"pt-PT": "license/license_g1-pt-PT"
}, },
"feed": { "feed": {
"jsonFeed": { "jsonFeed": {
...@@ -221,7 +225,7 @@ ...@@ -221,7 +225,7 @@
"helptip": { "helptip": {
"enable": false, "enable": false,
"installDocUrl": { "installDocUrl": {
"fr-FR": "https://duniter.org/fr/miner-des-blocs/installer/", "fr-FR": "https://duniter.fr/wiki/doc/installer/",
"en": "https://duniter.org/en/wiki/duniter/install/" "en": "https://duniter.org/en/wiki/duniter/install/"
} }
}, },
...@@ -279,15 +283,17 @@ ...@@ -279,15 +283,17 @@
"helptip": { "helptip": {
"enable": false, "enable": false,
"installDocUrl": { "installDocUrl": {
"fr-FR": "https://duniter.org/fr/wiki/duniter/installer/", "fr-FR": "https://duniter.fr/wiki/doc/installer/",
"en": "https://duniter.org/en/wiki/duniter/install/" "en": "https://duniter.org/en/wiki/duniter/install/"
} }
}, },
"license": { "license": {
"fr-FR": "license/license_g1-fr-FR",
"en": "license/license_g1-en", "en": "license/license_g1-en",
"fr-FR": "license/license_g1-fr-FR",
"es-ES": "license/license_g1-es-ES", "es-ES": "license/license_g1-es-ES",
"eo-EO": "license/license_g1-eo-EO" "eo-EO": "license/license_g1-eo-EO",
"it-IT": "license/license_g1-it-IT",
"pt-PT": "license/license_g1-pt-PT"
}, },
"node": { "node": {
"host": "g1.e-is.pro", "host": "g1.e-is.pro",
...@@ -300,6 +306,10 @@ ...@@ -300,6 +306,10 @@
{ {
"host": "g1.e-is.pro", "host": "g1.e-is.pro",
"port": 443 "port": 443
},
{
"host": "g1.librelois.fr",
"port": 443
} }
], ],
"plugins":{ "plugins":{
...@@ -354,13 +364,18 @@ ...@@ -354,13 +364,18 @@
"httpsMode": false, "httpsMode": false,
"helptip": { "helptip": {
"enable": false, "enable": false,
"installDocUrl": "https://github.com/duniter/duniter/blob/master/doc/install-a-node.md" "installDocUrl": {
"fr-FR": "https://duniter.fr/wiki/doc/installer/",
"en": "https://duniter.org/en/wiki/duniter/install/"
}
}, },
"license": { "license": {
"fr-FR": "license/license_g1-fr-FR.txt", "en": "license/license_g1-en",
"en": "license/license_g1-en.txt", "fr-FR": "license/license_g1-fr-FR",
"es-ES": "license/license_g1-es-ES", "es-ES": "license/license_g1-es-ES",
"eo-EO": "license/license_g1-eo-EO" "eo-EO": "license/license_g1-eo-EO",
"it-IT": "license/license_g1-it-IT",
"pt-PT": "license/license_g1-pt-PT"
}, },
"node": { "node": {
"host": "g1.duniter.org", "host": "g1.duniter.org",
......
...@@ -162,39 +162,43 @@ function NetworkLookupController($scope, $state, $location, $ionicPopover, $win ...@@ -162,39 +162,43 @@ function NetworkLookupController($scope, $state, $location, $ionicPopover, $win
// Start network scan // Start network scan
csNetwork.start($scope.node, $scope.computeOptions()) csNetwork.start($scope.node, $scope.computeOptions())
.then(function() { .then(function() {
if (!$scope.refreshing) { $scope.refresh();
$scope.refreshing = true;
csWot.extendAll(csNetwork.data.peers)
.then(function() {
// Avoid to refresh if view has been leaving
if ($scope.networkStarted) {
$scope.updateView(csNetwork.data);
}
$scope.refreshing = false;
});
}
}); });
// Catch event on new peers // Catch event on new peers
$scope.listeners.push( $scope.listeners.push(
csNetwork.api.data.on.changed($scope, function(data) { csNetwork.api.data.on.changed($scope, function(data) {
if (!$scope.refreshing) { $scope.refresh(data);
}));
}
// Show help tip
$scope.showHelpTip();
};
$scope.refresh = function(data) {
data = csNetwork.data || data;
if (!data || $scope.refreshing /*|| !$scope.networkStarted*/) return; // Skip if no data, or already refreshing
// Mark as refreshing
$scope.refreshing = true; $scope.refreshing = true;
// Add name+avatar to peers
csWot.extendAll(data.peers) csWot.extendAll(data.peers)
.then(function() { .then(function() {
// Avoid to refresh if view has been leaving // Avoid to refresh if view has been leaving
if ($scope.networkStarted) { if ($scope.networkStarted) {
$scope.updateView(data); $scope.updateView(data);
} }
})
.catch(function(err) {
console.error(err);
// Continue
})
.then(function() {
$scope.refreshing = false; $scope.refreshing = false;
}); });
} }
}));
}
// Show help tip
$scope.showHelpTip();
};
$scope.updateView = function(data) { $scope.updateView = function(data) {
console.debug("[peers] Updating UI"); console.debug("[peers] Updating UI");
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment