Merge pull request #170 from moneroexamples/fix_txpool

Fix txpool
master
moneroexamples 4 years ago committed by GitHub
commit 2a85caea04
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

@ -1,4 +1,4 @@
# Generated by YCM Generator at 2019-02-04 16:43:28.957650 # Generated by YCM Generator at 2019-11-20 22:37:52.132783
# This file is NOT licensed under the GPLv3, which is the license for the rest # This file is NOT licensed under the GPLv3, which is the license for the rest
# of YouCompleteMe. # of YouCompleteMe.
@ -36,28 +36,27 @@ import ycm_core
flags = [ flags = [
'-x', '-x',
'c++', 'c++',
'-DASIO_STANDALONE=YES', '-DBOOST_ALL_NO_LIB',
'-DBUILD_SSL=TRUE', '-DBOOST_CHRONO_DYN_LINK',
'-I/home/mwo2/monero/build', '-DBOOST_DATE_TIME_DYN_LINK',
'-I/home/mwo2/monero/contrib/epee/include', '-DBOOST_FILESYSTEM_DYN_LINK',
'-I/home/mwo2/monero/external', '-DBOOST_PROGRAM_OPTIONS_DYN_LINK',
'-I/home/mwo2/monero/external/db_drivers/liblmdb', '-DBOOST_REGEX_DYN_LINK',
'-I/home/mwo2/monero/external/easylogging++', '-DBOOST_SERIALIZATION_DYN_LINK',
'-I/home/mwo2/monero/src', '-DBOOST_SYSTEM_DYN_LINK',
'-I/home/mwo2/openmonero/ext/restbed/source', '-DBOOST_THREAD_DYN_LINK',
'-I/home/mwo2/openmonero/src/xmregcore', '-I/home/mwo2/openmonero/src/xmregcore',
'-I/tmp/tmpaV0i5C/distribution/include',
'-I/tmp/tmpaV0i5C/gen',
'-I/usr/include/mysql', '-I/usr/include/mysql',
'-I/usr/local/include', '-I/usr/include/mysql++',
'-I/usr/local/include/mysql',
'-I/usr/local/opt/openssl/include',
'-Wall',
'-Weffc++',
'-Wextra',
'-Wno-unknown-pragmas',
'-std=c++14',
'-std=gnu++14', '-std=gnu++14',
'-isystem', '/home/mwo2/openmonero/ext/restbed/dependency/asio/asio/include', '-isystem', '/home/mwo2/monero/build',
'-isystem', '/home/mwo2/openmonero/ext/restbed/dependency/kashmir', '-isystem', '/home/mwo2/monero/contrib/epee/include',
'-isystem', '/home/mwo2/monero/external',
'-isystem', '/home/mwo2/monero/external/db_drivers/liblmdb',
'-isystem', '/home/mwo2/monero/external/easylogging++',
'-isystem', '/home/mwo2/monero/src',
] ]
@ -157,3 +156,11 @@ def FlagsForFile( filename, **kwargs ):
'do_cache': True 'do_cache': True
} }
def Settings( **kwargs ):
language = kwargs[ 'language' ]
if language == 'cfamily':
return {
'flags': flags
}
return {}

