-
Notifications
You must be signed in to change notification settings - Fork 17
Ensure transaction inputs return complete output data #645
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
Conversation
There is a rare edge case when querying transactions that have just been inserted, but whose inputs have not yet been updated by `InputUpdateQueries`. In this scenario, the API returns the transactions, but the inputs are missing output data such as address and amount. This makes it difficult for applications to process these transactions. To address this, the API should only return transactions with complete data. For this edge case (which typically lasts around 300ms between insert and update), when querying transactions, we check if input data is complete—which is almost always the case. If not, we retrieve the corresponding output so users always receive complete transaction data. If for some reason we can't find the output, we'll return then incomplete input.
outputRefAmount = Some(output.amount), | ||
outputRefTokens = output.tokens | ||
) | ||
case None => input |
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.
Q: Is it possible that we end up in this situation where input still dose not have complete 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.
It's very very unlikely, I don't see yet a case, but there's always that one edge case we don't see :)
* If not, we get back outputs for the missing inputs | ||
*/ | ||
def validateInputFromTx( | ||
input: InputsFromTxQR |
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.
[Nit] Shall we call it InputFromTxQR
and InputQR
?
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.
yes would make more sense indeed, I think the reasoning was: Query Response of Inputs table
, but as the type represent only 1 input, it would be better
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.
@h0ngcha0 I also renamed some other types not used here
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.
LGTM 👍
There is a rare edge case when querying transactions that have just been inserted, but whose inputs have not yet been updated by
InputUpdateQueries
. In this scenario, the API returns the transactions, but the inputs are missing output data such as address and amount. This makes it difficult for applications to process these transactions.To address this, the API should only return transactions with complete data. For this edge case (which typically lasts around 300ms between insert and update), when querying transactions, we check if input data is complete—which is almost always the case. If not, we retrieve the corresponding output so users always receive complete transaction data.
If for some reason we can't find the output, we'll return then incomplete input.