Avoid the use of abs64 in timedata #20141

pull sipa wants to merge 1 commits into bitcoin:master from sipa:202010_no_abs64 changing 1 files +3 −7
  1. sipa commented at 0:37 am on October 13, 2020: member
    Fixes #20135.
  2. sipa force-pushed on Oct 13, 2020
  3. fanquake added the label Refactoring on Oct 13, 2020
  4. sipa force-pushed on Oct 13, 2020
  5. in src/timedata.cpp:78 in fc66451d5c outdated
    73@@ -79,7 +74,8 @@ void AddTimeData(const CNetAddr& ip, int64_t nOffsetSample)
    74         int64_t nMedian = vTimeOffsets.median();
    75         std::vector<int64_t> vSorted = vTimeOffsets.sorted();
    76         // Only let other nodes change our time by so much
    77-        if (abs64(nMedian) <= std::max<int64_t>(0, gArgs.GetArg("-maxtimeadjustment", DEFAULT_MAX_TIME_ADJUSTMENT))) {
    78+        int64_t max_adjustment = std::max<int64_t>(0, gArgs.GetArg("-maxtimeadjustment", DEFAULT_MAX_TIME_ADJUSTMENT));
    79+        if (nMedian < -max_adjustment || nMedian > max_adjustment) {
    


    kallewoof commented at 2:46 am on October 13, 2020:

    I think this is flipped. Now if nMedian is beyond the max nTimeOffset is set to nMedian, whereas it was the opposite before:

    Example: max = 4, nMedian = -3 Before: abs64(-3) <= 4 → 3 <= 4 → true Now: -3 < -4 || -3 > 4 → false


    sipa commented at 3:12 am on October 13, 2020:
    Uh, fixed. Thanks!
  6. Avoid the use of abs64 in timedata d1292f25f2
  7. sipa force-pushed on Oct 13, 2020
  8. MarcoFalke commented at 7:34 am on October 13, 2020: member

    ACK d1292f25f272401da0c58580521c74b1fa03a9ad 🎹

    Signature:

     0-----BEGIN PGP SIGNED MESSAGE-----
     1Hash: SHA512
     2
     3ACK d1292f25f272401da0c58580521c74b1fa03a9ad 🎹
     4-----BEGIN PGP SIGNATURE-----
     5
     6iQGzBAEBCgAdFiEE+rVPoUahrI9sLGYTzit1aX5ppUgFAlwqrYAACgkQzit1aX5p
     7pUhLDQwAtYxZPYoMjle0YqgTWENDhQOispBXpj557FjzlRPsr1Lbo2XIhyuqDtJr
     8vYrvpwVxPwjx/v/1kWqVtmiOhEPzkMwguDH6wVl3zMfnb97qzYE64p/JZp3AXLuD
     91FOhGkoACVEzHMoHL25tzQfiH+AfJ44QD1iFn4KLnVk4YXmqqC5OB8J6Sdpm3beV
    10+2nHGmzSH+DM/IH09EP1gtfmBISVLlMJESc0Jf+mwdBhO/y99UK9NATfKo/Cw0i3
    11ewblc/Asehq8u7ZxGAMoHTlr1VgSTNdUZ0bdMKKigvRkfIoAg5kTq80/uKS7mg3T
    12InA6Lau/CWDlmB+I6opTWIZgCqt3ZUkixtAhWeC8RzSB+CNk0efkbv8YIC+jv/FJ
    13RtG6YMnSf8pfyZtvz8vpSOPl58U4jx2Z5D/+rD1mnxuc6d+gzAFJMqms3vwaOe3r
    14HxrdNIEGFnhaxqwd2wq/wA1cqCzsPIcJKmg1+q581YPkNCXlsaORvLl5FywpbBbg
    1554gywunH
    16=8Rrg
    17-----END PGP SIGNATURE-----
    

    Timestamp of file with hash 9182aa2ebb693c9de1307af30edc9e597d470f51bd1cdb4b1d6b11923c3ef0db -

  9. kallewoof approved
  10. kallewoof commented at 7:55 am on October 13, 2020: member

    ACK d1292f25f272401da0c58580521c74b1fa03a9ad

    Verified no behavioral change.

  11. practicalswift commented at 9:07 am on October 13, 2020: contributor
    ACK d1292f25f272401da0c58580521c74b1fa03a9ad
  12. jonatack commented at 10:05 am on October 13, 2020: member
    ACK d1292f25f272401da0c58580521c74b1fa03a9ad code/logic review, verified there are no remaining callers of abs64(), verified no warnings in a debug build
  13. fanquake merged this on Oct 13, 2020
  14. fanquake closed this on Oct 13, 2020

  15. fanquake referenced this in commit 0b64310fb6 on Oct 16, 2020
  16. fanquake referenced this in commit ee0082b886 on Oct 16, 2020
  17. MarcoFalke referenced this in commit a2fa11f9de on Nov 18, 2020
  18. MarkLTZ referenced this in commit 5dee1e1f8f on Nov 21, 2020
  19. MarkLTZ referenced this in commit c61e643b75 on Nov 21, 2020
  20. MarcoFalke referenced this in commit 5baaea4410 on Dec 2, 2020
  21. Fabcien referenced this in commit f61fd42904 on Nov 12, 2021
  22. DrahtBot locked this on Feb 15, 2022

github-metadata-mirror

This is a metadata mirror of the GitHub repository bitcoin/bitcoin. This site is not affiliated with GitHub. Content is generated from a GitHub metadata backup.
generated: 2024-07-05 22:12 UTC

This site is hosted by @0xB10C
More mirrored repositories can be found on mirror.b10c.me