AddAddress (net.cpp) doesn't update mapAddresses #642

issue xanatos opened this issue on November 18, 2011
  1. xanatos commented at 10:10 AM on November 18, 2011: none

    After https://github.com/bitcoin/bitcoin/commit/940669657837e4a247a4d0746c12f52e8662f325

    AddAddress doesn't update the nServices and the nTime in the mapAddresses when the address is already present.

    The new code:

            addrFound = (*it).second;
            if ((addrFound.nServices | addr.nServices) != addrFound.nServices)
            {
                // Services have been added
                addrFound.nServices |= addr.nServices;
                fUpdated = true;
            }
    

    The old code

            CAddress& addrFound = (*it).second;
            if ((addrFound.nServices | addr.nServices) != addrFound.nServices)
            {
                // Services have been added
                addrFound.nServices |= addr.nServices;
                fUpdated = true;
            }
    

    where (*it) is an iterator on the mapAddresses (there is a second if block after this one that modifies addrFound.nTime, but to show the problem it isn't important)

    The difference is in the & of addrFound. Before when we modified addrFound we modified the "live" version of the mapAddresses, now we modify a copy that will be discarded at the end of the function.

  2. sipa closed this on Feb 19, 2012

  3. sipa reopened this on Feb 19, 2012

  4. sipa commented at 5:57 PM on February 19, 2012: member

    My mistake; this issue still exists, though it is fixed in addrman (#787).

  5. gavinandresen commented at 7:37 PM on April 5, 2012: contributor

    Fixed now, now that addrman is pulled?

  6. sipa closed this on Apr 5, 2012

  7. ptschip referenced this in commit 5b2faaa717 on Jun 5, 2017
  8. Losangelosgenetics referenced this in commit 7cf50c1cd5 on Mar 12, 2020
  9. rajarshimaitra referenced this in commit bed649d91f on Aug 5, 2021
  10. MarcoFalke locked this on Sep 8, 2021
Labels

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: 2026-04-29 03:16 UTC

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