Browse Source

Stored the latest tx output in namespace data.

cn
Jianping Wu 6 years ago
parent
commit
c72450e983
  1. 10
      src/coins.cpp
  2. 6
      src/keva/common.cpp
  3. 11
      src/keva/common.h

10
src/coins.cpp

@ -200,9 +200,9 @@ CNameIterator* CCoinsViewCache::IterateNames() const {
name history. */ name history. */
void CCoinsViewCache::SetName(const valtype &nameSpace, const valtype &key, const CKevaData& data, bool undo) void CCoinsViewCache::SetName(const valtype &nameSpace, const valtype &key, const CKevaData& data, bool undo)
{ {
#if 0
CKevaData oldData; CKevaData oldData;
if (GetName(nameSpace, key, oldData)) { if (GetName(nameSpace, key, oldData)) {
#if 0
cacheNames.removeExpireIndex(name, oldData.getHeight()); cacheNames.removeExpireIndex(name, oldData.getHeight());
/* Update the name history. If we are undoing, we expect that /* Update the name history. If we are undoing, we expect that
@ -228,11 +228,15 @@ void CCoinsViewCache::SetName(const valtype &nameSpace, const valtype &key, cons
cacheNames.setHistory(name, history); cacheNames.setHistory(name, history);
} }
#endif
} else { } else {
assert (!undo); assert (!undo);
} }
#endif
CKevaData namespaceData;
if (GetNamespace(nameSpace, namespaceData)) {
namespaceData.setUpdateOutpoint(data.getUpdateOutpoint());
cacheNames.setNamespace(nameSpace, namespaceData);
}
cacheNames.set(nameSpace, key, data); cacheNames.set(nameSpace, key, data);
#if 0 #if 0
cacheNames.addExpireIndex(name, data.getHeight()); cacheNames.addExpireIndex(name, data.getHeight());

6
src/keva/common.cpp

@ -200,6 +200,12 @@ CKevaCache::GetNamespace(const valtype& nameSpace, CKevaData& data) const
return get(nameSpace, ValtypeFromString(CKevaScript::KEVA_DISPLAY_NAME_KEY), data); return get(nameSpace, ValtypeFromString(CKevaScript::KEVA_DISPLAY_NAME_KEY), data);
} }
void
CKevaCache::setNamespace(const valtype& nameSpace, const CKevaData& data)
{
set(nameSpace, ValtypeFromString(CKevaScript::KEVA_DISPLAY_NAME_KEY), data);
}
void void
CKevaCache::set(const valtype& nameSpace, const valtype& key, const CKevaData& data) CKevaCache::set(const valtype& nameSpace, const valtype& key, const CKevaData& data)
{ {

11
src/keva/common.h

@ -130,6 +130,15 @@ public:
return prevout; return prevout;
} }
/**
* Get the namespace's updated outpoint.
*/
inline void
setUpdateOutpoint (const COutPoint& out)
{
prevout = out;
}
/** /**
* Get the address. * Get the address.
* @return The name's address. * @return The name's address.
@ -458,6 +467,8 @@ public:
removes the "deleted" mark. */ removes the "deleted" mark. */
void set(const valtype& nameSpace, const valtype& key, const CKevaData& data); void set(const valtype& nameSpace, const valtype& key, const CKevaData& data);
void setNamespace(const valtype& nameSpace, const CKevaData& data);
/* Delete a name. If it is in the "entries" set also, remove it there. */ /* Delete a name. If it is in the "entries" set also, remove it there. */
void remove(const valtype& nameSpace, const valtype& key); void remove(const valtype& nameSpace, const valtype& key);

Loading…
Cancel
Save