mirror of
https://github.com/bitcoin/bitcoin.git
synced 2026-01-21 15:50:07 +01:00
Merge branch '0.4.x' into 0.5.0.x
This commit is contained in:
14
src/db.cpp
14
src/db.cpp
@@ -777,6 +777,13 @@ int CWalletDB::LoadWallet(CWallet* pwallet)
|
||||
//// todo: shouldn't we catch exceptions and try to recover and continue?
|
||||
CRITICAL_BLOCK(pwallet->cs_wallet)
|
||||
{
|
||||
int nMinVersion = 0;
|
||||
if (Read((string)"minversion", nMinVersion))
|
||||
{
|
||||
if (nMinVersion > VERSION)
|
||||
return DB_TOO_NEW;
|
||||
}
|
||||
|
||||
// Get cursor
|
||||
Dbc* pcursor = GetCursor();
|
||||
if (!pcursor)
|
||||
@@ -962,13 +969,6 @@ int CWalletDB::LoadWallet(CWallet* pwallet)
|
||||
if (strKey == "addrProxy") ssValue >> addrProxy;
|
||||
if (fHaveUPnP && strKey == "fUseUPnP") ssValue >> fUseUPnP;
|
||||
}
|
||||
else if (strType == "minversion")
|
||||
{
|
||||
int nMinVersion = 0;
|
||||
ssValue >> nMinVersion;
|
||||
if (nMinVersion > VERSION)
|
||||
return DB_TOO_NEW;
|
||||
}
|
||||
}
|
||||
pcursor->close();
|
||||
}
|
||||
|
||||
12
src/main.cpp
12
src/main.cpp
@@ -1279,6 +1279,9 @@ bool static Reorganize(CTxDB& txdb, CBlockIndex* pindexNew)
|
||||
vConnect.push_back(pindex);
|
||||
reverse(vConnect.begin(), vConnect.end());
|
||||
|
||||
printf("REORGANIZE: Disconnect %i blocks; %s..%s\n", vDisconnect.size(), pfork->GetBlockHash().ToString().substr(0,20).c_str(), pindexBest->GetBlockHash().ToString().substr(0,20).c_str());
|
||||
printf("REORGANIZE: Connect %i blocks; %s..%s\n", vConnect.size(), pfork->GetBlockHash().ToString().substr(0,20).c_str(), pindexNew->GetBlockHash().ToString().substr(0,20).c_str());
|
||||
|
||||
// Disconnect shorter branch
|
||||
vector<CTransaction> vResurrect;
|
||||
BOOST_FOREACH(CBlockIndex* pindex, vDisconnect)
|
||||
@@ -1287,7 +1290,7 @@ bool static Reorganize(CTxDB& txdb, CBlockIndex* pindexNew)
|
||||
if (!block.ReadFromDisk(pindex))
|
||||
return error("Reorganize() : ReadFromDisk for disconnect failed");
|
||||
if (!block.DisconnectBlock(txdb, pindex))
|
||||
return error("Reorganize() : DisconnectBlock failed");
|
||||
return error("Reorganize() : DisconnectBlock %s failed", pindex->GetBlockHash().ToString().substr(0,20).c_str());
|
||||
|
||||
// Queue memory transactions to resurrect
|
||||
BOOST_FOREACH(const CTransaction& tx, block.vtx)
|
||||
@@ -1307,7 +1310,7 @@ bool static Reorganize(CTxDB& txdb, CBlockIndex* pindexNew)
|
||||
{
|
||||
// Invalid block
|
||||
txdb.TxnAbort();
|
||||
return error("Reorganize() : ConnectBlock failed");
|
||||
return error("Reorganize() : ConnectBlock %s failed", pindex->GetBlockHash().ToString().substr(0,20).c_str());
|
||||
}
|
||||
|
||||
// Queue memory transactions to delete
|
||||
@@ -1339,6 +1342,8 @@ bool static Reorganize(CTxDB& txdb, CBlockIndex* pindexNew)
|
||||
BOOST_FOREACH(CTransaction& tx, vDelete)
|
||||
tx.RemoveFromMemoryPool();
|
||||
|
||||
printf("REORGANIZE: done\n");
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -1536,10 +1541,11 @@ bool CBlock::AcceptBlock()
|
||||
return error("AcceptBlock() : AddToBlockIndex failed");
|
||||
|
||||
// Relay inventory, but don't relay old inventory during initial block download
|
||||
int nBlockEstimate = Checkpoints::GetTotalBlocksEstimate();
|
||||
if (hashBestChain == hash)
|
||||
CRITICAL_BLOCK(cs_vNodes)
|
||||
BOOST_FOREACH(CNode* pnode, vNodes)
|
||||
if (nBestHeight > (pnode->nStartingHeight != -1 ? pnode->nStartingHeight - 2000 : 140700))
|
||||
if (nBestHeight > (pnode->nStartingHeight != -1 ? pnode->nStartingHeight - 2000 : nBlockEstimate))
|
||||
pnode->PushInventory(CInv(MSG_BLOCK, hash));
|
||||
|
||||
return true;
|
||||
|
||||
@@ -716,6 +716,7 @@ void CNode::CloseSocketDisconnect()
|
||||
printf("disconnecting node %s\n", addr.ToString().c_str());
|
||||
closesocket(hSocket);
|
||||
hSocket = INVALID_SOCKET;
|
||||
vRecv.clear();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user