Browse Source

naming conventions changed

cl-refactor
Vlad Gluhovsky 10 years ago
parent
commit
52b36b6b6a
  1. 6
      libwhisper/WhisperDB.cpp
  2. 6
      libwhisper/WhisperDB.h
  3. 26
      test/libwhisper/whisperDB.cpp

6
libwhisper/WhisperDB.cpp

@ -49,7 +49,7 @@ WhisperDB::~WhisperDB()
delete m_db; delete m_db;
} }
bool WhisperDB::put(dev::h256 const& _key, string const& _value) bool WhisperDB::insert(dev::h256 const& _key, string const& _value)
{ {
string s = _key.hex(); string s = _key.hex();
string cropped = s.substr(s.size() - 8); string cropped = s.substr(s.size() - 8);
@ -62,7 +62,7 @@ bool WhisperDB::put(dev::h256 const& _key, string const& _value)
return status.ok(); return status.ok();
} }
string WhisperDB::get(dev::h256 const& _key) const string WhisperDB::lookup(dev::h256 const& _key) const
{ {
string ret; string ret;
string s = _key.hex(); string s = _key.hex();
@ -76,7 +76,7 @@ string WhisperDB::get(dev::h256 const& _key) const
return ret; return ret;
} }
bool WhisperDB::erase(dev::h256 const& _key) bool WhisperDB::kill(dev::h256 const& _key)
{ {
string s = _key.hex(); string s = _key.hex();
string cropped = s.substr(s.size() - 8); string cropped = s.substr(s.size() - 8);

6
libwhisper/WhisperDB.h

@ -36,9 +36,9 @@ class WhisperDB
WhisperDB(); WhisperDB();
~WhisperDB(); ~WhisperDB();
bool put(dev::h256 const& _key, std::string const& _value); bool insert(dev::h256 const& _key, std::string const& _value);
bool erase(dev::h256 const& _key); bool kill(dev::h256 const& _key);
std::string get(dev::h256 const& _key) const; std::string lookup(dev::h256 const& _key) const;
private: private:
ldb::ReadOptions m_readOptions; ldb::ReadOptions m_readOptions;

26
test/libwhisper/whisperDB.cpp

@ -42,29 +42,29 @@ BOOST_AUTO_TEST_CASE(first)
string const text1 = "lorem_ipsum"; string const text1 = "lorem_ipsum";
string const text2 = "dolor_sit_amet"; string const text2 = "dolor_sit_amet";
db.erase(h1); db.kill(h1);
db.erase(h2); db.kill(h2);
db.put(h1, text2); db.insert(h1, text2);
s = db.get(h2); s = db.lookup(h2);
BOOST_REQUIRE(s.empty()); BOOST_REQUIRE(s.empty());
s = db.get(h1); s = db.lookup(h1);
BOOST_REQUIRE(!s.compare(text2)); BOOST_REQUIRE(!s.compare(text2));
db.put(h1, text1); db.insert(h1, text1);
s = db.get(h2); s = db.lookup(h2);
BOOST_REQUIRE(s.empty()); BOOST_REQUIRE(s.empty());
s = db.get(h1); s = db.lookup(h1);
BOOST_REQUIRE(!s.compare(text1)); BOOST_REQUIRE(!s.compare(text1));
db.put(h2, text2); db.insert(h2, text2);
s = db.get(h2); s = db.lookup(h2);
BOOST_REQUIRE(!s.compare(text2)); BOOST_REQUIRE(!s.compare(text2));
s = db.get(h1); s = db.lookup(h1);
BOOST_REQUIRE(!s.compare(text1)); BOOST_REQUIRE(!s.compare(text1));
db.erase(h1); db.kill(h1);
db.erase(h2); db.kill(h2);
} }
BOOST_AUTO_TEST_SUITE_END() BOOST_AUTO_TEST_SUITE_END()

Loading…
Cancel
Save