Problem: Outputs API doesn't respond with correct unspent/spent outputs#2567
Merged
ldmberman merged 6 commits intobigchaindb:masterfrom Sep 26, 2018
Merged
Problem: Outputs API doesn't respond with correct unspent/spent outputs#2567ldmberman merged 6 commits intobigchaindb:masterfrom
ldmberman merged 6 commits intobigchaindb:masterfrom
Conversation
Solution: Fix fastquery such that embedded document is queried properly
Codecov Report
@@ Coverage Diff @@
## master #2567 +/- ##
==========================================
+ Coverage 93.63% 93.64% +<.01%
==========================================
Files 45 45
Lines 2623 2626 +3
==========================================
+ Hits 2456 2459 +3
Misses 167 167 |
ttmc
reviewed
Sep 21, 2018
bigchaindb/common/transaction.py
Outdated
| } | ||
|
|
||
| def to_query(self): | ||
| if self.txid is None and self.output is None: |
Contributor
There was a problem hiding this comment.
Is it possible for just one of these to be None?
Contributor
Author
There was a problem hiding this comment.
Actually, these fields cannot be None. I started off with to_dict, this code is leftover
Solution: remove to unnecesary if conditional
ldmberman
reviewed
Sep 24, 2018
bigchaindb/common/transaction.py
Outdated
| 'output_index': self.output, | ||
| } | ||
|
|
||
| def to_query(self): |
Contributor
There was a problem hiding this comment.
What do you think about changing the transaction query the following way? The current approach disguises the caveat from the reader.
'$and': [
{
'inputs.fulfills.transaction_id': {
'$in': transaction_ids,
},
'inputs.fulfills.output_index': {
'$in': output_indexes,
},
}
]
Contributor
There was a problem hiding this comment.
Actually, $and is applied to fulfills so:
{
'inputs.fulfills: {
'$and': [{
transaction_id': {
'$in': transaction_ids,
},
'output_index': {
'$in': output_indexes,
},
}]
}
]
Contributor
There was a problem hiding this comment.
Ah, and we also seem to need $elemMatch.
Solution: get_spent queries embedded documents which respect key order. This is not expected by the application hence the query should be altered to query any kind of key order
Solution: Simplify query using $elemMatch
Solution: Add test for `get_spending_transactions` to check that correct matching is done when querying documents with multiple inputs
ttmc
approved these changes
Sep 24, 2018
Solution: assert tranasction ids
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Solution: Fix
fastquerysuch that embedded document is queried properlyFixes #2552
Fixes #2568