source: source/ariba/overlay/messages/DHTMessage.cpp@ 6266

Last change on this file since 6266 was 6266, checked in by mies, 15 years ago

added basic DHT functionality (untested)

File size: 890 bytes
Line 
1#include "DHTMessage.h"
2
3#include<boost/foreach.hpp>
4
5namespace ariba {
6namespace overlay {
7
8vsznDefault(DHTMessage);
9
10DHTMessage::DHTMessage() {
11 this->key.setLength(0);
12 this->ttl =0 ;
13}
14
15DHTMessage::DHTMessage( const Data& key ) {
16 // calculate hash of key
17 this->hash = NodeID::sha1( key.getBuffer(), key.getLength() / 8 );
18 this->key = key.clone();
19 this->ttl =0 ;
20}
21
22DHTMessage::DHTMessage( const Data& key, const Data& value ) {
23 // calculate hash of key
24 this->hash = NodeID::sha1( key.getBuffer(), key.getLength() / 8 );
25 this->key = key.clone();
26 this->values.push_back( value.clone() );
27 this->ttl =0 ;
28}
29
30DHTMessage::DHTMessage( const Data& key, const vector<Data>& values ) {
31 BOOST_FOREACH(const Data value, values )
32 this->values.push_back( value.clone() );
33}
34
35DHTMessage::~DHTMessage() {
36 this->key.release();
37 BOOST_FOREACH( Data& value, values ) value.release();
38}
39
40}}
Note: See TracBrowser for help on using the repository browser.