MCPcopy Create free account
hub / github.com/WaykiChain/WaykiChain / ExReadDataDBFunc

Function ExReadDataDBFunc

src/vm/luavm/lmylib.cpp:1422–1453  ·  view source on GitHub ↗

*uint16_t ReadDataValueDB(const void* const key,const uint8_t keylen, void* const value,uint16_t const maxbuffer) * 这个函数式从中间层传了一个参数过来: * 1.第一个是 key值 */

Source from the content-addressed store, hash-verified

1420 * 1.第一个是 key值
1421 */
1422int32_t ExReadDataDBFunc(lua_State *L) {
1423 vector<std::shared_ptr < vector<uint8_t> > > retdata;
1424
1425 if (!GetDataString(L,retdata) ||retdata.size() != 1) {
1426 return RetFalse("ExReadDataDBFunc key err1");
1427 }
1428
1429 string key((*retdata.at(0)).begin(), (*retdata.at(0)).end());
1430
1431 CLuaVMRunEnv* pVmRunEnv = GetVmRunEnv(L);
1432 if (nullptr == pVmRunEnv) {
1433 return RetFalse("pVmRunEnv is nullptr");
1434 }
1435
1436 CRegID scriptRegId = pVmRunEnv->GetContractRegID();
1437
1438 string value;
1439 CContractDBCache* scriptDB = pVmRunEnv->GetScriptDB();
1440 int32_t len = 0;
1441 if (!scriptDB->GetContractData(scriptRegId, key, value)) {
1442 len = 0;
1443 lua_BurnStoreUnchanged(L, key.size(), 0, BURN_VER_R2);
1444 } else {
1445 lua_BurnStoreGet(L, key.size(), value.size(), BURN_VER_R2);
1446 len = RetRstToLua(L, vector<uint8_t>(value.begin(), value.end()));
1447 }
1448 #ifdef TRACE_LUAVM_CONTRACT_DATA
1449 LogPrint(BCLog::LUAVM, "ReadData(), contract_regid=%s, key=%s, key_hex=%s, value=%s, value_hex=%s\n",
1450 scriptRegId.ToString(), key, HexStr(key), value, HexStr(value));
1451 #endif//TRACE_LUAVM_CONTRACT_DATA
1452 return len;
1453}
1454
1455int32_t ExGetCurTxHash(lua_State *L) {
1456

Callers

nothing calls this directly

Calls 14

GetDataStringFunction · 0.85
RetFalseFunction · 0.85
GetVmRunEnvFunction · 0.85
lua_BurnStoreUnchangedFunction · 0.85
lua_BurnStoreGetFunction · 0.85
RetRstToLuaFunction · 0.85
HexStrFunction · 0.85
atMethod · 0.80
GetScriptDBMethod · 0.80
sizeMethod · 0.45
beginMethod · 0.45
endMethod · 0.45

Tested by

no test coverage detected