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

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

DHTTest working with 2 nodes

File size: 916 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 this->key = key.clone();
32 BOOST_FOREACH(const Data value, values )
33 this->values.push_back( value.clone() );
34}
35
36DHTMessage::~DHTMessage() {
37 this->key.release();
38 BOOST_FOREACH( Data& value, values ) value.release();
39}
40
41}}
Note: See TracBrowser for help on using the repository browser.