aboutsummaryrefslogtreecommitdiff
path: root/src/DhtKey.cpp
blob: 1508657a3e4afa7d8c9c1f674a40ee246cd5c8d8 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
#include "../include/odhtdb/DhtKey.hpp"
#include "../include/odhtdb/types.hpp"

namespace odhtdb
{
    DhtKey::DhtKey(const Hash &key) : infoHash((const u8*)key.getData(), key.getSize())
    {
        firstByteOriginalValue = infoHash[0];
    }
    
    DhtKey::DhtKey(const dht::InfoHash &_infoHash) : infoHash(_infoHash)
    {
        firstByteOriginalValue = infoHash[0];
    }
    
    dht::InfoHash DhtKey::getNewDataListenerKey()
    {
        infoHash[0] = firstByteOriginalValue;
        return infoHash;
    }
    
    dht::InfoHash DhtKey::getRequestOldDataKey()
    {
        infoHash[0] = firstByteOriginalValue + 1;
        return infoHash;
    }
    
    dht::InfoHash DhtKey::getPingKey()
    {
        infoHash[0] = firstByteOriginalValue + 10;
        return infoHash;
    }
}