Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[r2r] Remove outdated transactions from transaction history #1328

Merged
merged 9 commits into from Jul 4, 2022

Conversation

caglaryucekaya
Copy link

Fixes #1321 for UTXO coins by removing outdated transactions from transaction history

@caglaryucekaya caglaryucekaya changed the title Remove outdated transactions from transaction history [r2r] Remove outdated transactions from transaction history Jun 27, 2022
Copy link
Member

@artemii235 artemii235 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for the PR!
It's a first review. @caglaryucekaya Please also check if the same should be done for my_tx_history_v2.

mm2src/coins/utxo/utxo_common.rs Outdated Show resolved Hide resolved
@caglaryucekaya caglaryucekaya changed the title [r2r] Remove outdated transactions from transaction history [wip] Remove outdated transactions from transaction history Jun 27, 2022
@@ -2056,7 +2056,8 @@ where
};
let mut history_map: HashMap<H256Json, TransactionDetails> = history
.into_iter()
.map(|tx| (H256Json::from(tx.tx_hash.as_bytes()), tx))
.filter(|tx| H256Json::from_str(&tx.tx_hash).is_ok())
.map(|tx| (H256Json::from_str(&tx.tx_hash).unwrap(), tx))
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There was an unexpected bug here at the creation of the history_map. Using H256Json::from(tx.tx_hash.as_bytes()) created a different hash than the hashes inside the tx_ids vector. As a result, existing transactions in the history_map were ignored and all the transactions in the tx_ids were inserted repeatedly into the history_map. Creating the H256 by H256Json::from_str(&tx.tx_hash) fixed the problem.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good catch :)

@caglaryucekaya caglaryucekaya changed the title [wip] Remove outdated transactions from transaction history [r2r] Remove outdated transactions from transaction history Jun 28, 2022
@caglaryucekaya caglaryucekaya changed the title [r2r] Remove outdated transactions from transaction history [wip] Remove outdated transactions from transaction history Jun 28, 2022
@caglaryucekaya caglaryucekaya changed the title [wip] Remove outdated transactions from transaction history [r2r] Remove outdated transactions from transaction history Jun 28, 2022
artemii235
artemii235 previously approved these changes Jun 29, 2022
Copy link
Member

@artemii235 artemii235 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🔥

@artemii235
Copy link
Member

@sergeyboyko0791 Could you please take a look too? :)

@caglaryucekaya
Copy link
Author

If everything is fine, I can apply the same change to other coins as well before merging the PR

Copy link

@sergeyboyko0791 sergeyboyko0791 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM!

@sergeyboyko0791
Copy link

I think we have the same bug in QRC20, and we also need to remove outdated transactions from from QRC20 tx history.

If everything is fine, I can apply the same change to other coins as well before merging the PR

@caglaryucekaya caglaryucekaya changed the title [r2r] Remove outdated transactions from transaction history [wip] Remove outdated transactions from transaction history Jun 29, 2022
@caglaryucekaya
Copy link
Author

I think we have the same bug in QRC20, and we also need to remove outdated transactions from from QRC20 tx history.

If everything is fine, I can apply the same change to other coins as well before merging the PR

QRC20 didn't have the same bug, but tx history v2 did so I also fixed it

@caglaryucekaya caglaryucekaya changed the title [wip] Remove outdated transactions from transaction history [r2r] Remove outdated transactions from transaction history Jun 30, 2022
Copy link
Member

@artemii235 artemii235 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

One minor change.

mm2src/mm2_bitcoin/rpc/src/v1/types/hash.rs Outdated Show resolved Hide resolved
@caglaryucekaya caglaryucekaya changed the title [r2r] Remove outdated transactions from transaction history [wip] Remove outdated transactions from transaction history Jul 4, 2022
Copy link
Member

@artemii235 artemii235 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍

@caglaryucekaya caglaryucekaya changed the title [wip] Remove outdated transactions from transaction history [r2r] Remove outdated transactions from transaction history Jul 4, 2022
@artemii235 artemii235 merged commit a4cf395 into dev Jul 4, 2022
@artemii235 artemii235 deleted the remove-outdated-txs branch July 4, 2022 10:56
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants