mirror of
https://github.com/twisterarmy/twister-core.git
synced 2025-01-09 22:37:55 +00:00
another try to fix the infinite recursion triggered when the new (longer) chain
contains an invalid transaction (due to older, buggy, twisterd or attacker). i'm not entirely convinced that original bitcoin couldn't be attacked the same way (51% is still needed, but crashing the client is pretty bad).
This commit is contained in:
parent
19ff320d24
commit
6416fa5d58
15
src/main.cpp
15
src/main.cpp
@ -1299,9 +1299,22 @@ bool SetBestChain(CValidationState &state, CBlockIndex* pindexNew)
|
||||
|
||||
// List of what to connect (typically only pindexNew)
|
||||
vector<CBlockIndex*> vConnect;
|
||||
for (CBlockIndex* pindex = pindexNew; pindex != pfork; pindex = pindex->pprev)
|
||||
for (CBlockIndex* pindex = pindexNew; pindex != pfork; pindex = pindex->pprev) {
|
||||
vConnect.push_back(pindex);
|
||||
if( pindex->nStatus & BLOCK_FAILED_MASK ) {
|
||||
BOOST_FOREACH(CBlockIndex *pindex, vConnect) {
|
||||
pindex->nStatus |= BLOCK_FAILED_CHILD;
|
||||
setBlockIndexValid.erase(pindex);
|
||||
pblocktree->WriteBlockIndex(CDiskBlockIndex(pindex));
|
||||
}
|
||||
vConnect.clear();
|
||||
}
|
||||
}
|
||||
reverse(vConnect.begin(), vConnect.end());
|
||||
|
||||
if (vConnect.size() < vDisconnect.size()) {
|
||||
return error("SetBestChain() : Tried to connect to a shorter chain (invalid blocks)");
|
||||
}
|
||||
|
||||
if (vDisconnect.size() > 0) {
|
||||
printf("REORGANIZE: Disconnect %"PRIszu" blocks; %s..\n", vDisconnect.size(), pfork->GetBlockHash().ToString().c_str());
|
||||
|
Loading…
Reference in New Issue
Block a user