mysqlpp transaction added to TxSearch.cpp

pull/30/head
moneroexamples 7 years ago
parent 22072504da
commit 9ead4db8d8

@ -42,6 +42,14 @@ macro(create_git_version)
OUTPUT_STRIP_TRAILING_WHITESPACE
)
# Get current branch name
execute_process(
COMMAND git rev-parse --abbrev-ref HEAD
WORKING_DIRECTORY ${CMAKE_SOURCE_DIR}
OUTPUT_VARIABLE GIT_BRANCH_NAME
OUTPUT_STRIP_TRAILING_WHITESPACE
)
configure_file(
${CMAKE_SOURCE_DIR}/src/version.h.in
${CMAKE_BINARY_DIR}/gen/version.h

@ -1,6 +1,6 @@
var config = {
apiUrl: "http://127.0.0.1:1984/",
testnet: false,
testnet: true,
coinUnitPlaces: 12,
txMinConfirms: 10, // corresponds to CRYPTONOTE_DEFAULT_TX_SPENDABLE_AGE in Monero
txCoinbaseMinConfirms: 60, // corresponds to CRYPTONOTE_MINED_MONEY_UNLOCK_WINDOW in Monero

@ -63,7 +63,7 @@ thinwalletCtrls.controller("ImportWalletCtrl", function($scope, $location, $http
console.log(data);
if (data.new_request === false) {
if (data.new_request === true) {
$scope.success = "Payment received. Import will start shortly. This window will close in few seconds.";
}
else {

@ -9,10 +9,11 @@ thinwalletCtrls.controller('VersionCtrl', function ($scope, $http, ApiCalls) {
var last_git_commit_date = response.data.last_git_commit_date;
var last_git_commit_hash = response.data.last_git_commit_hash;
var git_branch_name = response.data.git_branch_name;
var monero_version_full = response.data.monero_version_full;
$scope.version = "Open Monero version: "
+ last_git_commit_date + "-" + last_git_commit_hash
+ git_branch_name + "-" + last_git_commit_date + "-" + last_git_commit_hash
+ " | Monero version: " + monero_version_full
+ " | Blockchain height: " + response.data.blockchain_height

@ -1106,6 +1106,12 @@ MySqlAccounts::launch_mysql_pinging_thread()
ping_thread.detach();
}
shared_ptr<MySqlConnector>
MySqlAccounts::get_connection()
{
return conn;
}
}

@ -252,6 +252,9 @@ public:
void
launch_mysql_pinging_thread();
shared_ptr<MySqlConnector>
get_connection();
};

@ -63,6 +63,12 @@ MySqlConnector::query(const std::string &qstr)
return conn.query(qstr);
}
Connection&
MySqlConnector::get_connection()
{
return conn;
}
MySqlConnector::~MySqlConnector()
{
conn.disconnect();

@ -60,6 +60,9 @@ public:
bool
ping();
Connection&
get_connection();
virtual ~MySqlConnector();
};

@ -182,6 +182,8 @@ TxSearch::search()
uint64_t tx_mysql_id {0};
// start mysql transaction
mysqlpp::Transaction trans(xmr_accounts->get_connection()->get_connection());
// if we identified some outputs as ours,
// save them into mysql.
@ -191,26 +193,33 @@ TxSearch::search()
// check if it already exists. So that we dont
// do it twice.
XmrTransaction tx_data;
XmrTransaction tx_data_existing;
if (xmr_accounts->tx_exists(acc->id,
oi_identification.tx_hash_str,
tx_data))
tx_data_existing))
{
cout << "\nTransaction " << oi_identification.tx_hash_str
<< " already present in mysql"
<< endl;
// if tx is already present for that user,
// just move to next txs. This can happen we we
// rescan user's transactions.
// we remove it, as we get it data from scrach
continue;
if (xmr_accounts->delete_tx(tx_data_existing.id) == 0)
{
string msg = fmt::format("xmr_accounts->delete_tx(%d)",
tx_data_existing.id);
cerr << msg << endl;
throw TxSearchException(msg);
}
}
XmrTransaction tx_data;
tx_data.hash = oi_identification.tx_hash_str;
tx_data.prefix_hash = oi_identification.tx_prefix_hash_str;
tx_data.tx_pub_key = oi_identification.tx_pub_key_str;
tx_data.tx_pub_key = oi_identification.tx_pub_key_str;
tx_data.account_id = acc->id;
tx_data.blockchain_tx_id = blockchain_tx_id;
tx_data.total_received = oi_identification.total_received;
@ -310,7 +319,7 @@ TxSearch::search()
if (xmr_accounts->output_exists(in_info.out_pub_key, out))
{
cout << "input uses some mixins which are our outputs"
<< out << endl;
<< out << '\n';
// seems that this key image is ours.
// so get it infromatoin from database into XmrInput
@ -398,6 +407,12 @@ TxSearch::search()
} // if (!oi_identification.identified_inputs.empty())
// if we get to this point, we assume that all tx related tables are ready
// to be written, i.e., Transactions, Outputs and Inputs. If so, write
// all this into database.
trans.commit();
} // for (const transaction& tx: blk_txs)

@ -979,7 +979,7 @@ YourMoneroRequests::get_version(const shared_ptr< Session > session, const Bytes
json j_response {
{"last_git_commit_hash", string {GIT_COMMIT_HASH}},
{"last_git_commit_date", string {GIT_COMMIT_DATETIME}},
{"monero_version_full" , string {MONERO_VERSION_FULL}},
{"git_branch_name" , string {GIT_BRANCH_NAME}},
{"monero_version_full" , string {MONERO_VERSION_FULL}},
{"blockchain_height" , get_current_blockchain_height()}
};

@ -8,6 +8,7 @@
#define GIT_BRANCH "@GIT_BRANCH@"
#define GIT_COMMIT_HASH "@GIT_COMMIT_HASH@"
#define GIT_COMMIT_DATETIME "@GIT_COMMIT_DATETIME@"
#define GIT_BRANCH_NAME "@GIT_BRANCH_NAME@"
#endif //XMRBLOCKS_VERSION_H_IN_H

Loading…
Cancel
Save