Exponentially limit the rate of nSize flow to nLimit. nLimit unit is thousands-per-minute.
| 1194 | |
| 1195 | // Exponentially limit the rate of nSize flow to nLimit. nLimit unit is thousands-per-minute. |
| 1196 | bool RateLimitExceeded(double& dCount, int64_t& nLastTime, int64_t nLimit, unsigned int nSize) |
| 1197 | { |
| 1198 | static CCriticalSection csLimiter; |
| 1199 | int64_t nNow = GetTime(); |
| 1200 | |
| 1201 | LOCK(csLimiter); |
| 1202 | |
| 1203 | dCount *= pow(1.0 - 1.0/600.0, (double)(nNow - nLastTime)); |
| 1204 | nLastTime = nNow; |
| 1205 | if (dCount >= nLimit*10*1000) |
| 1206 | return true; |
| 1207 | dCount += nSize; |
| 1208 | return false; |
| 1209 | } |
| 1210 | |
| 1211 | static bool RespendRelayExceeded(const CTransaction& doubleSpend) |
| 1212 | { |
no test coverage detected