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

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

added replace flag

File size: 1012 bytes
RevLine 
[6266]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 ;
[6835]13 this->replace = false;
[6266]14}
15
16DHTMessage::DHTMessage( const Data& key ) {
17 // calculate hash of key
18 this->hash = NodeID::sha1( key.getBuffer(), key.getLength() / 8 );
19 this->key = key.clone();
20 this->ttl =0 ;
[6835]21 this->replace = false;
[6266]22}
23
24DHTMessage::DHTMessage( const Data& key, const Data& value ) {
25 // calculate hash of key
26 this->hash = NodeID::sha1( key.getBuffer(), key.getLength() / 8 );
27 this->key = key.clone();
28 this->values.push_back( value.clone() );
29 this->ttl =0 ;
[6835]30 this->replace = false;
[6266]31}
32
33DHTMessage::DHTMessage( const Data& key, const vector<Data>& values ) {
[6796]34 this->key = key.clone();
[6266]35 BOOST_FOREACH(const Data value, values )
36 this->values.push_back( value.clone() );
[6835]37 this->replace = false;
[6266]38}
39
40DHTMessage::~DHTMessage() {
41 this->key.release();
42 BOOST_FOREACH( Data& value, values ) value.release();
43}
44
45}}
Note: See TracBrowser for help on using the repository browser.