MCPcopy Create free account
hub / github.com/FISCO-BCOS/FISCO-BCOS / getCode

Method getCode

bcos-executor/src/executor/TransactionExecutor.cpp:1994–2123  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1992}
1993
1994void TransactionExecutor::getCode(
1995 std::string_view contract, std::function<void(bcos::Error::Ptr, bcos::bytes)> callback)
1996{
1997 EXECUTOR_NAME_LOG(INFO) << "Get code request" << LOG_KV("Contract", contract);
1998
1999 if (!m_isRunning)
2000 {
2001 EXECUTOR_NAME_LOG(ERROR) << "TransactionExecutor is not running";
2002 callback(
2003 BCOS_ERROR_UNIQUE_PTR(ExecuteError::STOPPED, "TransactionExecutor is not running"), {});
2004 return;
2005 }
2006
2007 storage::StateStorageInterface::Ptr stateStorage;
2008
2009 {
2010 std::unique_lock<std::shared_mutex> lock(m_stateStoragesMutex);
2011 if (!m_stateStorages.empty())
2012 {
2013 stateStorage = createStateStorage(m_stateStorages.back().storage, true, false);
2014 }
2015 }
2016 // create temp state storage
2017 if (!stateStorage)
2018 {
2019 if (m_cachedStorage)
2020 {
2021 stateStorage = createStateStorage(m_cachedStorage, true, false);
2022 }
2023 else
2024 {
2025 stateStorage = createStateStorage(m_backendStorage, true, false);
2026 }
2027 }
2028
2029 std::string contractTableName = getContractTableName(executor::USER_APPS_PREFIX, contract);
2030
2031 auto getCodeFromContractTable = [stateStorage, this](std::string_view contractTableName,
2032 decltype(callback) _callback) {
2033 stateStorage->asyncGetRow(contractTableName, ACCOUNT_CODE,
2034 [this, callback = std::move(_callback)](
2035 Error::UniquePtr error, std::optional<Entry> entry) {
2036 if (!m_isRunning)
2037 {
2038 callback(BCOS_ERROR_UNIQUE_PTR(
2039 ExecuteError::STOPPED, "TransactionExecutor is not running"),
2040 {});
2041 return;
2042 }
2043
2044 if (error)
2045 {
2046 EXECUTOR_NAME_LOG(INFO) << "Get code failed: " << error->errorMessage();
2047
2048 callback(BCOS_ERROR_WITH_PREV_UNIQUE_PTR(-1, "Get code failed", *error), {});
2049 return;
2050 }
2051

Callers 1

BOOST_AUTO_TEST_CASEFunction · 0.45

Calls 13

getCodeHashFunction · 0.85
matchDynamicAccountCodeFunction · 0.85
errorMessageMethod · 0.80
getFieldMethod · 0.80
readFromStorageMethod · 0.80
getContractTableNameFunction · 0.50
emptyMethod · 0.45
asyncGetRowMethod · 0.45
sizeMethod · 0.45
beginMethod · 0.45
endMethod · 0.45

Tested by 1

BOOST_AUTO_TEST_CASEFunction · 0.36