|
|
|
@ -1514,7 +1514,9 @@ bool CBlock::SetBestChain(CTxDB& txdb, CBlockIndex* pindexNew)
@@ -1514,7 +1514,9 @@ bool CBlock::SetBestChain(CTxDB& txdb, CBlockIndex* pindexNew)
|
|
|
|
|
{ |
|
|
|
|
uint256 hash = GetHash(); |
|
|
|
|
|
|
|
|
|
txdb.TxnBegin(); |
|
|
|
|
if (!txdb.TxnBegin()) |
|
|
|
|
return error("SetBestChain() : TxnBegin failed"); |
|
|
|
|
|
|
|
|
|
if (pindexGenesisBlock == NULL && hash == hashGenesisBlock) |
|
|
|
|
{ |
|
|
|
|
txdb.WriteHashBestChain(hash); |
|
|
|
@ -1563,7 +1565,10 @@ bool CBlock::SetBestChain(CTxDB& txdb, CBlockIndex* pindexNew)
@@ -1563,7 +1565,10 @@ bool CBlock::SetBestChain(CTxDB& txdb, CBlockIndex* pindexNew)
|
|
|
|
|
printf("SetBestChain() : ReadFromDisk failed\n"); |
|
|
|
|
break; |
|
|
|
|
} |
|
|
|
|
txdb.TxnBegin(); |
|
|
|
|
if (!txdb.TxnBegin()) { |
|
|
|
|
printf("SetBestChain() : TxnBegin 2 failed\n"); |
|
|
|
|
break; |
|
|
|
|
} |
|
|
|
|
// errors now are not fatal, we still did a reorganisation to a new chain in a valid way
|
|
|
|
|
if (!block.SetBestChainInner(txdb, pindex)) |
|
|
|
|
break; |
|
|
|
@ -1621,7 +1626,8 @@ bool CBlock::AddToBlockIndex(unsigned int nFile, unsigned int nBlockPos)
@@ -1621,7 +1626,8 @@ bool CBlock::AddToBlockIndex(unsigned int nFile, unsigned int nBlockPos)
|
|
|
|
|
pindexNew->bnChainWork = (pindexNew->pprev ? pindexNew->pprev->bnChainWork : 0) + pindexNew->GetBlockWork(); |
|
|
|
|
|
|
|
|
|
CTxDB txdb; |
|
|
|
|
txdb.TxnBegin(); |
|
|
|
|
if (!txdb.TxnBegin()) |
|
|
|
|
return false; |
|
|
|
|
txdb.WriteBlockIndex(CDiskBlockIndex(pindexNew)); |
|
|
|
|
if (!txdb.TxnCommit()) |
|
|
|
|
return false; |
|
|
|
|