]> AND Private Git Repository - loba.git/blobdiff - process.cpp
Logo AND Algorithmique Numérique Distribuée

Private GIT Repository
Bug fix: credit can be negative.
[loba.git] / process.cpp
index 97f2a69db2e943c01bfdb6e9187856aa073db947..b5531b0ce85eff0a0a20f6f5f9ce3a1276a71d5d 100644 (file)
@@ -421,7 +421,11 @@ void process::data_send(neighbor& nb)
         else
             excess_load = real_load;
 
         else
             excess_load = real_load;
 
-        double balance = nb.get_debt() - nb.get_credit();
+        double balance;
+        if (nb.get_credit() > 0.0)
+            balance = nb.get_debt() - nb.get_credit();
+        else
+            balance = nb.get_debt();
         load_to_send = std::min(excess_load,
                                 std::max(0.0, balance));
 
         load_to_send = std::min(excess_load,
                                 std::max(0.0, balance));