aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authordec05eba <0xdec05eba@gmail.com>2018-05-30 14:52:14 +0200
committerdec05eba <0xdec05eba@gmail.com>2018-05-30 14:52:17 +0200
commit9ef02410fda13bffd6ff2fc7172d19d1f7c25a94 (patch)
tree31a301ec139b00800b95ecbc1d201a00fdd2f989
parent0ce0eaf93dea198a6b0f812c724be9bad74270b2 (diff)
Add flag for data loaded from cache
-rw-r--r--include/odhtdb/Database.hpp12
-rw-r--r--src/DatabaseStorage.cpp7
2 files changed, 14 insertions, 5 deletions
diff --git a/include/odhtdb/Database.hpp b/include/odhtdb/Database.hpp
index 5ec0da0..85207a0 100644
--- a/include/odhtdb/Database.hpp
+++ b/include/odhtdb/Database.hpp
@@ -55,12 +55,14 @@ namespace odhtdb
u64 timestamp; // In microseconds
const Signature::PublicKey *creatorPublicKey;
const DataView groupId;
+ bool loadedFromCache;
DatabaseCreateNodeRequest(const Hash *_nodeHash, u64 _timestamp, const Signature::PublicKey *_creatorPublicKey, const DataView &_groupId) :
nodeHash(_nodeHash),
timestamp(_timestamp),
creatorPublicKey(_creatorPublicKey),
- groupId(_groupId)
+ groupId(_groupId),
+ loadedFromCache(false)
{
}
@@ -75,13 +77,15 @@ namespace odhtdb
u64 timestamp; // In microseconds
const Signature::PublicKey *creatorPublicKey;
const DataView decryptedData;
+ bool loadedFromCache;
DatabaseAddNodeRequest(const Hash *_nodeHash, const Hash *_requestHash, u64 _timestamp, const Signature::PublicKey *_creatorPublicKey, const DataView &_decryptedData) :
nodeHash(_nodeHash),
requestHash(_requestHash),
timestamp(_timestamp),
creatorPublicKey(_creatorPublicKey),
- decryptedData(_decryptedData)
+ decryptedData(_decryptedData),
+ loadedFromCache(false)
{
}
@@ -97,6 +101,7 @@ namespace odhtdb
const Signature::PublicKey *creatorPublicKey;
const Signature::PublicKey *userToAddPublicKey;
const DataView groupToAddUserTo;
+ bool loadedFromCache;
DatabaseAddUserRequest(const Hash *_nodeHash, const Hash *_requestHash, u64 _timestamp, const Signature::PublicKey *_creatorPublicKey, const Signature::PublicKey *_userToAddPublicKey, const DataView &_groupToAddUserTo) :
nodeHash(_nodeHash),
@@ -104,7 +109,8 @@ namespace odhtdb
timestamp(_timestamp),
creatorPublicKey(_creatorPublicKey),
userToAddPublicKey(_userToAddPublicKey),
- groupToAddUserTo(_groupToAddUserTo)
+ groupToAddUserTo(_groupToAddUserTo),
+ loadedFromCache(false)
{
}
diff --git a/src/DatabaseStorage.cpp b/src/DatabaseStorage.cpp
index 6e4046d..407aa5c 100644
--- a/src/DatabaseStorage.cpp
+++ b/src/DatabaseStorage.cpp
@@ -241,7 +241,8 @@ namespace odhtdb
const DataView adminGroupRaw = nodeQuery.getBlob(2);
memcpy(adminGroupId, adminGroupRaw.data, GROUP_ID_LENGTH);
- const DatabaseCreateNodeRequest createNodeRequest(&nodeHash, timestamp, &creatorPublicKey, DataView(adminGroupId, GROUP_ID_LENGTH));
+ DatabaseCreateNodeRequest createNodeRequest(&nodeHash, timestamp, &creatorPublicKey, DataView(adminGroupId, GROUP_ID_LENGTH));
+ createNodeRequest.loadedFromCache = true;
database->onCreateNodeCallbackFunc(createNodeRequest);
}
}
@@ -288,7 +289,8 @@ namespace odhtdb
OwnedByteArray decryptedData(new u8[decryptedDataSize], decryptedDataSize);
memcpy(decryptedData.data, decryptedDataRaw, decryptedDataSize);
- const DatabaseAddNodeRequest addNodeRequest(&nodeHash, &requestHash, timestamp, &creatorPublicKey, DataView(decryptedData.data, decryptedData.size));
+ DatabaseAddNodeRequest addNodeRequest(&nodeHash, &requestHash, timestamp, &creatorPublicKey, DataView(decryptedData.data, decryptedData.size));
+ addNodeRequest.loadedFromCache = true;
database->onAddNodeCallbackFunc(addNodeRequest);
}
else if(operation == DatabaseOperation::ADD_USER)
@@ -317,6 +319,7 @@ namespace odhtdb
memcpy(groupToAddUserTo, groupToAddUserToRaw, GROUP_ID_LENGTH);
DatabaseAddUserRequest addUserRequest(&nodeHash, &requestHash, timestamp, &creatorPublicKey, &userToAddPublicKey, DataView(groupToAddUserTo, GROUP_ID_LENGTH));
+ addUserRequest.loadedFromCache = true;
database->onAddUserCallbackFunc(addUserRequest);
}
}