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 ) {
|
---|
[6796] | 31 | this->key = key.clone();
|
---|
[6266] | 32 | BOOST_FOREACH(const Data value, values )
|
---|
| 33 | this->values.push_back( value.clone() );
|
---|
| 34 | }
|
---|
| 35 |
|
---|
| 36 | DHTMessage::~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.