From 6bbf7f58f025142522e303d66a2c5e9a29ccd426 Mon Sep 17 00:00:00 2001 From: JoelKatz Date: Fri, 29 Jun 2012 22:40:48 -0700 Subject: [PATCH] Fix a small bug. Catch bad store/retrieeves sooner. --- src/HashedObject.cpp | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/HashedObject.cpp b/src/HashedObject.cpp index 4305a5b5cb..8c9ef0ac7c 100644 --- a/src/HashedObject.cpp +++ b/src/HashedObject.cpp @@ -17,6 +17,7 @@ HashedObjectStore::HashedObjectStore(int cacheSize, int cacheAge) : bool HashedObjectStore::store(HashedObjectType type, uint32 index, const std::vector& data, const uint256& hash) { // return: false=already in cache, true = added to cache + assert(hash == Serializer::getSHA512Half(data)); if (!theApp->getHashNodeDB()) return true; if (mCache.touch(hash)) { @@ -25,7 +26,7 @@ bool HashedObjectStore::store(HashedObjectType type, uint32 index, } HashedObject::pointer object = boost::make_shared(type, index, data, hash); - + if (!mCache.canonicalize(hash, object)) { boost::recursive_mutex::scoped_lock sl(mWriteMutex); mWriteSet.push_back(object); @@ -126,6 +127,8 @@ HashedObject::pointer HashedObjectStore::retrieve(const uint256& hash) db->getBinary("Object", &(data.front()), size); db->endIterRows(); + assert(Serializer::getSHA512Half(data) == hash); + HashedObjectType htype = UNKNOWN; switch(type[0]) {