This repository has been archived by the owner on Jun 11, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 456
Add filter data field to get transactions endpoint - Closes #2404 #2470
Merged
shuse2
merged 14 commits into
development
from
2404-add_filter_data_field_get_transactions
Oct 18, 2018
Merged
Add filter data field to get transactions endpoint - Closes #2404 #2470
shuse2
merged 14 commits into
development
from
2404-add_filter_data_field_get_transactions
Oct 18, 2018
Conversation
This file contains 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
diego-G
changed the title
Add filter data field get transactions - Closes #2404
Add filter data field to get transactions endpoint - Closes #2404
Oct 15, 2018
diego-G
force-pushed
the
2404-add_filter_data_field_get_transactions
branch
from
October 15, 2018 11:35
8d644d1
to
8882e71
Compare
nazarhussain
suggested changes
Oct 16, 2018
schema/swagger.yml
Outdated
in: query | ||
description: Additional data field to query | ||
type: string | ||
format: data |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There is no format defined with this name data
modules/transactions.js
Outdated
@@ -121,6 +121,9 @@ __private.list = function(filter, cb) { | |||
maxAmount: '"t_amount" <= ${maxAmount}', | |||
type: '"t_type" = ${type}', | |||
minConfirmations: 'confirmations >= ${minConfirmations}', | |||
data: `ENCODE((SELECT data FROM transfer WHERE transfer."transactionId" = trs_list."t_id"), 'escape') LIKE '${ | |||
filter.data | |||
}'`, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
After research, I suggest for now we go with exact match instead of regexpr:
- This must be going to impact the performance
- The
encode
withescape
just escape the special characters so will change the actual content- If user added a transaction with
\u0000 hey how :)
, escaping it will turn it to\000 hey how :)
- If user search with key word
00
the query will match and return the transaction
- If user added a transaction with
- Since the actual content is different then escaped one so match will not result accurate
So until we have this data
field as binary, we should only provide the exact match. Once we find way to convert it to utf8 strings, then we may provide the pattern matching.
Instead of encoding the cases existing in the database from bytea to utf8, we convert the filter required by the user from utf8 to hex and later decode it to bytea finally making the comparision in plain bytea.
It covers edge cases related to SQL injection.
nazarhussain
approved these changes
Oct 16, 2018
4miners
suggested changes
Oct 17, 2018
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please check the impact of the new subquery on performance.
4miners
suggested changes
Oct 18, 2018
diego-G
requested review from
4miners and
shuse2
and removed request for
vitaly-t
October 18, 2018 09:52
4miners
approved these changes
Oct 18, 2018
nazarhussain
previously approved these changes
Oct 18, 2018
4miners
previously approved these changes
Oct 18, 2018
shuse2
suggested changes
Oct 18, 2018
shuse2
approved these changes
Oct 18, 2018
Sign up for free
to subscribe to this conversation on GitHub.
Already have an account?
Sign in.
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.
What was the problem?
There was no way to get a transaction from its attached additional data field.
How did I fix it?
Adding a subquery filter on GET transactions endpoint.
How to test it?
mocha test/functional/http/get/transactions.js
Review checklist