Browse Source

Fixed tuple const valtype& crash issues.

cn
Jianping Wu 6 years ago
parent
commit
83f7bd5071
  1. 2
      src/keva/common.cpp
  2. 6
      src/keva/common.h
  3. 4
      src/keva/main.cpp

2
src/keva/common.cpp

@ -227,6 +227,8 @@ CKevaCache::remove(const valtype& nameSpace, const valtype& key)
if (ei != entries.end ()) if (ei != entries.end ())
entries.erase (ei); entries.erase (ei);
//JWU TODO: make sure to remove namespace registration when
// the corresponding block is disconnected!!!
#if 0 #if 0
deleted.insert(name); deleted.insert(name);
#endif #endif

6
src/keva/common.h

@ -287,8 +287,8 @@ private:
class NameComparator class NameComparator
{ {
public: public:
inline bool operator() (const std::tuple<const valtype&, const valtype&> a, inline bool operator() (const std::tuple<valtype, valtype> a,
const std::tuple<const valtype&, const valtype&> b) const const std::tuple<valtype, valtype> b) const
{ {
unsigned int aSize = std::get<0>(a).size() + std::get<1>(a).size(); unsigned int aSize = std::get<0>(a).size() + std::get<1>(a).size();
unsigned int bSize = std::get<0>(b).size() + std::get<1>(b).size(); unsigned int bSize = std::get<0>(b).size() + std::get<1>(b).size();
@ -378,7 +378,7 @@ public:
* Type of name entry map. This is public because it is also used * Type of name entry map. This is public because it is also used
* by the unit tests. * by the unit tests.
*/ */
typedef std::map<std::tuple<const valtype&, const valtype&>, CKevaData, NameComparator> EntryMap; typedef std::map<std::tuple<valtype, valtype>, CKevaData, NameComparator> EntryMap;
typedef std::set<valtype> NamespaceSet; typedef std::set<valtype> NamespaceSet;
private: private:

4
src/keva/main.cpp

@ -143,7 +143,7 @@ CKevaMemPool::check(const CCoinsView& coins) const
nHeight = mapBlockIndex.find (blockHash)->second->nHeight; nHeight = mapBlockIndex.find (blockHash)->second->nHeight;
std::set<valtype> nameRegs; std::set<valtype> nameRegs;
std::set<std::tuple<const valtype&, const valtype&>> namespaceKeyUpdates; std::set<std::tuple<valtype, valtype>> namespaceKeyUpdates;
for (const auto& entry : pool.mapTx) { for (const auto& entry : pool.mapTx) {
const uint256 txHash = entry.GetTx ().GetHash (); const uint256 txHash = entry.GetTx ().GetHash ();
if (entry.isNamespaceRegistration()) { if (entry.isNamespaceRegistration()) {
@ -168,7 +168,7 @@ CKevaMemPool::check(const CCoinsView& coins) const
if (entry.isNamespaceKeyUpdate()) { if (entry.isNamespaceKeyUpdate()) {
const valtype& nameSpace = entry.getNamespace(); const valtype& nameSpace = entry.getNamespace();
const valtype& key = entry.getKey(); const valtype& key = entry.getKey();
std::tuple<const valtype&, const valtype&> tuple(nameSpace, key); std::tuple<valtype, valtype> tuple(nameSpace, key);
const NamespaceKeyTxMap::const_iterator mit = mapNamespaceKeyUpdates.find(tuple); const NamespaceKeyTxMap::const_iterator mit = mapNamespaceKeyUpdates.find(tuple);
assert (mit != mapNamespaceKeyUpdates.end ()); assert (mit != mapNamespaceKeyUpdates.end ());
assert (mit->second == txHash); assert (mit->second == txHash);

Loading…
Cancel
Save