|
|
|
@ -76,10 +76,6 @@ TxSearch::search()
|
|
|
|
|
loop_timestamp = chrono::duration_cast<chrono::seconds>(
|
|
|
|
|
chrono::system_clock::now().time_since_epoch()).count();
|
|
|
|
|
|
|
|
|
|
//cout << "loop_timestamp: " << loop_timestamp << endl;
|
|
|
|
|
//cout << "last_ping_timestamp: " << last_ping_timestamp << endl;
|
|
|
|
|
//cout << "loop_timestamp - last_ping_timestamp: " << (loop_timestamp - last_ping_timestamp) << endl;
|
|
|
|
|
|
|
|
|
|
if (loop_timestamp - last_ping_timestamp > THREAD_LIFE_DURATION)
|
|
|
|
|
{
|
|
|
|
|
// also check if we caught up with current blockchain height
|
|
|
|
@ -92,7 +88,6 @@ TxSearch::search()
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (searched_blk_no > CurrentBlockchainStatus::current_height) {
|
|
|
|
|
fmt::print("searched_blk_no {:d} and current_height {:d}\n",
|
|
|
|
|
searched_blk_no, CurrentBlockchainStatus::current_height);
|
|
|
|
@ -105,21 +100,21 @@ TxSearch::search()
|
|
|
|
|
continue;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
//
|
|
|
|
|
//cout << " - searching tx of: " << acc << endl;
|
|
|
|
|
|
|
|
|
|
// get block cointaining this tx
|
|
|
|
|
block blk;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (!CurrentBlockchainStatus::get_block(searched_blk_no, blk))
|
|
|
|
|
{
|
|
|
|
|
cerr << "Cant get block of height: " + to_string(searched_blk_no) << endl;
|
|
|
|
|
|
|
|
|
|
// update of current_height, as maybe top block(s)
|
|
|
|
|
// update current_height of blockchain, as maybe top block(s)
|
|
|
|
|
// were dropped due to reorganization.
|
|
|
|
|
CurrentBlockchainStatus::update_current_blockchain_height();
|
|
|
|
|
|
|
|
|
|
// if any txs that we already indexed got orphaned as a consequence of this
|
|
|
|
|
// MySqlAccounts::select_txs_for_account_spendability_check should
|
|
|
|
|
// update database accordingly when get_address_txs is executed.
|
|
|
|
|
|
|
|
|
|
continue;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
@ -134,7 +129,7 @@ TxSearch::search()
|
|
|
|
|
|
|
|
|
|
if (searched_blk_no % 100 == 0)
|
|
|
|
|
{
|
|
|
|
|
// print status every 10th block
|
|
|
|
|
// print status every 100th block
|
|
|
|
|
|
|
|
|
|
fmt::print(" - searching block {:d} of hash {:s} \n",
|
|
|
|
|
searched_blk_no, pod_to_hex(get_block_hash(blk)));
|
|
|
|
@ -160,7 +155,7 @@ TxSearch::search()
|
|
|
|
|
// can filter out false positives.
|
|
|
|
|
for (transaction& tx: blk_txs)
|
|
|
|
|
{
|
|
|
|
|
// Class that is resposnible for idenficitaction of our outputs
|
|
|
|
|
// Class that is responsible for identification of our outputs
|
|
|
|
|
// and inputs in a given tx.
|
|
|
|
|
OutputInputIdentification oi_identification {&address, &viewkey, &tx};
|
|
|
|
|
|
|
|
|
@ -235,6 +230,7 @@ TxSearch::search()
|
|
|
|
|
{
|
|
|
|
|
//cerr << "tx_mysql_id is zero!" << endl;
|
|
|
|
|
//throw TxSearchException("tx_mysql_id is zero!");
|
|
|
|
|
//todo what should be done when insert_tx fails?
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// now add the found outputs into Outputs tables
|
|
|
|
@ -261,7 +257,7 @@ TxSearch::search()
|
|
|
|
|
if (out_mysql_id == 0)
|
|
|
|
|
{
|
|
|
|
|
//cerr << "out_mysql_id is zero!" << endl;
|
|
|
|
|
//throw TxSearchException("out_mysql_id is zero!");
|
|
|
|
|
//todo what should be done when insert_tx fails?
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
{
|
|
|
|
@ -272,19 +268,6 @@ TxSearch::search()
|
|
|
|
|
|
|
|
|
|
} // for (auto &out_k_idx: found_mine_outputs)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// once tx and outputs were added, update Accounts table
|
|
|
|
|
|
|
|
|
|
XmrAccount updated_acc = *acc;
|
|
|
|
|
|
|
|
|
|
updated_acc.total_received = acc->total_received + tx_data.total_received;
|
|
|
|
|
|
|
|
|
|
if (xmr_accounts->update(*acc, updated_acc))
|
|
|
|
|
{
|
|
|
|
|
// if success, set acc to updated_acc;
|
|
|
|
|
*acc = updated_acc;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
} // if (!found_mine_outputs.empty())
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@ -328,11 +311,6 @@ TxSearch::search()
|
|
|
|
|
|
|
|
|
|
inputs_found.push_back(in_data);
|
|
|
|
|
|
|
|
|
|
// a key image has only one real mixin. Rest is fake.
|
|
|
|
|
// so if we find a candidate, break the search.
|
|
|
|
|
|
|
|
|
|
// break;
|
|
|
|
|
|
|
|
|
|
} // if (xmr_accounts->output_exists(output_public_key_str, out))
|
|
|
|
|
|
|
|
|
|
} // for (auto& in_info: oi_identification.identified_inputs)
|
|
|
|
@ -384,6 +362,7 @@ TxSearch::search()
|
|
|
|
|
{
|
|
|
|
|
//cerr << "tx_mysql_id is zero!" << endl;
|
|
|
|
|
//throw TxSearchException("tx_mysql_id is zero!");
|
|
|
|
|
//todo what should be done when insert_tx fails?
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
} // if (tx_mysql_id == 0)
|
|
|
|
@ -397,10 +376,8 @@ TxSearch::search()
|
|
|
|
|
|
|
|
|
|
} // if (!inputs_found.empty())
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
} // if (!oi_identification.identified_inputs.empty())
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
} // for (const transaction& tx: blk_txs)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@ -432,7 +409,7 @@ TxSearch::search()
|
|
|
|
|
void
|
|
|
|
|
TxSearch::stop()
|
|
|
|
|
{
|
|
|
|
|
cout << "Stoping the thread by setting continue_search=false" << endl;
|
|
|
|
|
cout << "Stopping the thread by setting continue_search=false" << endl;
|
|
|
|
|
continue_search = false;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
@ -649,8 +626,6 @@ TxSearch::find_txs_in_mempool(
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
pair<account_public_address, secret_key>
|
|
|
|
|
TxSearch::get_xmr_address_viewkey() const
|
|
|
|
|
{
|
|
|
|
|