aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authordec05eba <0xdec05eba@gmail.com>2018-05-15 17:11:06 +0200
committerdec05eba <0xdec05eba@gmail.com>2018-05-15 17:11:08 +0200
commit66ec8dd9b9d3f1f71ce2158c2603586814cc7b8d (patch)
treedca425e8c703568f59621c1eb2cee5afffec2a03 /src
parent4b656c5600a28f05665e849715af3d08f29dff2f (diff)
Add versioning to request old data structure
Diffstat (limited to 'src')
-rw-r--r--src/Database.cpp8
1 files changed, 8 insertions, 0 deletions
diff --git a/src/Database.cpp b/src/Database.cpp
index ac5a941..5eedc7a 100644
--- a/src/Database.cpp
+++ b/src/Database.cpp
@@ -33,6 +33,7 @@ namespace odhtdb
const u16 DATABASE_CREATE_PACKET_STRUCTURE_VERSION = 1;
const u16 DATABASE_ADD_PACKET_STRUCTURE_VERSION = 1;
+ const u16 DATABASE_REQUEST_OLD_DATA_STRUCTURE_VERSION = 1;
class RequestQuarantineException : public runtime_error
{
@@ -251,6 +252,12 @@ namespace odhtdb
{
static_assert(HASH_LEN == OPENDHT_INFOHASH_LEN, "Wrong hashlen size, did it change with opendht upgrade?");
sibs::SafeDeserializer deserializer(value->data.data(), value->data.size());
+ u16 requestStructureVersion = deserializer.extract<u16>();
+ if(requestStructureVersion != DATABASE_REQUEST_OLD_DATA_STRUCTURE_VERSION)
+ {
+ Log::warn("Request: structure is version %d but we are at version %d, ignoring request", requestStructureVersion, DATABASE_REQUEST_OLD_DATA_STRUCTURE_VERSION);
+ return true;
+ }
InfoHash requestResponseInfoHash;
deserializer.extract(requestResponseInfoHash.data(), OPENDHT_INFOHASH_LEN);
if(*responseKeyShared == requestResponseInfoHash)
@@ -324,6 +331,7 @@ namespace odhtdb
seedInfoMap[*nodeToSeed.getRequestHash()] = newSeedInfo;
sibs::SafeSerializer serializer;
+ serializer.add(DATABASE_REQUEST_OLD_DATA_STRUCTURE_VERSION);
serializer.add(responseKey, OPENDHT_INFOHASH_LEN);
bool iHaveCreateNode = databaseStorage.doesNodeExist(*nodeToSeed.getRequestHash());
serializer.add(iHaveCreateNode ? (u8)0 : (u8)1);