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

Function ExByteToIntegerFunc

src/vm/luavm/lmylib.cpp:1030–1065  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1028}
1029
1030int32_t ExByteToIntegerFunc(lua_State *L) {
1031 //把字节流组合成integer
1032 vector<std::shared_ptr<vector<uint8_t>>> retdata;
1033 if (!GetArray(L, retdata) || retdata.size() != 1 ||
1034 ((retdata.at(0).get()->size() != 4) && (retdata.at(0).get()->size() != 8))) {
1035 return RetFalse("ExByteToIntegerFunc para err1");
1036 }
1037
1038 //将数据反向
1039 vector<uint8_t> vValue(retdata.at(0).get()->begin(), retdata.at(0).get()->end());
1040 CDataStream tep1(vValue, SER_DISK, CLIENT_VERSION);
1041
1042 LUA_BurnFuncCall(L, FUEL_CALL_ByteToInteger, BURN_VER_R2);
1043 if (retdata.at(0).get()->size() == 4) {
1044 uint32_t height;
1045 tep1 >> height;
1046
1047 // LogPrint(BCLog::LUAVM, "%d\n", height);
1048 if (lua_checkstack(L, sizeof(lua_Integer))) {
1049 lua_pushinteger(L, (lua_Integer)height);
1050 return 1;
1051 } else {
1052 return RetFalse("ExByteToIntegerFunc stack overflow");
1053 }
1054 } else {
1055 int64_t llValue = 0;
1056 tep1 >> llValue;
1057 // LogPrint(BCLog::LUAVM, "%lld\n", llValue);
1058 if (lua_checkstack(L, sizeof(lua_Integer))) {
1059 lua_pushinteger(L, (lua_Integer)llValue);
1060 return 1;
1061 } else {
1062 return RetFalse("ExByteToIntegerFunc stack overflow");
1063 }
1064 }
1065}
1066
1067int32_t ExIntegerToByte4Func(lua_State *L) {
1068 //把integer转换成4字节数组

Callers

nothing calls this directly

Calls 9

GetArrayFunction · 0.85
RetFalseFunction · 0.85
lua_checkstackFunction · 0.85
lua_pushintegerFunction · 0.85
atMethod · 0.80
sizeMethod · 0.45
getMethod · 0.45
beginMethod · 0.45
endMethod · 0.45

Tested by

no test coverage detected