Merge pull request #1667

cd024be tracking: query blockchain height only once during update (xiphon)
cf8f36b tracking: don't fetch redundant txes (xiphon)
This commit is contained in:
luigi1111 2018-10-16 16:31:47 -05:00
commit 2e2e7be4d0
No known key found for this signature in database
GPG key ID: F4ACA0183641E010

View file

@ -65,6 +65,8 @@ Rectangle {
} }
function update() { function update() {
const max_tracking = 3;
if (!appWindow.currentWallet || !trackingEnabled.checked) { if (!appWindow.currentWallet || !trackingEnabled.checked) {
trackingLineText.text = ""; trackingLineText.text = "";
trackingModel.clear(); trackingModel.clear();
@ -80,10 +82,10 @@ Rectangle {
var count = model.rowCount() var count = model.rowCount()
var totalAmount = 0 var totalAmount = 0
var nTransactions = 0 var nTransactions = 0
var blockchainHeight = 0 var blockchainHeight = null
var txs = [] var txs = []
for (var i = 0; i < count; ++i) { for (var i = 0; i < count && txs.length < max_tracking; ++i) {
var idx = model.index(i, 0) var idx = model.index(i, 0)
var isout = model.data(idx, TransactionHistoryModel.TransactionIsOutRole); var isout = model.data(idx, TransactionHistoryModel.TransactionIsOutRole);
var subaddrAccount = model.data(idx, TransactionHistoryModel.TransactionSubaddrAccountRole); var subaddrAccount = model.data(idx, TransactionHistoryModel.TransactionSubaddrAccountRole);
@ -103,8 +105,8 @@ Rectangle {
if (blockHeight == 0) { if (blockHeight == 0) {
in_txpool = true; in_txpool = true;
} else { } else {
if (blockchainHeight == 0) if (blockchainHeight == null)
blockchainHeight = walletManager.blockchainHeight() blockchainHeight = appWindow.currentWallet.blockChainHeight()
confirmations = blockchainHeight - blockHeight - 1 confirmations = blockchainHeight - blockHeight - 1
displayAmount = model.data(idx, TransactionHistoryModel.TransactionDisplayAmountRole); displayAmount = model.data(idx, TransactionHistoryModel.TransactionDisplayAmountRole);
} }
@ -130,7 +132,6 @@ Rectangle {
trackingLineText.text = qsTr("%1 transactions found").arg(nTransactions) + ":" + translationManager.emptyString trackingLineText.text = qsTr("%1 transactions found").arg(nTransactions) + ":" + translationManager.emptyString
} }
var max_tracking = 3;
toReceiveSatisfiedLine.text = ""; toReceiveSatisfiedLine.text = "";
var expectedAmount = walletManager.amountFromString(amountToReceiveLine.text) var expectedAmount = walletManager.amountFromString(amountToReceiveLine.text)
if (expectedAmount && expectedAmount != amount) { if (expectedAmount && expectedAmount != amount) {
@ -143,11 +144,6 @@ Rectangle {
} }
trackingModel.clear(); trackingModel.clear();
if (txs.length > 3) {
txs.length = 3;
}
txs.forEach(function(tx){ txs.forEach(function(tx){
trackingModel.append({ trackingModel.append({
"amount": tx.amount, "amount": tx.amount,