Browse Source

Fixed tuple const valtype& crash issues.

0.16.3-insta
Jianping Wu 6 years ago
parent
commit
252319e899
  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) @@ -227,6 +227,8 @@ CKevaCache::remove(const valtype& nameSpace, const valtype& key)
if (ei != entries.end ())
entries.erase (ei);
//JWU TODO: make sure to remove namespace registration when
// the corresponding block is disconnected!!!
#if 0
deleted.insert(name);
#endif

6
src/keva/common.h

@ -287,8 +287,8 @@ private: @@ -287,8 +287,8 @@ private:
class NameComparator
{
public:
inline bool operator() (const std::tuple<const valtype&, const valtype&> a,
const std::tuple<const valtype&, const valtype&> b) const
inline bool operator() (const std::tuple<valtype, valtype> a,
const std::tuple<valtype, valtype> b) const
{
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();
@ -378,7 +378,7 @@ public: @@ -378,7 +378,7 @@ public:
* Type of name entry map. This is public because it is also used
* 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;
private:

4
src/keva/main.cpp

@ -143,7 +143,7 @@ CKevaMemPool::check(const CCoinsView& coins) const @@ -143,7 +143,7 @@ CKevaMemPool::check(const CCoinsView& coins) const
nHeight = mapBlockIndex.find (blockHash)->second->nHeight;
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) {
const uint256 txHash = entry.GetTx ().GetHash ();
if (entry.isNamespaceRegistration()) {
@ -168,7 +168,7 @@ CKevaMemPool::check(const CCoinsView& coins) const @@ -168,7 +168,7 @@ CKevaMemPool::check(const CCoinsView& coins) const
if (entry.isNamespaceKeyUpdate()) {
const valtype& nameSpace = entry.getNamespace();
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);
assert (mit != mapNamespaceKeyUpdates.end ());
assert (mit->second == txHash);

Loading…
Cancel
Save