aboutsummaryrefslogtreecommitdiff
path: root/src/DhtKey.cpp
diff options
context:
space:
mode:
authorAleksi Lindeman <0xdec05eba@gmail.com>2018-03-05 22:45:56 +0100
committerAleksi Lindeman <0xdec05eba@gmail.com>2018-03-05 22:48:26 +0100
commit2ffb47d0043e57707474e5ae811f97c2e5e93f25 (patch)
treefd60b300cdf736de5adc68b395105dcfc6a43f09 /src/DhtKey.cpp
parent66661e47dc826f50b690e080057f47a0ea27016c (diff)
Implement 'create' operation, add seeding
Seeding is currently only done on the key you specify, in the future the user should request data that it can seed.
Diffstat (limited to 'src/DhtKey.cpp')
-rw-r--r--src/DhtKey.cpp22
1 files changed, 22 insertions, 0 deletions
diff --git a/src/DhtKey.cpp b/src/DhtKey.cpp
new file mode 100644
index 0000000..ea59740
--- /dev/null
+++ b/src/DhtKey.cpp
@@ -0,0 +1,22 @@
+#include "../include/DhtKey.hpp"
+#include "../include/types.hpp"
+
+namespace odhtdb
+{
+ DhtKey::DhtKey(const Hash &key) : infoHash((const u8*)key.getData(), key.getSize())
+ {
+ firstByteOriginalValue = infoHash[0];
+ }
+
+ const dht::InfoHash& DhtKey::getNewDataListenerKey()
+ {
+ infoHash[0] = firstByteOriginalValue;
+ return infoHash;
+ }
+
+ const dht::InfoHash& DhtKey::getRequestOldDataKey()
+ {
+ infoHash[0] = firstByteOriginalValue + 1;
+ return infoHash;
+ }
+}