Skip to content

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

@xanatos

Description

@xanatos

After 9406696

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions