total_received removed from Accounts table

pull/5/head
moneroexamples 7 years ago
parent 83e7989a99
commit 5b99b52277

@ -3,7 +3,7 @@
-- https://www.phpmyadmin.net/
--
-- Host: localhost
-- Generation Time: Feb 16, 2017 at 05:55 AM
-- Generation Time: Feb 21, 2017 at 02:37 AM
-- Server version: 10.1.21-MariaDB
-- PHP Version: 7.1.2
@ -32,7 +32,6 @@ DROP TABLE IF EXISTS `Accounts`;
CREATE TABLE `Accounts` (
`id` bigint(10) UNSIGNED NOT NULL,
`address` varchar(95) NOT NULL,
`total_received` bigint(20) UNSIGNED NOT NULL DEFAULT '0',
`scanned_block_height` int(10) UNSIGNED NOT NULL DEFAULT '0',
`start_height` int(10) UNSIGNED NOT NULL DEFAULT '0',
`created` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP,
@ -175,17 +174,17 @@ ALTER TABLE `Transactions`
-- AUTO_INCREMENT for table `Accounts`
--
ALTER TABLE `Accounts`
MODIFY `id` bigint(10) UNSIGNED NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=2;
MODIFY `id` bigint(10) UNSIGNED NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=9;
--
-- AUTO_INCREMENT for table `Inputs`
--
ALTER TABLE `Inputs`
MODIFY `id` bigint(20) UNSIGNED NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=210;
MODIFY `id` bigint(20) UNSIGNED NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=449;
--
-- AUTO_INCREMENT for table `Outputs`
--
ALTER TABLE `Outputs`
MODIFY `id` bigint(20) UNSIGNED NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=297;
MODIFY `id` bigint(20) UNSIGNED NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=11206;
--
-- AUTO_INCREMENT for table `Payments`
--
@ -195,7 +194,7 @@ ALTER TABLE `Payments`
-- AUTO_INCREMENT for table `Transactions`
--
ALTER TABLE `Transactions`
MODIFY `id` bigint(20) UNSIGNED NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=389;
MODIFY `id` bigint(20) UNSIGNED NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=3145;
--
-- Constraints for dumped tables
--

@ -48,11 +48,9 @@ public:
bool
select_for_tx(const uint64_t& address_id, vector<XmrInput>& ins);
bool
select_for_out(const uint64_t& output_id, vector<XmrInput>& ins);
uint64_t
insert(const XmrInput& in_data);

@ -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;
}
@ -530,9 +507,9 @@ TxSearch::find_txs_in_mempool(
j_tx["unlock_time"] = 0; // for mempool we set it to zero
// since we dont have block_height to work with
j_tx["height"] = current_height; // put current blockchain height,
// just to indicate to frontend that this
// tx is younger than 10 blocks so that
// it shows unconfirmed message.
// just to indicate to frontend that this
// tx is younger than 10 blocks so that
// it shows unconfirmed message.
j_tx["payment_id"] = CurrentBlockchainStatus::get_payment_id_as_string(tx);
j_tx["coinbase"] = false; // mempool tx are not coinbase, so always false
j_tx["is_rct"] = oi_identification.is_rct;
@ -613,12 +590,12 @@ TxSearch::find_txs_in_mempool(
json j_tx;
j_tx["id"] = 0; // dont have any database id for tx in mempool
// this id is used for sorting txs in the frontend.
j_tx["id"] = 0; // dont have any database id for tx in mempool
// this id is used for sorting txs in the frontend.
j_tx["hash"] = oi_identification.tx_hash_str;
j_tx["timestamp"] = timestamp_to_str(recieve_time); // when it got into mempool
j_tx["total_received"] = 0; // we did not recive any outputs/xmr
j_tx["total_received"] = 0; // we did not recive any outputs/xmr
j_tx["total_sent"] = total_sent; // to be set later when looking for key images
j_tx["unlock_time"] = 0; // for mempool we set it to zero
// since we dont have block_height to work with
@ -627,7 +604,7 @@ TxSearch::find_txs_in_mempool(
// tx is younger than 10 blocks so that
// it shows unconfirmed message.
j_tx["payment_id"] = CurrentBlockchainStatus::get_payment_id_as_string(tx);
j_tx["coinbase"] = false; // mempool tx are not coinbase, so always false
j_tx["coinbase"] = false; // mempool tx are not coinbase, so always false
j_tx["is_rct"] = oi_identification.is_rct;
j_tx["rct_type"] = oi_identification.rct_type;
j_tx["mixin"] = get_mixin_no(tx) - 1;
@ -649,9 +626,7 @@ TxSearch::find_txs_in_mempool(
}
pair<account_public_address, secret_key>
pair<account_public_address, secret_key>
TxSearch::get_xmr_address_viewkey() const
{
return make_pair(address, viewkey);

@ -17,7 +17,6 @@ XmrAccount::to_json() const
json j {{"id" , id},
{"address" , address},
{"viewkey" , viewkey},
{"total_received" , total_received},
{"scanned_block_height", scanned_block_height},
{"start_height" , start_height}
};

@ -18,10 +18,9 @@ using namespace std;
using namespace nlohmann;
using namespace mysqlpp;
sql_create_7(Accounts, 1, 2,
sql_create_6(Accounts, 1, 2,
sql_bigint_unsigned, id,
sql_varchar , address,
sql_bigint_unsigned, total_received,
sql_bigint_unsigned, scanned_block_height,
sql_bigint_unsigned, start_height,
sql_timestamp , created,

Loading…
Cancel
Save