Does the main Bitcoin client blacklist addresses?

9

2

Does the main Bitcoin client blacklist any addresses that send too many erroneous messages? If so, how can one whitelist a particular address? I am developing an app that will be communicating with the main client and I don't want the program to ban it during testing.

ThePiachu

Posted 2011-12-08T13:22:18.933

Reputation: 41 594

1I don't know the answer, but there is a testnet intended for app development isn't there? It should presumably be more forgiving.Highly Irregular 2011-12-08T21:27:55.343

Why not title this as "Does the main Bitcoin client blacklist addresses?"ripper234 2011-12-09T08:12:53.543

Answers

9

There is a ban mechanism which is handled in net.cpp.

Any node which misbehave by more than -banscore (defaults to 100) is banned for -bantime (defaults to 60×60×24 seconds = 1 day). However, nodes with a local ip address are exempted, and for those a warning is shown in the logs after each misbehavior.

Also bans are not persistent, they are lifted when the client is restarted.

So, during development, just make sure that your app connects with a local address to the bitcoin client, and you will not be bothered by bans.


Here is the relevant piece of code:

bool CNode::Misbehaving(int howmuch)
{
    if (addr.IsLocal())
    {
        printf("Warning: local node %s misbehaving\n", addr.ToString().c_str());
        return false;
    }

    nMisbehavior += howmuch;
    if (nMisbehavior >= GetArg("-banscore", 100))
    {
        int64 banTime = GetTime()+GetArg("-bantime", 60*60*24);  // Default 24-hour ban
        CRITICAL_BLOCK(cs_setBanned)
            if (setBanned[addr.ip] < banTime)
                setBanned[addr.ip] = banTime;
        CloseSocketDisconnect();
        printf("Disconnected %s for misbehavior (score=%d)\n", addr.ToString().c_str(), nMisbehavior);
        return true;
    }
    return false;
}

Stéphane Gimenez

Posted 2011-12-08T13:22:18.933

Reputation: 4 746

3Setting -banscore=999999 (or some other very-large number) would be another way of getting bitcoin to be very forgiving when developing an app.gavinandresen 2011-12-10T06:16:59.310

2What determines misbehavior?Geremia 2016-05-20T17:28:23.040