Inputs ssqls added

pull/1/head
moneroexamples 8 years ago
parent 5c18958edb
commit a66f5230f3

@ -309,19 +309,22 @@ public:
string tx_hash_str = pod_to_hex(tx_hash);
DateTime blk_timestamp_mysql_format
= XmrTransaction::timestamp_to_DateTime(blk.timestamp);
XmrTransaction tx_data;
tx_data.hash = tx_hash_str;
tx_data.account_id = acc.id;
tx_data.hash = tx_hash_str;
tx_data.account_id = acc.id;
tx_data.total_received = total_received;
tx_data.total_sent = 0; // at this stage we don't have any
tx_data.total_sent = 0; // at this stage we don't have any
// info about spendings
tx_data.unlock_time = 0;
tx_data.height = searched_blk_no;
tx_data.coinbase = is_coinbase(tx);
tx_data.payment_id = payment_id_str;
tx_data.mixin = get_mixin_no(tx) - 1;
tx_data.timestamp = XmrTransaction::timestamp_to_DateTime(blk.timestamp);
tx_data.unlock_time = 0;
tx_data.height = searched_blk_no;
tx_data.coinbase = is_coinbase(tx);
tx_data.payment_id = payment_id_str;
tx_data.mixin = get_mixin_no(tx) - 1;
tx_data.timestamp = blk_timestamp_mysql_format;
// insert tx_data into mysql's Transactions table
uint64_t tx_mysql_id = xmr_accounts->insert_tx(tx_data);

@ -235,6 +235,65 @@ ostream& operator<< (std::ostream& os, const XmrOutput& out) {
os << "XmrOutputs: " << out.to_json().dump() << '\n';
return os;
};
sql_create_6(Inputs, 1, 4,
sql_bigint_unsigned, id,
sql_bigint_unsigned, account_id,
sql_bigint_unsigned, tx_id,
sql_bigint_unsigned, output_id,
sql_varchar , key_image,
sql_timestamp , timestamp);
struct XmrInput : public Inputs
{
static constexpr const char* SELECT_STMT = R"(
SELECT * FROM `Inputs` WHERE `account_id` = (%0q)
)";
static constexpr const char* EXIST_STMT = R"(
SELECT 1 FROM `Inputs` WHERE `key_image` == (%0q)
)";
static constexpr const char* INSERT_STMT = R"(
INSERT IGNORE INTO `Inputs` (`account_id`, `tx_id`, `output_id`,
`key_image`, `timestamp`)
VALUES (%0q, %1q, %2q,
%3q, %4q);
)";
using Inputs::Inputs;
json
to_json() const
{
json j {{"id" , id},
{"account_id" , account_id},
{"tx_id" , tx_id},
{"output_id" , output_id},
{"key_image" , key_image},
{"timestamp" , timestamp}
};
return j;
}
friend std::ostream& operator<< (std::ostream& stream, const XmrInput& out);
};
ostream& operator<< (std::ostream& os, const XmrInput& out) {
os << "XmrInput: " << out.to_json().dump() << '\n';
return os;
};
}

Loading…
Cancel
Save