@ -29,8 +29,8 @@ to MyMonero. They include:
## Live stagenet version ## Live stagenet version
- [http://139.162.60.17:81](http://139.162.60.17:81) - [http://139.162.60.17:81](http://139.162.60.17:81) - down for now.
- [http://139.162.60.17:8100](http://139.162.60.17:8100) - MyMonero frontend - [http://139.162.60.17:8100](http://139.162.60.17:8100) - MyMonero frontend - down for now.
This is OpenMonero running on stagnet network. You can use it to play around with it. This is OpenMonero running on stagnet network. You can use it to play around with it.
Please note that the live version is running on cheap VPS, which may result in Please note that the live version is running on cheap VPS, which may result in

@ -1,5 +1,4 @@
var config = { var config = {
//apiUrl: "http://0.0.0.0:1984/",
apiUrl: "http://127.0.0.1:1984/", apiUrl: "http://127.0.0.1:1984/",
mainnetExplorerUrl: "https://xmrchain.com/", mainnetExplorerUrl: "https://xmrchain.com/",
testnetExplorerUrl: "https://testnet.xmrchain.com/", testnetExplorerUrl: "https://testnet.xmrchain.com/",

@ -16,7 +16,6 @@ import monero
# openmonero backend url # openmonero backend url
om_url = "http://127.0.0.1:1984/" om_url = "http://127.0.0.1:1984/"
#om_url = "http://139.162.60.17:1984/"
async def make_request(url, payload=""): async def make_request(url, payload=""):

@ -46,7 +46,8 @@ CurrentBlockchainStatus::monitor_blockchain()
break; break;
} }
OMVLOG1 << "PoolQueue size: " //OMVLOG1 << "PoolQueue size: "
OMINFO << "PoolQueue size: "
<< TP::DefaultThreadPool::queueSize(); << TP::DefaultThreadPool::queueSize();
update_current_blockchain_height(); update_current_blockchain_height();
@ -589,62 +590,51 @@ bool
CurrentBlockchainStatus::read_mempool() CurrentBlockchainStatus::read_mempool()
{ {
// get txs in the mempool // get txs in the mempool
std::vector<tx_info> mempool_tx_info;
vector<spent_key_image_info> key_image_infos; mempool_txs_t local_mempool_txs;
auto future_result = thread_pool->submit( auto future_result = thread_pool->submit(
[this](auto& mempool_tx_info, auto& key_image_infos) [this](auto& local_mempool_txs)
-> bool -> bool
{ {
if (!this->mcore->get_mempool_txs(
mempool_tx_info, key_image_infos)) std::vector<transaction> txs;
if (!this->mcore->get_mempool_txs(txs))
{ {
OMERROR << "Getting mempool failed "; OMERROR << "Getting mempool failed ";
return false; return false;
} }
return true;
}, std::ref(mempool_tx_info),
std::ref(key_image_infos));
if (!future_result.get()) for (size_t i = 0; i < txs.size(); ++i)
return false; {
// get transaction info of the tx in the mempool
auto const& tx = txs.at(i);
// not using this info at present tx_memory_pool::tx_details txd;
(void) key_image_infos;
std::lock_guard<std::mutex> lck (getting_mempool_txs); txpool_tx_meta_t meta;
// clear current mempool txs vector if (!this->mcore->get_core().get_txpool_tx_meta(tx.hash, meta))
// repopulate it with each execution of read_mempool() {
// not very efficient but good enough for now. OMERROR << "Failed to find tx in txpool";
mempool_txs.clear(); return false;
}
// if dont have tx_blob member, construct tx local_mempool_txs.emplace_back(meta.receive_time, tx);
// from json obtained from the rpc call
for (size_t i = 0; i < mempool_tx_info.size(); ++i) } // for (size_t i = 0; i < mempool_tx_info.size(); ++i)
{
// get transaction info of the tx in the mempool
tx_info const& _tx_info = mempool_tx_info.at(i);
transaction tx; return true;
crypto::hash tx_hash;
crypto::hash tx_prefix_hash;
if (!parse_and_validate_tx_from_blob( }, std::ref(local_mempool_txs));
_tx_info.tx_blob, tx, tx_hash, tx_prefix_hash))
{
OMERROR << "Cant make tx from _tx_info.tx_blob";
return false;
}
(void) tx_hash; if (!future_result.get())
(void) tx_prefix_hash; return false;
mempool_txs.emplace_back(_tx_info.receive_time, tx); std::lock_guard<std::mutex> lck (getting_mempool_txs);
} // for (size_t i = 0; i < mempool_tx_info.size(); ++i) mempool_txs = std::move(local_mempool_txs);
return true; return true;
} }

@ -1710,9 +1710,19 @@ OpenMoneroRequests::get_tx(
if (current_bc_status->get_xmr_address_viewkey( if (current_bc_status->get_xmr_address_viewkey(
xmr_address, address_info, viewkey)) xmr_address, address_info, viewkey))
{ {
auto coreacc = make_account(xmr_address, view_key);
if (!coreacc)
{
// if creation failed, just close the session
session_close(session, j_response, UNPROCESSABLE_ENTITY,
"Cant create coreacc for " + xmr_address);
return;
}
auto identifier = make_identifier(tx, auto identifier = make_identifier(
make_unique<Output>(&address_info, &viewkey)); tx,
make_unique<Output>(coreacc.get()));
identifier.identify(); identifier.identify();
@ -1739,6 +1749,7 @@ OpenMoneroRequests::get_tx(
// a placeholder for exciting or new account data // a placeholder for exciting or new account data
XmrAccount acc; XmrAccount acc;
// select this account if its existing one // select this account if its existing one
if (xmr_accounts->select(xmr_address, acc)) if (xmr_accounts->select(xmr_address, acc))
{ {
@ -1819,7 +1830,7 @@ OpenMoneroRequests::get_tx(
// and inputs in a given tx. // and inputs in a given tx.
auto identifier = make_identifier(tx, auto identifier = make_identifier(tx,
make_unique<Input>(&address_info, &viewkey, make_unique<Input>(coreacc.get(),
&known_outputs_keys, &known_outputs_keys,
&mcore_addapter)); &mcore_addapter));
identifier.identify(); identifier.identify();
@ -2159,7 +2170,8 @@ OpenMoneroRequests::create_account(
// in a moment we will try to get last block timestamp // in a moment we will try to get last block timestamp
// to replace this value. But if it fails, we just use current // to replace this value. But if it fails, we just use current
// timestamp // timestamp
uint64_t current_blockchain_timestamp = std::time(nullptr); uint64_t current_blockchain_timestamp
= std::time(nullptr);
// get last block so we have its timestamp when // get last block so we have its timestamp when
// createing the account // createing the account
@ -2167,14 +2179,14 @@ OpenMoneroRequests::create_account(
if (current_bc_status->get_block(current_blockchain_height, last_blk)) if (current_bc_status->get_block(current_blockchain_height, last_blk))
{ {
current_blockchain_timestamp = last_blk.timestamp; if (last_blk.timestamp != 0)
current_blockchain_timestamp = last_blk.timestamp;
} }
DateTime blk_timestamp_mysql_format DateTime blk_timestamp_mysql_format
= XmrTransaction::timestamp_to_DateTime( = XmrTransaction::timestamp_to_DateTime(
current_blockchain_timestamp); current_blockchain_timestamp);
//@todo setting up start_height and scanned_block_height //@todo setting up start_height and scanned_block_height
//needs to be revisited as they are needed for importing //needs to be revisited as they are needed for importing
//wallets. The simples way is when import is free and this //wallets. The simples way is when import is free and this

@ -393,9 +393,12 @@ for (auto const& tx_tuple: txs_data)
{ {
OMERROR << address_prefix OMERROR << address_prefix
<< ": insert outputs_found: no_rows_inserted is zero!" << ": insert outputs_found: no_rows_inserted is zero!"
<< outputs_found; << " in tx " << tx_hash_str << " in blk " << blk_height
<< ' ' << outputs_found;
throw TxSearchException("insert output_found: no_rows_inserted is zero!"); continue;
//throw TxSearchException("insert output_found: "
// "no_rows_inserted is zero!");
} }
} // if (!found_mine_outputs.empty()) } // if (!found_mine_outputs.empty())
@ -581,10 +584,12 @@ for (auto const& tx_tuple: txs_data)
{ {
OMERROR << address_prefix OMERROR << address_prefix
<< ": insert inputs_found: no_rows_inserted is zero!" << ": insert inputs_found: no_rows_inserted is zero!"
<< inputs_found; << " in tx " << tx_hash_str << " in blk " << blk_height
<< ' ' << inputs_found;
throw TxSearchException( continue;
"insert inputs_found: no_rows_inserted is zero!"); //throw TxSearchException(
//"insert inputs_found: no_rows_inserted is zero!");
} }
} // if (!inputs_found.empty()) } // if (!inputs_found.empty())

@ -7,10 +7,15 @@
#define OMWARN CLOG(WARNING, OPENMONERO_LOG_CATEGORY) #define OMWARN CLOG(WARNING, OPENMONERO_LOG_CATEGORY)
#define OMERROR CLOG(ERROR, OPENMONERO_LOG_CATEGORY) #define OMERROR CLOG(ERROR, OPENMONERO_LOG_CATEGORY)
#define OMVLOG1 CVLOG(1, OPENMONERO_LOG_CATEGORY) //#define OMVLOG1 CVLOG(1, OPENMONERO_LOG_CATEGORY)
#define OMVLOG2 CVLOG(2, OPENMONERO_LOG_CATEGORY) //#define OMVLOG2 CVLOG(2, OPENMONERO_LOG_CATEGORY)
#define OMVLOG3 CVLOG(3, OPENMONERO_LOG_CATEGORY) //#define OMVLOG3 CVLOG(3, OPENMONERO_LOG_CATEGORY)
#define OMVLOG4 CVLOG(4, OPENMONERO_LOG_CATEGORY) //#define OMVLOG4 CVLOG(4, OPENMONERO_LOG_CATEGORY)
#define OMVLOG1 CLOG(INFO, OPENMONERO_LOG_CATEGORY)
#define OMVLOG2 CLOG(INFO, OPENMONERO_LOG_CATEGORY)
#define OMVLOG3 CLOG(INFO, OPENMONERO_LOG_CATEGORY)
#define OMVLOG4 CLOG(INFO, OPENMONERO_LOG_CATEGORY)
#define OMINFO_IF(cond) CLOG_IF(cond, INFO, OPENMONERO_LOG_CATEGORY) #define OMINFO_IF(cond) CLOG_IF(cond, INFO, OPENMONERO_LOG_CATEGORY)
#define OMWARN_IF(cond) CLOG_IF(cond, WARNING, OPENMONERO_LOG_CATEGORY) #define OMWARN_IF(cond) CLOG_IF(cond, WARNING, OPENMONERO_LOG_CATEGORY)

@ -1240,7 +1240,7 @@ blocks_and_txs_from_complete_blocks(
{ {
transaction tx; transaction tx;
if (!parse_and_validate_tx_from_blob(tx_blob, tx)) if (!parse_and_validate_tx_from_blob(tx_blob.blob, tx))
return false; return false;
txs.push_back(tx); txs.push_back(tx);

@ -1 +1 @@
Subproject commit 4356c9892b9903da4410f773ea36a6e4c799be5a Subproject commit 6e0c9e4b9fa1d2ce1182e61290ff5190608c8b6a
Loading…
Cancel
Save