MCPcopy Create free account
hub / github.com/Achain-Dev/Achain / open_contract

Method open_contract

src/Chain/libraries/glua/thinkyoung_lua_api.cpp:239–260  ·  view source on GitHub ↗

* load contract lua byte stream from thinkyoung api */

Source from the content-addressed store, hash-verified

237 * load contract lua byte stream from thinkyoung api
238 */
239 std::shared_ptr<GluaModuleByteStream> GluaChainApi::open_contract(lua_State *L, const char *name)
240 {
241 // FXIME
242 thinkyoung::lua::lib::increment_lvm_instructions_executed_count(L, CHAIN_GLUA_API_EACH_INSTRUCTIONS_COUNT - 1);
243
244 thinkyoung::blockchain::TransactionEvaluationState* eval_state_ptr =
245 (thinkyoung::blockchain::TransactionEvaluationState*)
246 (thinkyoung::lua::lib::get_lua_state_value(L, "evaluate_state").pointer_value);
247
248 if (!eval_state_ptr)
249 return NULL;
250
251 thinkyoung::blockchain::ChainInterface* cur_state = eval_state_ptr->_current_state;
252
253 oContractEntry entry = cur_state->get_contract_entry(std::string(name));
254 if (entry.valid() && (entry->code.byte_code.size() <= LUA_MODULE_BYTE_STREAM_BUF_SIZE))
255 {
256 return get_bytestream_from_code(L, entry->code);
257 }
258
259 return NULL;
260 }
261
262 std::shared_ptr<GluaModuleByteStream> GluaChainApi::open_contract_by_address(lua_State *L, const char *address)
263 {

Callers 1

lua_common_open_contractFunction · 0.45

Calls 5

get_lua_state_valueFunction · 0.85
stringClass · 0.50
validMethod · 0.45
sizeMethod · 0.45

Tested by

no test coverage detected