| 4522 | |
| 4523 | |
| 4524 | bool static AlreadyHave(const CInv& inv) |
| 4525 | { |
| 4526 | switch (inv.type) |
| 4527 | { |
| 4528 | case MSG_TX: |
| 4529 | { |
| 4530 | assert(recentRejects); |
| 4531 | if (chainActive.Tip()->GetBlockHash() != hashRecentRejectsChainTip) |
| 4532 | { |
| 4533 | // If the chain tip has changed previously rejected transactions |
| 4534 | // might be now valid, e.g. due to a nLockTime'd tx becoming valid, |
| 4535 | // or a double-spend. Reset the rejects filter and give those |
| 4536 | // txs a second chance. |
| 4537 | hashRecentRejectsChainTip = chainActive.Tip()->GetBlockHash(); |
| 4538 | recentRejects->reset(); |
| 4539 | } |
| 4540 | |
| 4541 | return recentRejects->contains(inv.hash) || |
| 4542 | mempool.exists(inv.hash) || |
| 4543 | mapOrphanTransactions.count(inv.hash) || |
| 4544 | pcoinsTip->HaveCoins(inv.hash); |
| 4545 | } |
| 4546 | case MSG_BLOCK: |
| 4547 | return mapBlockIndex.count(inv.hash); |
| 4548 | } |
| 4549 | // Don't know what it is, just say we already got one |
| 4550 | return true; |
| 4551 | } |
| 4552 | |
| 4553 | // Activate thin blocks only if we're not doing bulk downloads (it's faster to use ordinary block messages when |
| 4554 | // catching up with the block chain). |