Changeset 10572 for source/ariba/overlay/messages
- Timestamp:
- Jun 18, 2012, 1:40:59 PM (12 years ago)
- Location:
- source/ariba/overlay/messages
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
source/ariba/overlay/messages/DHTMessage.cpp
r6919 r10572 8 8 vsznDefault(DHTMessage); 9 9 10 DHTMessage::DHTMessage() { 11 this->key.setLength(0); 12 this->ttl = 0; 13 this->replace = false; 14 } 10 DHTMessage::DHTMessage() : 11 ttl( 0 ), 12 replace( false ) 13 {} 15 14 16 DHTMessage::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; 21 this->replace = false; 22 } 15 DHTMessage::DHTMessage( const Data& key ) : 16 ttl( 0 ), 17 replace( false ), 18 key( key.clone() ) 19 {} 23 20 24 DHTMessage::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; 30 this->replace = false; 31 } 21 DHTMessage::DHTMessage( const Data& key, const Data& value ) : 22 ttl( 0 ), 23 replace( false ), 24 key( key.clone() ), 25 values(1, value.clone()) 26 {} 32 27 33 DHTMessage::DHTMessage( const Data& key, const vector<Data>& values ) { 34 this->hash = NodeID::sha1( key.getBuffer(), key.getLength() / 8 ); 35 this->key = key.clone(); 28 DHTMessage::DHTMessage( const Data& key, const vector<Data>& values ) : 29 ttl( 0 ), 30 replace( false ), 31 key( key.clone() ) 32 { 33 // preallocate enough room so we don't need to copy a lot 34 this->values.reserve(values.size()); 36 35 BOOST_FOREACH(const Data value, values ) 37 36 this->values.push_back( value.clone() ); 38 this->ttl = 0;39 this->replace = false;40 37 } 41 38 -
source/ariba/overlay/messages/DHTMessage.h
r6919 r10572 20 20 21 21 const NodeID& getHashedKey() const { 22 return hash;22 return NodeID::sha1( key.getBuffer(), key.getLength() / 8 ); 23 23 } 24 24 … … 58 58 59 59 private: 60 NodeID hash;61 60 uint16_t ttl; 62 61 bool replace;
Note:
See TracChangeset
for help on using the changeset viewer.