aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorGavin Andresen <gavinandresen@gmail.com>2012-03-26 14:32:26 -0400
committerGavin Andresen <gavinandresen@gmail.com>2012-03-26 14:32:26 -0400
commitbf5b80a8ae67b177e06c7024eb3b7a14097a8814 (patch)
treef369d089f6795703646a2d9c26fe66dd14656fd7 /src
parente9f9282bde3292b4df35a245b9fbd9d13020a8c6 (diff)
parent53cb1a49e744b9ebed85bb03ccd1a241cf818d74 (diff)
Merge branch 'deladdr' of https://github.com/sipa/bitcoin
Diffstat (limited to 'src')
-rw-r--r--src/db.cpp28
-rw-r--r--src/db.h4
2 files changed, 12 insertions, 20 deletions
diff --git a/src/db.cpp b/src/db.cpp
index 56c59cbea7..c18860afcc 100644
--- a/src/db.cpp
+++ b/src/db.cpp
@@ -714,22 +714,12 @@ bool CTxDB::LoadBlockIndex()
// CAddrDB
//
-bool CAddrDB::WriteAddress(const CAddress& addr)
-{
- return Write(make_pair(string("addr"), addr.GetKey()), addr);
-}
-
bool CAddrDB::WriteAddrman(const CAddrMan& addrman)
{
return Write(string("addrman"), addrman);
}
-bool CAddrDB::EraseAddress(const CAddress& addr)
-{
- return Erase(make_pair(string("addr"), addr.GetKey()));
-}
-
-bool CAddrDB::LoadAddresses(bool &fUpdate)
+bool CAddrDB::LoadAddresses()
{
bool fAddrMan = false;
if (Read(string("addrman"), addrman))
@@ -739,6 +729,7 @@ bool CAddrDB::LoadAddresses(bool &fUpdate)
}
vector<CAddress> vAddr;
+ vector<vector<unsigned char> > vDelete;
// Get cursor
Dbc* pcursor = GetCursor();
@@ -762,7 +753,11 @@ bool CAddrDB::LoadAddresses(bool &fUpdate)
if (strType == "addr")
{
if (fAddrMan)
- fUpdate = true;
+ {
+ vector<unsigned char> vchKey;
+ ssKey >> vchKey;
+ vDelete.push_back(vchKey);
+ }
else
{
CAddress addr;
@@ -774,6 +769,9 @@ bool CAddrDB::LoadAddresses(bool &fUpdate)
}
pcursor->close();
+ BOOST_FOREACH(const vector<unsigned char> &vchKey, vDelete)
+ Erase(make_pair(string("addr"), vchKey));
+
if (!fAddrMan)
{
addrman.Add(vAddr, CNetAddr("0.0.0.0"));
@@ -785,11 +783,7 @@ bool CAddrDB::LoadAddresses(bool &fUpdate)
bool LoadAddresses()
{
- bool fUpdate = false;
- bool fRet = CAddrDB("cr+").LoadAddresses(fUpdate);
- if (fUpdate)
- CDB::Rewrite("addr.dat", "\004addr");
- return fRet;
+ return CAddrDB("cr+").LoadAddresses();
}
diff --git a/src/db.h b/src/db.h
index 2a869d511b..688c390e40 100644
--- a/src/db.h
+++ b/src/db.h
@@ -306,10 +306,8 @@ private:
CAddrDB(const CAddrDB&);
void operator=(const CAddrDB&);
public:
- bool WriteAddress(const CAddress& addr);
- bool EraseAddress(const CAddress& addr);
bool WriteAddrman(const CAddrMan& addr);
- bool LoadAddresses(bool &fUpdate);
+ bool LoadAddresses();
};
bool LoadAddresses();