diff options
| author | Adam Ierymenko <adam.ierymenko@gmail.com> | 2013-09-07 12:23:53 -0400 |
|---|---|---|
| committer | Adam Ierymenko <adam.ierymenko@gmail.com> | 2013-09-07 12:23:53 -0400 |
| commit | cdb96726df0f383c20bc83448a4e2427317371c0 (patch) | |
| tree | ba4956bd41941b8268736a32c44b9314d8f788b9 /node/Network.cpp | |
| parent | 56d8bbf780240be34759c5f6c9ff67d09d231468 (diff) | |
| download | infinitytier-cdb96726df0f383c20bc83448a4e2427317371c0.tar.gz infinitytier-cdb96726df0f383c20bc83448a4e2427317371c0.zip | |
updateAndCheckMulticastBalance and friends
Diffstat (limited to 'node/Network.cpp')
| -rw-r--r-- | node/Network.cpp | 28 |
1 files changed, 7 insertions, 21 deletions
diff --git a/node/Network.cpp b/node/Network.cpp index bc651661..60f87f92 100644 --- a/node/Network.cpp +++ b/node/Network.cpp @@ -76,27 +76,13 @@ bool Network::Certificate::qualifyMembership(const Network::Certificate &mc) con if (myField->second != theirField->second) return false; } else { - // Otherwise compare range with max delta. Presence of a dot in delta - // indicates a floating point comparison. Otherwise an integer - // comparison occurs. - if (deltaField->second.find('.') != std::string::npos) { - double my = Utils::strToDouble(myField->second.c_str()); - double their = Utils::strToDouble(theirField->second.c_str()); - double delta = Utils::strToDouble(deltaField->second.c_str()); - if (fabs(my - their) > delta) - return false; - } else { - uint64_t my = Utils::hexStrToU64(myField->second.c_str()); - uint64_t their = Utils::hexStrToU64(theirField->second.c_str()); - uint64_t delta = Utils::hexStrToU64(deltaField->second.c_str()); - if (my > their) { - if ((my - their) > delta) - return false; - } else { - if ((their - my) > delta) - return false; - } - } + // Otherwise compare the absolute value of the difference between + // the two values against the max delta. + int64_t my = Utils::hexStrTo64(myField->second.c_str()); + int64_t their = Utils::hexStrTo64(theirField->second.c_str()); + int64_t delta = Utils::hexStrTo64(deltaField->second.c_str()); + if (llabs((long long)(my - their)) > delta) + return false; } } } |
