Last change
on this file since 6584 was 6266, checked in by mies, 15 years ago |
added basic DHT functionality (untested)
|
File size:
890 bytes
|
Rev | Line | |
---|
[6266] | 1 | #include "DHTMessage.h"
|
---|
| 2 |
|
---|
| 3 | #include<boost/foreach.hpp>
|
---|
| 4 |
|
---|
| 5 | namespace ariba {
|
---|
| 6 | namespace overlay {
|
---|
| 7 |
|
---|
| 8 | vsznDefault(DHTMessage);
|
---|
| 9 |
|
---|
| 10 | DHTMessage::DHTMessage() {
|
---|
| 11 | this->key.setLength(0);
|
---|
| 12 | this->ttl =0 ;
|
---|
| 13 | }
|
---|
| 14 |
|
---|
| 15 | DHTMessage::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 |
|
---|
| 22 | DHTMessage::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 |
|
---|
| 30 | DHTMessage::DHTMessage( const Data& key, const vector<Data>& values ) {
|
---|
| 31 | BOOST_FOREACH(const Data value, values )
|
---|
| 32 | this->values.push_back( value.clone() );
|
---|
| 33 | }
|
---|
| 34 |
|
---|
| 35 | DHTMessage::~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.