Browse Source

Updated keva related function names.

issue_19
Just Wonder 5 years ago
parent
commit
c8875d60fa
  1. 4
      src/coins.cpp
  2. 4
      src/coins.h
  3. 10
      src/keva/main.cpp
  4. 6
      src/rpc/rpckeva_nonwallet.cpp
  5. 32
      src/test/keva_tests.cpp
  6. 6
      src/validation.cpp

4
src/coins.cpp

@ -208,7 +208,7 @@ CKevaIterator* CCoinsViewCache::IterateAssociatedNamespaces(const valtype& nameS @@ -208,7 +208,7 @@ CKevaIterator* CCoinsViewCache::IterateAssociatedNamespaces(const valtype& nameS
time. The ordinary case (!undo) means that we update the name normally,
going forward in time. This is important for keeping track of the
name history. */
void CCoinsViewCache::SetName(const valtype &nameSpace, const valtype &key, const CKevaData& data, bool undo)
void CCoinsViewCache::SetKeyValue(const valtype &nameSpace, const valtype &key, const CKevaData& data, bool undo)
{
cacheNames.set(nameSpace, key, data);
@ -225,7 +225,7 @@ void CCoinsViewCache::SetName(const valtype &nameSpace, const valtype &key, cons @@ -225,7 +225,7 @@ void CCoinsViewCache::SetName(const valtype &nameSpace, const valtype &key, cons
cacheNames.associateNamespaces(nameSpace, associdateNamespace, data);
}
void CCoinsViewCache::DeleteName(const valtype &nameSpace, const valtype &key) {
void CCoinsViewCache::DeleteKey(const valtype &nameSpace, const valtype &key) {
CKevaData oldData;
if (!GetName(nameSpace, key, oldData)) {
assert(false);

4
src/coins.h

@ -263,8 +263,8 @@ public: @@ -263,8 +263,8 @@ public:
}
/* Changes to the name database. */
void SetName(const valtype &nameSpace, const valtype &key, const CKevaData &data, bool undo);
void DeleteName(const valtype &nameSpace, const valtype &key);
void SetKeyValue(const valtype &nameSpace, const valtype &key, const CKevaData &data, bool undo);
void DeleteKey(const valtype &nameSpace, const valtype &key);
/**
* Check if we have the given utxo already loaded in this cache.

10
src/keva/main.cpp

@ -39,10 +39,10 @@ void @@ -39,10 +39,10 @@ void
CKevaTxUndo::apply(CCoinsViewCache& view) const
{
if (isNew) {
view.DeleteName(nameSpace, key);
view.DeleteKey(nameSpace, key);
}
else {
view.SetName(nameSpace, key, oldData, true);
view.SetKeyValue(nameSpace, key, oldData, true);
}
}
@ -403,7 +403,7 @@ void ApplyKevaTransaction(const CTransaction& tx, const CBlockIndex& pindex, @@ -403,7 +403,7 @@ void ApplyKevaTransaction(const CTransaction& tx, const CBlockIndex& pindex,
CKevaData data;
data.fromScript(nHeight, COutPoint(tx.GetHash(), i), op);
view.SetName(nameSpace, key, data, false);
view.SetKeyValue(nameSpace, key, data, false);
notifier.KevaNamespaceCreated(tx, pindex, EncodeBase58Check(nameSpace));
} else if (op.isAnyUpdate()) {
const valtype& nameSpace = op.getOpNamespace();
@ -419,12 +419,12 @@ void ApplyKevaTransaction(const CTransaction& tx, const CBlockIndex& pindex, @@ -419,12 +419,12 @@ void ApplyKevaTransaction(const CTransaction& tx, const CBlockIndex& pindex,
if (op.isDelete()) {
CKevaData oldData;
if (view.GetName(nameSpace, key, oldData)) {
view.DeleteName(nameSpace, key);
view.DeleteKey(nameSpace, key);
notifier.KevaDeleted(tx, pindex, EncodeBase58Check(nameSpace), ValtypeToString(key));
}
} else {
data.fromScript(nHeight, COutPoint(tx.GetHash(), i), op);
view.SetName(nameSpace, key, data, false);
view.SetKeyValue(nameSpace, key, data, false);
notifier.KevaUpdated(tx, pindex, EncodeBase58Check(nameSpace), ValtypeToString(key), ValtypeToString(data.getValue()));
}
}

6
src/rpc/rpckeva_nonwallet.cpp

@ -362,9 +362,9 @@ UniValue keva_group_filter(const JSONRPCRequest& request) @@ -362,9 +362,9 @@ UniValue keva_group_filter(const JSONRPCRequest& request)
" ...\n"
"]\n"
"\nExamples:\n"
+ HelpExampleCli ("keva_filter", "\"namespaceId\" \"all\"")
+ HelpExampleCli ("keva_filter", "\"namespaceId\" \"self\" 96000 0 0 \"stat\"")
+ HelpExampleRpc ("keva_filter", "\"namespaceId\"")
+ HelpExampleCli ("keva_group_filter", "\"namespaceId\" \"all\"")
+ HelpExampleCli ("keva_group_filter", "\"namespaceId\" \"self\" 96000 0 0 \"stat\"")
+ HelpExampleRpc ("keva_group_filter", "\"namespaceId\"")
);
RPCTypeCheck(request.params, {

32
src/test/keva_tests.cpp

@ -124,7 +124,7 @@ BOOST_AUTO_TEST_CASE (name_database) @@ -124,7 +124,7 @@ BOOST_AUTO_TEST_CASE (name_database)
BOOST_CHECK (setRet == setExpected);
BOOST_CHECK (!view.GetName (name1, data2));
view.SetName (name1, dataHeight2, false);
view.SetKeyValue (name1, dataHeight2, false);
BOOST_CHECK (view.GetName (name1, data2));
BOOST_CHECK (dataHeight2 == data2);
@ -138,12 +138,12 @@ BOOST_AUTO_TEST_CASE (name_database) @@ -138,12 +138,12 @@ BOOST_AUTO_TEST_CASE (name_database)
BOOST_CHECK (view.GetName (name1, data2));
BOOST_CHECK (dataHeight2 == data2);
view.SetName (name2, dataHeight2, false);
view.SetKeyValue (name2, dataHeight2, false);
BOOST_CHECK (view.GetNamesForHeight (height2, setRet));
setExpected.insert (name2);
BOOST_CHECK (setRet == setExpected);
view.DeleteName (name1);
view.DeleteKey (name1);
BOOST_CHECK (!view.GetName (name1, data2));
BOOST_CHECK (view.Flush());
BOOST_CHECK (!view.GetName (name1, data2));
@ -152,9 +152,9 @@ BOOST_AUTO_TEST_CASE (name_database) @@ -152,9 +152,9 @@ BOOST_AUTO_TEST_CASE (name_database)
setExpected.erase (name1);
BOOST_CHECK (setRet == setExpected);
view.SetName (name2, dataHeight1, false);
view.SetKeyValue (name2, dataHeight1, false);
BOOST_CHECK (view.Flush());
view.SetName (name1, dataHeight1, false);
view.SetKeyValue (name1, dataHeight1, false);
BOOST_CHECK (view.GetNamesForHeight (height2, setRet));
setExpected.clear();
@ -420,8 +420,8 @@ NameIterationTester::add (const std::string& n) @@ -420,8 +420,8 @@ NameIterationTester::add (const std::string& n)
assert (data.count (name) == 0);
data[name] = testData;
hybrid.SetName (name, testData, false);
cache.SetName (name, testData, false);
hybrid.SetKeyValue (name, testData, false);
cache.SetKeyValue (name, testData, false);
verify();
}
@ -433,8 +433,8 @@ NameIterationTester::update (const std::string& n) @@ -433,8 +433,8 @@ NameIterationTester::update (const std::string& n)
assert (data.count (name) == 1);
data[name] = testData;
hybrid.SetName (name, testData, false);
cache.SetName (name, testData, false);
hybrid.SetKeyValue (name, testData, false);
cache.SetKeyValue (name, testData, false);
verify();
}
@ -445,8 +445,8 @@ NameIterationTester::remove (const std::string& n) @@ -445,8 +445,8 @@ NameIterationTester::remove (const std::string& n)
assert (data.count (name) == 1);
data.erase (name);
hybrid.DeleteName (name);
cache.DeleteName (name);
hybrid.DeleteKey (name);
cache.DeleteKey (name);
verify();
}
@ -538,7 +538,7 @@ BOOST_AUTO_TEST_CASE (name_tx_verification) @@ -538,7 +538,7 @@ BOOST_AUTO_TEST_CASE (name_tx_verification)
CNameData data1;
data1.fromScript (100000, inFirst, CNameScript (scrFirst));
view.SetName (name1, data1, false);
view.SetKeyValue (name1, data1, false);
/* ****************************************************** */
/* Try out the Namecoin / non-Namecoin tx version check. */
@ -604,7 +604,7 @@ BOOST_AUTO_TEST_CASE (name_tx_verification) @@ -604,7 +604,7 @@ BOOST_AUTO_TEST_CASE (name_tx_verification)
CCoinsViewCache viewFirst(&view);
CCoinsViewCache viewUpd(&view);
data1.fromScript (100000, inUpdate, CNameScript (scrUpdate));
viewUpd.SetName (name1, data1, false);
viewUpd.SetKeyValue (name1, data1, false);
/* Check update of UPDATE output, plus expiry. */
mtx = CMutableTransaction (baseTx);
@ -647,14 +647,14 @@ BOOST_AUTO_TEST_CASE (name_tx_verification) @@ -647,14 +647,14 @@ BOOST_AUTO_TEST_CASE (name_tx_verification)
mtx.vout.push_back (CTxOut (COIN, scrUpdate));
mtx.vin.push_back (CTxIn (inNew));
CCoinsViewCache viewNew(&view);
viewNew.DeleteName (name1);
viewNew.DeleteKey (name1);
BOOST_CHECK (!CheckNameTransaction (mtx, 110000, viewNew, state, 0));
/* ********************************** */
/* Test NAME_FIRSTUPDATE validation. */
CCoinsViewCache viewClean(&view);
viewClean.DeleteName (name1);
viewClean.DeleteKey (name1);
/* Basic valid transaction. */
mtx = CMutableTransaction (baseTx);
@ -869,7 +869,7 @@ BOOST_AUTO_TEST_CASE(keva_mempool) @@ -869,7 +869,7 @@ BOOST_AUTO_TEST_CASE(keva_mempool)
const CKevaScript nameOp(upd1);
CKevaData data;
data.fromScript(100, COutPoint (uint256(), 0), nameOp);
view.SetName(nameUpd, data, false);
view.SetKeyValue(nameUpd, data, false);
mempool.checkNames(&view);
#endif

6
src/validation.cpp

@ -690,17 +690,17 @@ static bool AcceptToMemoryPoolWorker(const CChainParams& chainparams, CTxMemPool @@ -690,17 +690,17 @@ static bool AcceptToMemoryPoolWorker(const CChainParams& chainparams, CTxMemPool
CKevaData data;
// Make sure namespace info is in cache.
if (view.GetNamespace(nameSpace, data)) {
view.SetName(nameSpace, ValtypeFromString(CKevaScript::KEVA_DISPLAY_NAME_KEY), data, false);
view.SetKeyValue(nameSpace, ValtypeFromString(CKevaScript::KEVA_DISPLAY_NAME_KEY), data, false);
}
if (view.GetName(nameSpace, key, data)) {
view.SetName(nameSpace, key, data, false);
view.SetKeyValue(nameSpace, key, data, false);
}
} else if (kevaOp.isNamespaceRegistration()) {
const valtype& nameSpace = kevaOp.getOpNamespace();
const valtype& key = ValtypeFromString(CKevaScript::KEVA_DISPLAY_NAME_KEY);
CKevaData data;
if (view.GetName(nameSpace, key, data)) {
view.SetName(nameSpace, key, data, false);
view.SetKeyValue(nameSpace, key, data, false);
}
} else {
assert(false);

Loading…
Cancel
Save