bitcoin/bitcoin — Issue #642: AddAddress (net.cpp) doesn't update mapAddresses
Author: xanatos
Created: 2011-11-18 10:10:58+00:00
State: open

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.

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.