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

Function GetDataTableWriteOutput

src/vm/luavm/lmylib.cpp:1513–1567  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1511
1512
1513static bool GetDataTableWriteOutput(lua_State *L, CVmOperate &operate) {
1514 if (!lua_istable(L,-1)) {
1515 LogPrint(BCLog::LUAVM,"WriteOutput(), param 1 must be table\n");
1516 return false;
1517 }
1518
1519 double doubleValue = 0;
1520 uint16_t len = 0;
1521 vector<uint8_t> vBuf;
1522 if (!(getNumberInTable(L,(char *)"addrType",doubleValue))) {
1523 LogPrint(BCLog::LUAVM, "WriteOutput(), get addrType failed\n");
1524 return false;
1525 } else {
1526 operate.accountType = (AccountType)doubleValue;
1527 }
1528
1529 if (operate.accountType == AccountType::REGID) {
1530 len = 6;
1531 } else if (operate.accountType == AccountType::BASE58ADDR){
1532 len = 34;
1533 } else {
1534 LogPrint(BCLog::LUAVM, "WriteOutput(), invalid accountType: %d\n", operate.accountType);
1535 return false;
1536 }
1537
1538 if (!getArrayInTable(L, "accountIdTbl", len, vBuf)) {
1539 LogPrint(BCLog::LUAVM,"WriteOutput(), get accountIdTbl failed\n");
1540 return false;
1541 } else {
1542 memcpy(operate.accountId,&vBuf[0],len);
1543 }
1544
1545 if (!(getNumberInTable(L, "operatorType", doubleValue))) {
1546 LogPrint(BCLog::LUAVM, "WriteOutput(), get opType failed\n");
1547 return false;
1548
1549 } else {
1550 operate.opType = (BalanceOpType) doubleValue;
1551 }
1552
1553 if (!(getNumberInTable(L, "outHeight", doubleValue))) {
1554 LogPrint(BCLog::LUAVM, "WriteOutput(), get outheight failed\n");
1555 return false;
1556 } else {
1557 operate.timeoutHeight = (uint32_t)doubleValue;
1558 }
1559
1560 if (!getArrayInTable(L, "moneyTbl", sizeof(operate.money), vBuf)) {
1561 LogPrint(BCLog::LUAVM,"WriteOutput(), moneyTbl not table\n");
1562 return false;
1563 } else {
1564 memcpy(operate.money, &vBuf[0], sizeof(operate.money));
1565 }
1566 return true;
1567}
1568
1569/**
1570 * contract api - lua function

Callers 1

ExWriteOutputFuncFunction · 0.85

Calls 3

getNumberInTableFunction · 0.85
getArrayInTableFunction · 0.85
memcpyFunction · 0.85

Tested by

no test coverage detected