Compare commits

...

4 Commits

Author SHA1 Message Date
moneroexamples d2d6504dd0 fix mysql_tests
5 years ago
moneroexamples 66047b9dc6 dont require inputs and outputs_id to be unique
5 years ago
moneroexamples 9087478ea3 upgrade xmregcore
5 years ago
moneroexamples 174b934501 Output table and known_outputs_t modified
5 years ago

@ -63,7 +63,6 @@ CREATE TABLE IF NOT EXISTS `Inputs` (
`amount` bigint(20) UNSIGNED ZEROFILL NOT NULL DEFAULT '00000000000000000000',
`timestamp` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,
PRIMARY KEY (`id`),
UNIQUE KEY `output_id` (`output_id`,`key_image`),
KEY `account_id2` (`account_id`),
KEY `tx_id2` (`tx_id`),
KEY `output_id2` (`output_id`)
@ -91,7 +90,7 @@ CREATE TABLE IF NOT EXISTS `Outputs` (
`mixin` bigint(20) UNSIGNED NOT NULL DEFAULT '0',
`timestamp` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,
PRIMARY KEY (`id`),
UNIQUE KEY `out_pub_key` (`out_pub_key`),
UNIQUE KEY `out_pub_key` (`out_pub_key`, `tx_id`),
KEY `tx_id` (`tx_id`),
KEY `account_id` (`account_id`) USING BTREE
) ENGINE=InnoDB DEFAULT CHARSET=utf8;

@ -80,7 +80,6 @@ CREATE TABLE IF NOT EXISTS `Inputs` (
`amount` bigint(20) UNSIGNED ZEROFILL NOT NULL DEFAULT '00000000000000000000',
`timestamp` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,
PRIMARY KEY (`id`),
UNIQUE KEY `output_id` (`output_id`,`key_image`),
KEY `account_id2` (`account_id`),
KEY `tx_id2` (`tx_id`),
KEY `output_id2` (`output_id`)
@ -190,7 +189,7 @@ CREATE TABLE IF NOT EXISTS `Outputs` (
`mixin` bigint(20) UNSIGNED NOT NULL DEFAULT '0',
`timestamp` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,
PRIMARY KEY (`id`),
UNIQUE KEY `out_pub_key` (`out_pub_key`),
UNIQUE KEY `out_pub_key` (`out_pub_key`, `tx_id`),
KEY `tx_id` (`tx_id`),
KEY `account_id` (`account_id`) USING BTREE
) ENGINE=InnoDB AUTO_INCREMENT=140460833003782 DEFAULT CHARSET=utf8;

@ -872,7 +872,7 @@ CurrentBlockchainStatus::get_searched_blk_no(const string& address,
bool
CurrentBlockchainStatus::get_known_outputs_keys(
string const& address,
unordered_map<public_key, uint64_t>& known_outputs_keys)
known_outputs_t& known_outputs_keys)
{
std::lock_guard<std::mutex> lck (searching_threads_map_mtx);

@ -50,6 +50,8 @@ public:
// recieved_time, tx
using mempool_txs_t = vector<pair<uint64_t, transaction>>;
//output_pubk, amount
using known_outputs_t = unordered_multimap<public_key, uint64_t>;
// height , timestamp, is_coinbase
using txs_tuple_t
@ -259,8 +261,7 @@ public:
virtual bool
get_known_outputs_keys(string const& address,
unordered_map<public_key,
uint64_t>& known_outputs_keys);
known_outputs_t& known_outputs_keys);
virtual void
clean_search_thread_map();

@ -1452,6 +1452,9 @@ OpenMoneroRequests::import_recent_wallet_request(
XmrAccount updated_acc = acc;
//cout << updated_acc.scanned_block_height
//<< ',' << no_blocks_to_import << '\n';
// make sure scanned_block_height is larger than
// no_blocks_to_import so we dont
// end up with overflowing uint64_t.
@ -1805,7 +1808,7 @@ OpenMoneroRequests::get_tx(
// we have to redo this info from basically from scrach.
unordered_map<public_key, uint64_t> known_outputs_keys;
CurrentBlockchainStatus::known_outputs_t known_outputs_keys;
if (current_bc_status->get_known_outputs_keys(
xmr_address, known_outputs_keys))

@ -721,7 +721,7 @@ TxSearch::populate_known_outputs()
hex_to_pod(out.out_pub_key, out_pub_key);
known_outputs_keys[out_pub_key] = out.amount;
known_outputs_keys.insert({out_pub_key, out.amount});
}
}
}

@ -30,7 +30,7 @@ class TxSearch
public:
// out_pk , amount
using known_outputs_t = std::unordered_map<public_key, uint64_t>;
using known_outputs_t = std::unordered_multimap<public_key, uint64_t>;
using addr_view_t = std::pair<address_parse_info, secret_key>;
using pool_txs_t = std::vector<pair<uint64_t, transaction>>;

@ -27,6 +27,8 @@ public:
virtual string table_name() const = 0;
virtual json to_json() const = 0;
virtual ~Table() = default;
friend std::ostream& operator<< (std::ostream& stream, const Table& data);
};

@ -1 +1 @@
Subproject commit 4356c9892b9903da4410f773ea36a6e4c799be5a
Subproject commit 20c9de37cfa5b199bd36e0a2e12fcb01337ef779

@ -925,10 +925,32 @@ TEST_F(MYSQL_TEST, SelectInputsForOutput)
ASSERT_TRUE(xmr_accounts->select_inputs_for_out(output_id, inputs));
for (auto&& in: inputs)
{
cout << in << 'n';
}
EXPECT_EQ(inputs.size(), 3);
EXPECT_EQ(inputs.front().key_image, "00dd88b3a16b3616d342faec2bc47b24add433407ef79b9a00b55b75d96239a4");
EXPECT_EQ(inputs.back().key_image, "abc529357f90641d501d5108f822617049c19461569eafa45cb5400ee45bef33");
auto it= std::find_if(
inputs.begin(), inputs.end(),
[](auto const& input)
{
return input.key_image
== "00dd88b3a16b3616d342faec2bc47b24add433407ef79b9a00b55b75d96239a4";
});
EXPECT_TRUE(it != inputs.end());
it= std::find_if(
inputs.begin(), inputs.end(),
[](auto const& input)
{
return input.key_image
== "abc529357f90641d501d5108f822617049c19461569eafa45cb5400ee45bef33";
});
EXPECT_TRUE(it != inputs.end());
inputs.clear();
@ -1035,7 +1057,9 @@ TEST_F(MYSQL_TEST, InsertSeverlInputsAtOnce)
TEST_F(MYSQL_TEST, TryToInsertSameInputTwice)
{
// the input table requires a row to be unique for pair
// of key_image + output_id
// of key_image + output_id. UPDATE. This is no longer
// the case as output public keys are not garanteed to
// be unique
ACC_FROM_HEX(owner_addr_5Ajfk);
@ -1048,10 +1072,10 @@ TEST_F(MYSQL_TEST, TryToInsertSameInputTwice)
EXPECT_GT(inserted_id, 0);
// second insert should fail and result in 0
// second insert should also be fine
inserted_id = xmr_accounts->insert(mock_data);
EXPECT_EQ(inserted_id, 0);
EXPECT_GT(inserted_id, 0);
}

Loading…
Cancel
Save