mempool_tx structure was made lighter

master
moneroexamples 8 years ago
parent 46c8d5ec1a
commit 13a9060b8b

@ -23,13 +23,6 @@ MempoolStatus::set_blockchain_variables(MicroCore *_mcore,
void void
MempoolStatus::start_mempool_status_thread() MempoolStatus::start_mempool_status_thread()
{ {
// initialize network info as not current.
// so we know that what ever values are returned, they
// dont come from the deamon now.
network_info local_copy = current_network_info;
local_copy.current = false;
local_copy.info_timestamp = 0;
current_network_info = local_copy;
if (mempool_refresh_time < 1) if (mempool_refresh_time < 1)
{ {
@ -162,7 +155,7 @@ MempoolStatus::read_mempool()
mempool_size_kB += _tx_info.blob_size; mempool_size_kB += _tx_info.blob_size;
local_copy_of_mempool_txs.push_back(mempool_tx {tx_hash_reconstructed, _tx_info, tx}); local_copy_of_mempool_txs.push_back(mempool_tx {tx_hash_reconstructed, tx});
mempool_tx& last_tx = local_copy_of_mempool_txs.back(); mempool_tx& last_tx = local_copy_of_mempool_txs.back();
@ -176,6 +169,8 @@ MempoolStatus::read_mempool()
const array<uint64_t, 4>& sum_data = summary_of_in_out_rct( const array<uint64_t, 4>& sum_data = summary_of_in_out_rct(
tx, output_pub_keys, input_key_imgs); tx, output_pub_keys, input_key_imgs);
last_tx.receive_time = _tx_info.receive_time;
last_tx.sum_outputs = sum_data[0]; last_tx.sum_outputs = sum_data[0];
last_tx.sum_inputs = sum_data[1]; last_tx.sum_inputs = sum_data[1];
last_tx.no_outputs = output_pub_keys.size(); last_tx.no_outputs = output_pub_keys.size();
@ -252,12 +247,14 @@ MempoolStatus::read_network_info()
local_copy.incoming_connections_count = rpc_network_info.incoming_connections_count; local_copy.incoming_connections_count = rpc_network_info.incoming_connections_count;
local_copy.white_peerlist_size = rpc_network_info.white_peerlist_size; local_copy.white_peerlist_size = rpc_network_info.white_peerlist_size;
local_copy.testnet = rpc_network_info.testnet; local_copy.testnet = rpc_network_info.testnet;
epee::string_tools::hex_to_pod(rpc_network_info.top_block_hash, local_copy.top_block_hash);
local_copy.cumulative_difficulty = rpc_network_info.cumulative_difficulty; local_copy.cumulative_difficulty = rpc_network_info.cumulative_difficulty;
local_copy.block_size_limit = rpc_network_info.block_size_limit; local_copy.block_size_limit = rpc_network_info.block_size_limit;
local_copy.start_time = rpc_network_info.start_time; local_copy.start_time = rpc_network_info.start_time;
epee::string_tools::hex_to_pod(rpc_network_info.top_block_hash, local_copy.top_block_hash);
local_copy.fee_per_kb = fee_estimated; local_copy.fee_per_kb = fee_estimated;
local_copy.info_timestamp = static_cast<uint64_t>(std::time(nullptr)); local_copy.info_timestamp = static_cast<uint64_t>(std::time(nullptr));
local_copy.current = true; local_copy.current = true;
current_network_info = local_copy; current_network_info = local_copy;

@ -25,9 +25,9 @@ struct MempoolStatus
struct mempool_tx struct mempool_tx
{ {
crypto::hash tx_hash; crypto::hash tx_hash;
tx_info info;
transaction tx; transaction tx;
uint64_t receive_time {0};
uint64_t sum_inputs {0}; uint64_t sum_inputs {0};
uint64_t sum_outputs {0}; uint64_t sum_outputs {0};
uint64_t no_inputs {0}; uint64_t no_inputs {0};
@ -48,26 +48,28 @@ struct MempoolStatus
// the current info timesout. // the current info timesout.
struct network_info struct network_info
{ {
uint64_t height; uint64_t height {0};
bool testnet; uint64_t target_height {0};
bool current; uint64_t difficulty {0};
uint64_t target {0};
uint64_t tx_count {0};
uint64_t tx_pool_size {0};
uint64_t alt_blocks_count {0};
uint64_t outgoing_connections_count {0};
uint64_t incoming_connections_count {0};
uint64_t white_peerlist_size {0};
uint64_t grey_peerlist_size {0};
bool testnet {false};
crypto::hash top_block_hash; crypto::hash top_block_hash;
uint64_t target_height; uint64_t cumulative_difficulty {0};
uint64_t difficulty; uint64_t block_size_limit {0};
uint64_t target; uint64_t start_time {0};
uint64_t tx_count;
uint64_t tx_pool_size; uint64_t hash_rate {0};
uint64_t alt_blocks_count; uint64_t fee_per_kb {0};
uint64_t outgoing_connections_count; uint64_t info_timestamp {0};
uint64_t incoming_connections_count;
uint64_t white_peerlist_size; bool current {false};
uint64_t grey_peerlist_size;
uint64_t cumulative_difficulty;
uint64_t block_size_limit;
uint64_t start_time;
uint64_t hash_rate;
uint64_t fee_per_kb;
uint64_t info_timestamp;
}; };
static boost::thread m_thread; static boost::thread m_thread;

@ -858,7 +858,7 @@ namespace xmreg
// calculate difference between tx in mempool and server timestamps // calculate difference between tx in mempool and server timestamps
array<size_t, 5> delta_time = timestamp_difference( array<size_t, 5> delta_time = timestamp_difference(
local_copy_server_timestamp, local_copy_server_timestamp,
mempool_tx.info.receive_time); mempool_tx.receive_time);
// use only hours, so if we have days, add // use only hours, so if we have days, add
// it to hours // it to hours
@ -881,10 +881,10 @@ namespace xmreg
// set output page template map // set output page template map
txs.push_back(mstch::map { txs.push_back(mstch::map {
{"timestamp_no" , mempool_tx.info.receive_time}, {"timestamp_no" , mempool_tx.receive_time},
{"timestamp" , mempool_tx.timestamp_str}, {"timestamp" , mempool_tx.timestamp_str},
{"age" , age_str}, {"age" , age_str},
{"hash" , mempool_tx.info.id_hash}, {"hash" , pod_to_hex(mempool_tx.tx_hash)},
{"fee" , mempool_tx.fee_str}, {"fee" , mempool_tx.fee_str},
{"xmr_inputs" , mempool_tx.xmr_inputs_str}, {"xmr_inputs" , mempool_tx.xmr_inputs_str},
{"xmr_outputs" , mempool_tx.xmr_outputs_str}, {"xmr_outputs" , mempool_tx.xmr_outputs_str},
@ -1165,7 +1165,7 @@ namespace xmreg
// so use its recive_time as timestamp to show // so use its recive_time as timestamp to show
uint64_t tx_recieve_timestamp uint64_t tx_recieve_timestamp
= found_txs.at(0).info.receive_time; = found_txs.at(0).receive_time;
blk_timestamp = xmreg::timestamp_to_str_gm(tx_recieve_timestamp); blk_timestamp = xmreg::timestamp_to_str_gm(tx_recieve_timestamp);
@ -1486,7 +1486,7 @@ namespace xmreg
// so use its recive_time as timestamp to show // so use its recive_time as timestamp to show
uint64_t tx_recieve_timestamp uint64_t tx_recieve_timestamp
= found_txs.at(0).info.receive_time; = found_txs.at(0).receive_time;
blk_timestamp = xmreg::timestamp_to_str_gm(tx_recieve_timestamp); blk_timestamp = xmreg::timestamp_to_str_gm(tx_recieve_timestamp);
@ -3585,7 +3585,7 @@ namespace xmreg
// tx in mempool have no blk_timestamp // tx in mempool have no blk_timestamp
// but can use their recive time // but can use their recive time
blk_timestamp = found_txs.at(0).info.receive_time; blk_timestamp = found_txs.at(0).receive_time;
} }
@ -4320,7 +4320,7 @@ namespace xmreg
json j_tx = get_tx_json(mempool_tx->tx, txd); json j_tx = get_tx_json(mempool_tx->tx, txd);
// we add some extra data, for mempool txs, such as recieve timestamp // we add some extra data, for mempool txs, such as recieve timestamp
j_tx["timestamp"] = mempool_tx->info.receive_time; j_tx["timestamp"] = mempool_tx->receive_time;
j_tx["timestamp_utc"] = mempool_tx->timestamp_str; j_tx["timestamp_utc"] = mempool_tx->timestamp_str;
j_txs.push_back(j_tx); j_txs.push_back(j_tx);
@ -4745,7 +4745,7 @@ namespace xmreg
// there should be only one tx found // there should be only one tx found
tx = found_txs.at(0).tx; tx = found_txs.at(0).tx;
found_in_mempool = true; found_in_mempool = true;
tx_timestamp = found_txs.at(0).info.receive_time; tx_timestamp = found_txs.at(0).receive_time;
} }
else else
{ {

Loading…
Cancel
Save