From f0d05b77ffbd2672701f79b4d0528af27a7dc949 Mon Sep 17 00:00:00 2001 From: moneroexamples Date: Thu, 14 Jun 2018 14:51:59 +0800 Subject: [PATCH] rollback mysql changes as they work in Arch, not Ubuntu. --- src/TxSearch.cpp | 56 +++++++++++++++++++++++++++++++++++------------- 1 file changed, 41 insertions(+), 15 deletions(-) diff --git a/src/TxSearch.cpp b/src/TxSearch.cpp index d9edef5..6bad16e 100755 --- a/src/TxSearch.cpp +++ b/src/TxSearch.cpp @@ -262,7 +262,7 @@ TxSearch::search() //todo what should be done when insert_tx fails? } - vector outputs_found; + //vector outputs_found; // now add the found outputs into Outputs tables for (auto& out_info: oi_identification.identified_outputs) @@ -282,7 +282,17 @@ TxSearch::search() out_data.mixin = tx_data.mixin; out_data.timestamp = tx_data.timestamp; - outputs_found.push_back(out_data); + //outputs_found.push_back(out_data); + + // insert output into mysql's outputs table + uint64_t out_mysql_id = xmr_accounts->insert_output(out_data); + + if (out_mysql_id == 0) + { + throw TxSearchException("out_mysql_id is zero!"); + //todo what should be done when insert_tx fails? + } + { // add the outputs found into known_outputs_keys map @@ -294,14 +304,15 @@ TxSearch::search() // insert all outputs found into mysql's outputs table - uint64_t no_rows_inserted = xmr_accounts->insert_output(outputs_found); - - if (no_rows_inserted == 0) - { - //cerr << "out_mysql_id is zero!" << endl; - throw TxSearchException("no_rows_inserted is zero!"); - //todo what should be done when insert_tx fails? - } + // DOES not work in ubuntu 16.04, but works in arch. + // back to inserting one by one above +// uint64_t no_rows_inserted = xmr_accounts->insert_output(outputs_found); +// +// if (no_rows_inserted == 0) +// { +// //cerr << "out_mysql_id is zero!" << endl; +// throw TxSearchException("no_rows_inserted is zero!"); +// } } // if (!found_mine_outputs.empty()) @@ -445,15 +456,30 @@ TxSearch::search() // save all input found into database at once // but first update tx_mysql_id for these inputs + // UPDATE: remove this as it does not work in Ubuntu 18.04. + // mysql throws. But works fine in Arch. What a garbage. +// for (XmrInput& in_data: inputs_found) +// in_data.tx_id = tx_mysql_id; // set tx id now. before we made it 0 +// +// uint64_t no_rows_inserted = xmr_accounts->insert_input(inputs_found); +// +// if (no_rows_inserted == 0) +// { +// throw TxSearchException("no_rows_inserted is zero!"); +// } + + // save all input found into database for (XmrInput& in_data: inputs_found) + { in_data.tx_id = tx_mysql_id; // set tx id now. before we made it 0 - uint64_t no_rows_inserted = xmr_accounts->insert_input(inputs_found); + uint64_t in_mysql_id = xmr_accounts->insert_input(in_data); - if (no_rows_inserted == 0) - { - throw TxSearchException("no_rows_inserted is zero!"); - //todo what shoud we do when insert_input fails? + if (in_mysql_id == 0) + { + throw TxSearchException("in_mysql_id is zero!"); + //todo what shoud we do when insert_input fails? + } } } // if (!inputs_found.empty())