Return false only on read fails
Signed-off-by: Anthony Fieroni <bvbfan@abv.bg>
This commit is contained in:
parent
4e48f81860
commit
56cd9c600c
3 changed files with 3 additions and 5 deletions
|
@ -136,20 +136,17 @@ bool CClaimTrieDb::seekByKey(std::map<K, V, C> &map) const
|
|||
const size_t hash = hashType<K, V>();
|
||||
boost::scoped_ptr<CDBIterator> pcursor(const_cast<CClaimTrieDb*>(this)->NewIterator());
|
||||
|
||||
bool found = false;
|
||||
|
||||
for (pcursor->SeekToFirst(); pcursor->Valid(); pcursor->Next()) {
|
||||
std::pair<size_t, K> key;
|
||||
if (pcursor->GetKey(key)) {
|
||||
if (hash == key.first) {
|
||||
V value;
|
||||
if (!pcursor->GetValue(value)) return false;
|
||||
found = true;
|
||||
map.insert(std::make_pair(key.second, value));
|
||||
}
|
||||
}
|
||||
}
|
||||
return found;
|
||||
return true;
|
||||
}
|
||||
|
||||
template <typename K, typename V, typename C>
|
||||
|
|
|
@ -107,6 +107,7 @@ public:
|
|||
/**
|
||||
* Get a map representation of K type / V type stored by their hash.
|
||||
* Look only in the disk, and not the buffer.
|
||||
* Returns false if database read fails.
|
||||
* @param[out] map key / value pairs readed only from disk
|
||||
*/
|
||||
template <typename K, typename V, typename C>
|
||||
|
|
|
@ -316,7 +316,7 @@ struct ClaimTrieChainFixture{
|
|||
// from disk
|
||||
pclaimTrie->WriteToDisk();
|
||||
pclaimTrie->clear();
|
||||
pclaimTrie->ReadFromDisk(true);
|
||||
BOOST_CHECK(pclaimTrie->ReadFromDisk(true));
|
||||
}
|
||||
|
||||
};
|
||||
|
|
Loading…
Add table
Reference in a new issue