Bitcoin Forum

Bitcoin => Development & Technical Discussion => Topic started by: Martin P. Hellwig on July 14, 2011, 05:33:36 PM



Title: Version Message and addrYou / addrMe
Post by: Martin P. Hellwig on July 14, 2011, 05:33:36 PM
Hi all, I am a bit confused here:
According to the spec and main.cpp the version message should be first me and then you:
(line 2364)
        int64 nTime;
        CAddress addrMe;
        CAddress addrFrom;
        uint64 nNonce = 1;

but from what I see over the network it is more the otherway around, as net.h would suggest too:
line 743
    void PushVersion()
    {
        /// when NTP implemented, change to just nTime = GetAdjustedTime()
        int64 nTime = (fInbound ? GetAdjustedTime() : GetTime());
        CAddress addrYou = (fUseProxy ? CAddress("0.0.0.0") : addr);
        CAddress addrMe = (fUseProxy ? CAddress("0.0.0.0") : addrLocalHost);
        RAND_bytes((unsigned char*)&nLocalHostNonce, sizeof(nLocalHostNonce));
        PushMessage("version", VERSION, nLocalServices, nTime, addrYou, addrMe,
                    nLocalHostNonce, std::string(pszSubVer), nBestHeight);
    }

As I am not proficient in cpp, I don't really know now what is going on.
Could someone shed a bit more light on this please?

Thanks,

Martin


Title: Re: Version Message and addrYou / addrMe
Post by: wumpus on July 14, 2011, 06:05:45 PM
One sides' "me" is the other sides' "you", I guess? That explains why they're swapped on receive.


Title: Re: Version Message and addrYou / addrMe
Post by: Martin P. Hellwig on July 14, 2011, 11:27:11 PM
Well I thought about that one but I have to swap both of them that is incoming and outgoing to make sense.