|
|
@ -45,28 +45,6 @@ CKevaTxUndo::apply(CCoinsViewCache& view) const |
|
|
|
/* ************************************************************************** */ |
|
|
|
/* ************************************************************************** */ |
|
|
|
/* CKevaMemPool. */ |
|
|
|
/* CKevaMemPool. */ |
|
|
|
|
|
|
|
|
|
|
|
uint256 |
|
|
|
|
|
|
|
CKevaMemPool::getTxForNamespace(const valtype& nameSpace) const |
|
|
|
|
|
|
|
{ |
|
|
|
|
|
|
|
#if 0 |
|
|
|
|
|
|
|
// JWU TODO: implement this!
|
|
|
|
|
|
|
|
NamespaceTxMap::const_iterator mi; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
mi = mapNamespaceRegs.find(nameSpace); |
|
|
|
|
|
|
|
if (mi != mapNamespaceRegs.end()) { |
|
|
|
|
|
|
|
assert(mapNamespaceKeyUpdates.count(name) == 0); |
|
|
|
|
|
|
|
return mi->second; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
mi = mapNamespaceKeyUpdates.find(name); |
|
|
|
|
|
|
|
if (mi != mapNameUpdates.end ()) { |
|
|
|
|
|
|
|
assert (mapNameRegs.count (name) == 0); |
|
|
|
|
|
|
|
return mi->second; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
#endif |
|
|
|
|
|
|
|
return uint256(); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
void |
|
|
|
void |
|
|
|
CKevaMemPool::addUnchecked (const uint256& hash, const CTxMemPoolEntry& entry) |
|
|
|
CKevaMemPool::addUnchecked (const uint256& hash, const CTxMemPoolEntry& entry) |
|
|
|
{ |
|
|
|
{ |
|
|
@ -80,10 +58,8 @@ CKevaMemPool::addUnchecked (const uint256& hash, const CTxMemPoolEntry& entry) |
|
|
|
|
|
|
|
|
|
|
|
if (entry.isNamespaceKeyUpdate ()) { |
|
|
|
if (entry.isNamespaceKeyUpdate ()) { |
|
|
|
const valtype& nameSpace = entry.getNamespace(); |
|
|
|
const valtype& nameSpace = entry.getNamespace(); |
|
|
|
const valtype& key = entry.getKey(); |
|
|
|
assert(mapNamespaceUpdates.count(nameSpace) == 0); |
|
|
|
NamespaceKeyTuple tuple(nameSpace, key); |
|
|
|
mapNamespaceUpdates.insert (std::make_pair(nameSpace, hash)); |
|
|
|
assert(mapNamespaceKeyUpdates.count(tuple) == 0); |
|
|
|
|
|
|
|
mapNamespaceKeyUpdates.insert (std::make_pair(tuple, hash)); |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
@ -99,10 +75,9 @@ CKevaMemPool::remove (const CTxMemPoolEntry& entry) |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
if (entry.isNamespaceKeyUpdate()) { |
|
|
|
if (entry.isNamespaceKeyUpdate()) { |
|
|
|
NamespaceKeyTuple tuple(entry.getNamespace(), entry.getKey()); |
|
|
|
const NamespaceTxMap::iterator mit = mapNamespaceUpdates.find(entry.getNamespace()); |
|
|
|
const NamespaceKeyTxMap::iterator mit = mapNamespaceKeyUpdates.find(tuple); |
|
|
|
assert (mit != mapNamespaceUpdates.end()); |
|
|
|
assert (mit != mapNamespaceKeyUpdates.end()); |
|
|
|
mapNamespaceUpdates.erase(mit); |
|
|
|
mapNamespaceKeyUpdates.erase (mit); |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
@ -143,7 +118,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<valtype, valtype>> namespaceKeyUpdates; |
|
|
|
std::set<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()) { |
|
|
@ -167,14 +142,12 @@ 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 NamespaceTxMap::const_iterator mit = mapNamespaceUpdates.find(nameSpace); |
|
|
|
std::tuple<valtype, valtype> tuple(nameSpace, key); |
|
|
|
assert (mit != mapNamespaceUpdates.end ()); |
|
|
|
const NamespaceKeyTxMap::const_iterator mit = mapNamespaceKeyUpdates.find(tuple); |
|
|
|
|
|
|
|
assert (mit != mapNamespaceKeyUpdates.end ()); |
|
|
|
|
|
|
|
assert (mit->second == txHash); |
|
|
|
assert (mit->second == txHash); |
|
|
|
|
|
|
|
|
|
|
|
assert (namespaceKeyUpdates.count(tuple) == 0); |
|
|
|
assert (namespaceKeyUpdates.count(nameSpace) == 0); |
|
|
|
namespaceKeyUpdates.insert(tuple); |
|
|
|
namespaceKeyUpdates.insert(nameSpace); |
|
|
|
|
|
|
|
|
|
|
|
#if 0 |
|
|
|
#if 0 |
|
|
|
/* As above, use nHeight+1 for the expiration check. */ |
|
|
|
/* As above, use nHeight+1 for the expiration check. */ |
|
|
@ -188,7 +161,7 @@ CKevaMemPool::check(const CCoinsView& coins) const |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
assert(nameRegs.size() == mapNamespaceRegs.size()); |
|
|
|
assert(nameRegs.size() == mapNamespaceRegs.size()); |
|
|
|
assert(namespaceKeyUpdates.size() == mapNamespaceKeyUpdates.size()); |
|
|
|
assert(namespaceKeyUpdates.size() == mapNamespaceUpdates.size()); |
|
|
|
|
|
|
|
|
|
|
|
/* Check that nameRegs and nameUpdates are disjoint. They must be since
|
|
|
|
/* Check that nameRegs and nameUpdates are disjoint. They must be since
|
|
|
|
a name can only be in either category, depending on whether it exists |
|
|
|
a name can only be in either category, depending on whether it exists |
|
|
@ -200,8 +173,8 @@ CKevaMemPool::check(const CCoinsView& coins) const |
|
|
|
} |
|
|
|
} |
|
|
|
#endif |
|
|
|
#endif |
|
|
|
|
|
|
|
|
|
|
|
for (const auto& namespaceKey : namespaceKeyUpdates) { |
|
|
|
for (const auto& nameSpace : namespaceKeyUpdates) { |
|
|
|
assert(nameRegs.count(std::get<0>(namespaceKey)) == 0); |
|
|
|
assert(nameRegs.count(nameSpace) == 0); |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
@ -238,8 +211,9 @@ CKevaMemPool::checkTx (const CTransaction& tx) const |
|
|
|
{ |
|
|
|
{ |
|
|
|
const valtype& nameSpace = nameOp.getOpNamespace(); |
|
|
|
const valtype& nameSpace = nameOp.getOpNamespace(); |
|
|
|
const valtype& key = nameOp.getOpKey(); |
|
|
|
const valtype& key = nameOp.getOpKey(); |
|
|
|
if (updatesKey(nameSpace, key)) |
|
|
|
if (updatesNamespace(nameSpace)) { |
|
|
|
return false; |
|
|
|
return false; |
|
|
|
|
|
|
|
} |
|
|
|
break; |
|
|
|
break; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|