diff options
| author | Jeff Garzik <[email protected]> | 2012-05-17 08:49:16 -0700 |
|---|---|---|
| committer | Jeff Garzik <[email protected]> | 2012-05-17 08:49:16 -0700 |
| commit | cf2f7c30a3b461c8db8703f3d522076fdacd81ba (patch) | |
| tree | caa85fe1518b5998cdb7c200b4d5d74c5576b300 /src/main.cpp | |
| parent | Merge pull request #1316 from jgarzik/dead-code (diff) | |
| parent | Always check return values of TxnBegin() and TxnCommit() (diff) | |
| download | discoin-cf2f7c30a3b461c8db8703f3d522076fdacd81ba.tar.xz discoin-cf2f7c30a3b461c8db8703f3d522076fdacd81ba.zip | |
Merge pull request #1295 from jgarzik/txn-retval
[FIX] Always check return values of TxnBegin() and TxnCommit()
Diffstat (limited to 'src/main.cpp')
| -rw-r--r-- | src/main.cpp | 12 |
1 files changed, 9 insertions, 3 deletions
diff --git a/src/main.cpp b/src/main.cpp index e40acf6d3..6096ee3e6 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -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) 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) 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; |