aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/DatabaseStorage.cpp10
1 files changed, 4 insertions, 6 deletions
diff --git a/src/DatabaseStorage.cpp b/src/DatabaseStorage.cpp
index 0f75d1f..5e43d1a 100644
--- a/src/DatabaseStorage.cpp
+++ b/src/DatabaseStorage.cpp
@@ -58,8 +58,8 @@ namespace odhtdb
throw DatabaseStorageNotFound(errMsg);
}
- auto storedDataIt = storedDataHash.find(dataHash);
- if(storedDataIt != storedDataHash.end())
+ auto storeDataHashResult = storedDataHash.insert(dataHash);
+ if(!storeDataHashResult.second)
{
string errMsg = "Database already contains data with hash: ";
errMsg += dataHash.toString();
@@ -70,13 +70,12 @@ namespace odhtdb
memcpy(storageData.data, data, dataSize);
DatabaseStorageObject *databaseStorageObject = new DatabaseStorageObject(storageData, timestamp, creatorUser->getPublicKey());
it->second->objects.push_back(databaseStorageObject);
- storedDataHash.insert(dataHash);
}
void DatabaseStorage::addToQuarantine(const Hash &dataHash, const Signature::PublicKey &creatorPublicKey, u64 timestamp, const u8 *data, usize dataSize)
{
- auto storedDataIt = storedDataHash.find(dataHash);
- if(storedDataIt != storedDataHash.end())
+ auto storeDataHashResult = storedDataHash.insert(dataHash);
+ if(!storeDataHashResult.second)
{
string errMsg = "Database already contains data with hash: ";
errMsg += dataHash.toString();
@@ -87,7 +86,6 @@ namespace odhtdb
memcpy(storageData.data, data, dataSize);
DatabaseStorageQuarantineObject *databaseQuarantineStorageObject = new DatabaseStorageQuarantineObject(storageData, timestamp, creatorPublicKey);
quarantineStorageMap[creatorPublicKey].emplace_back(databaseQuarantineStorageObject);
- storedDataHash.insert(dataHash);
}
void DatabaseStorage::addUser(User *user, const Hash &hash)