Missing AddAddress for -connect addresses #668

issue xanatos opened this issue on November 27, 2011
  1. xanatos commented at 4:41 PM on November 27, 2011: none

    If you select an address with the -connect command line parameter it isn,t "AddAddress"ed before connecting to it. For -addnode nodes there is a block of code that does it in init.cpp::AppInit2(int argc, char* argv[]) around line 470.

    In net.cpp::ConnectNode(CAddress addrConnect, int64 nTimeout) then a funny thing happen:

    CRITICAL_BLOCK(cs_mapAddresses)
        mapAddresses[addrConnect.GetKey()].nLastTry = GetAdjustedTime();
    

    Here an "empty" address is created in mapAddresses with only nLastTry correctly valued. You can check it by changing the code to something like

    CRITICAL_BLOCK(cs_mapAddresses)
    {
        if (mapAddresses.count(addrConnect.GetKey()) == 0)
        {
            printf("*** Missing address in mapAddresses: ");
            addrConnect.print();
    
            mapAddresses[addrConnect.GetKey()].nLastTry = GetAdjustedTime();
    
            printf("*** Now the address in mapAddresses is ");
            mapAddresses[addrConnect.GetKey()].print();
        }
        else
        {
            mapAddresses[addrConnect.GetKey()].nLastTry = GetAdjustedTime();
        }
    }
    
  2. sipa commented at 5:38 PM on February 19, 2012: member

    This is fixed in addrman (#787).

  3. sipa closed this on Apr 5, 2012

  4. ptschip referenced this in commit 1fac9fcc8a on Jun 11, 2017
  5. MarcoFalke locked this on Sep 8, 2021
Contributors

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