|
|
@ -739,21 +739,28 @@ bool CTransaction::AcceptToMemoryPool(CTxDB& txdb, bool fCheckInputs, bool* pfMi |
|
|
|
return error("AcceptToMemoryPool() : not enough fees"); |
|
|
|
return error("AcceptToMemoryPool() : not enough fees"); |
|
|
|
|
|
|
|
|
|
|
|
// Continuously rate-limit free transactions
|
|
|
|
// Continuously rate-limit free transactions
|
|
|
|
|
|
|
|
// This mitigates 'penny-flooding' -- sending thousands of free transactions just to
|
|
|
|
|
|
|
|
// be annoying or make other's transactions take longer to confirm.
|
|
|
|
if (nFees < CENT) |
|
|
|
if (nFees < CENT) |
|
|
|
{ |
|
|
|
{ |
|
|
|
|
|
|
|
static CCriticalSection cs; |
|
|
|
static double dFreeCount; |
|
|
|
static double dFreeCount; |
|
|
|
static int64 nLastTime; |
|
|
|
static int64 nLastTime; |
|
|
|
int64 nNow = GetTime(); |
|
|
|
int64 nNow = GetTime(); |
|
|
|
// Use an exponentially decaying ~10-minute window:
|
|
|
|
|
|
|
|
dFreeCount *= pow(1.0 - 1.0/600.0, (double)(nNow - nLastTime)); |
|
|
|
CRITICAL_BLOCK(cs) |
|
|
|
nLastTime = nNow; |
|
|
|
{ |
|
|
|
// -limitfreerelay unit is thousand-bytes-per-minute
|
|
|
|
// Use an exponentially decaying ~10-minute window:
|
|
|
|
// At default rate it would take over a month to fill 1GB
|
|
|
|
dFreeCount *= pow(1.0 - 1.0/600.0, (double)(nNow - nLastTime)); |
|
|
|
if (dFreeCount > GetArg("-limitfreerelay", 15)*10*1000 && !IsFromMe()) |
|
|
|
nLastTime = nNow; |
|
|
|
return error("AcceptToMemoryPool() : free transaction rejected by rate limiter"); |
|
|
|
// -limitfreerelay unit is thousand-bytes-per-minute
|
|
|
|
if (fDebug) |
|
|
|
// At default rate it would take over a month to fill 1GB
|
|
|
|
printf("Rate limit dFreeCount: %g => %g\n", dFreeCount, dFreeCount+nSize); |
|
|
|
if (dFreeCount > GetArg("-limitfreerelay", 15)*10*1000 && !IsFromMe()) |
|
|
|
dFreeCount += nSize; |
|
|
|
return error("AcceptToMemoryPool() : free transaction rejected by rate limiter"); |
|
|
|
|
|
|
|
if (fDebug) |
|
|
|
|
|
|
|
printf("Rate limit dFreeCount: %g => %g\n", dFreeCount, dFreeCount+nSize); |
|
|
|
|
|
|
|
dFreeCount += nSize; |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|