GambleCoin-Project / GambleCoin

GambleCoin (GMCN) Official Core Project
http://www.gamblecoin-info.com/
MIT License
5 stars 6 forks source link

ipv4 vs. ipv6 seednodes #29

Open CaveSpectre11 opened 5 years ago

CaveSpectre11 commented 5 years ago

All seednodes are setup to be the ipv4 node addresses. There are plenty of wallets and servers out there that can handle ipv6; which can handle ipv4 as well. However there are some that can't do ipv6 yet.

The ipv4 nodes should be "reserved", if you will, for ipv4 only nodes. Therefore... design logic that prioritizes ipv6 connections on wallets configured with ipv6, or we find that we are able to connect to an ipv6 address.

CaveSpectre11 commented 5 years ago

Look at the SeedSpec6 in chainparamseeds.h, it appears to be other preloaded seeds that are probably very stale.

Looks like those are used if there's nothing found with DNS.

Also look at

        // Only connect out to one peer per network group (/16 for IPv4).
        // Do this here so we don't have to critsect vNodes inside mapAddresses critsect.
        int nOutbound = 0;
        set<vector<unsigned char> > setConnected;
        {
            LOCK(cs_vNodes);
            BOOST_FOREACH (CNode* pnode, vNodes) {
                if (!pnode->fInbound) {
                    setConnected.insert(pnode->addr.GetGroup());
                    nOutbound++;
                }
            }
        }

And perhaps hook in there somewhere to distinguish between ipv4 and ipv6 connections (The group limitation is very interesting)

                BOOST_FOREACH (CNetAddr& ip, vIPs) {
                    int nOneDay = 24 * 3600;
                    CAddress addr = CAddress(CService(ip, Params().GetDefaultPort()));
                    addr.nTime = GetTime() - 3 * nOneDay - GetRand(4 * nOneDay); // use a random age between 3 and 7 days old
                    vAdd.push_back(addr);
                    found++;
                }

Understand that code... why it's randomized; and also get the stupid constant out of that loop, and probably the gettime also; since it's randomized, should be able to just:

    LogPrintf("Loading addresses from DNS seeds (could take a while)\n");
    static int nOneDay = 24 * 3600;
    int baseTime = GetTime() - 3 * nOneDay;

    BOOST_FOREACH (const CDNSSeedData& seed, vSeeds) {
        if (HaveNameProxy()) {
            AddOneShot(seed.host);
        } else {
            vector<CNetAddr> vIPs;
            vector<CAddress> vAdd;
            if (LookupHost(seed.host.c_str(), vIPs)) {
                BOOST_FOREACH (CNetAddr& ip, vIPs) {
                    CAddress addr = CAddress(CService(ip, Params().GetDefaultPort()));
                    addr.nTime = baseTime  - GetRand(4 * nOneDay); // use a random age between 3 and 7 days old
                    vAdd.push_back(addr);
                    found++;
                }
            }
            addrman.Add(vAdd, CNetAddr(seed.name, true));
        }
    }

    LogPrintf("%d addresses found from DNS seeds\n", found);

Which, if that is a slow routine; will speed it up some

CaveSpectre11 commented 5 years ago

Look at the potential to add code that will SetLimited(NET_IPV4) for daemons that are routeable to IPV6; essentially rendering IPv4 reserved for those that cant route to ipv6. Possibly use IsLimited() To deterine if IPv4 is limited when we detect there isn't enough ipv6 hosts to get a decent number of connections.

Need an UnSetLimited() to be able to turn it back on.