Rename to save Z txs

This commit is contained in:
Aditya Kulkarni
2018-10-23 22:13:45 -07:00
parent 4c58f70a31
commit cdc46b3022
8 changed files with 42 additions and 39 deletions

View File

@@ -332,8 +332,21 @@ void RPC::getBatchRPC(
waitTimer->start(100);
}
/// Batch RPC methods
// Refresh received z txs by calling z_listreceivedbyaddress/gettransaction
void RPC::refreshReceivedZTrans(QList<QString> zaddrs, QList<QString> txidFilter) {
// We'll only refresh the received Z txs if settings allows us.
if (!Settings::getInstance()->getSaveZtxs()) {
QList<TransactionItem> emptylist;
transactionsTableModel->addZRecvData(emptylist);
return;
}
// This method is complicated because z_listreceivedbyaddress only returns the txid, and
// we have to make a follow up call to gettransaction to get details of that transaction.
// Additionally, it has to be done in batches, because there are multiple z-Addresses,
// and each z-Addr can have multiple received txs.
// 1. For each z-Addr, get list of received txs
getBatchRPC(zaddrs,
[=] (QString zaddr) {
@@ -347,7 +360,8 @@ void RPC::refreshReceivedZTrans(QList<QString> zaddrs, QList<QString> txidFilter
return payload;
},
[=] (QMap<QString, json>* zaddrTxids) {
// Process all txids
// Process all txids, removing duplicates. This can happen if the same address
// appears multiple times in a single tx's outputs.
QSet<QString> txids;
for (auto it = zaddrTxids->constBegin(); it != zaddrTxids->constEnd(); it++) {
for (auto& i : it.value().get<json::array_t>()) {