blockchainbitcoinbitcoinj

What exacly is BITCOIN_SEED_NONCE in Bitcoin Source code?


I'm studing blockchain and I'm curently looking at how to DNS Seed Nodes work. I understand that crawler grabs nodes via magic messages but I can't figure out where one value came from Bitcoin source code and what is use of it.

#define BITCOIN_SEED_NONCE 0x0539a019ca550825ULL Program source: https://github.com/team-exor/generic-seeder/blob/f6c33d59b9a56a677364fbcdb9b2e30c51fc4a89/bitcoin.cpp#L9

Could you guys help me figure this out and point to correct place in Bitcoin source and let me know what is exacly use of that hex number?


Solution

  • It is used by generic-seeder in it's PushVersion function, which corresponds to the "version" message used in handshakes between new bitcoin peers.

    From the bitcoin wiki:

    nonce uint64_t: Node random nonce, randomly generated every time a version packet is sent. This nonce is used to detect connections to self.

    The PeerManagerImpl::PushNodeVersion(CNode& pnode, int64_t nTime) routine is the equivalent routine in the Bitcoin source:

    void PeerManagerImpl::PushNodeVersion(CNode& pnode, int64_t nTime)
    {
    <...>
        uint64_t nonce = pnode.GetLocalNonce();
    <...>
        m_connman.PushMessage(&pnode, CNetMsgMaker(INIT_PROTO_VERSION).Make(NetMsgType::VERSION, PROTOCOL_VERSION, (uint64_t)nLocalNodeServices, nTime, addrYou, addrMe,
                nonce, strSubVersion, nNodeStartingHeight, tx_relay));
    <...>
    }