Add function TxIDExists and use in validation path #2075
Merged
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.
Signed-off-by: manish manish.sethi@gmail.com
Type of change
Description
This commit adds a function in ledger TxIDExists and uses this in validation path for checking duplicate txids.
Additional details
The current validation code, in order to checks for a duplicate txid, uses the API
GetTransactionByID
on ledger and relies on the error types returned by this API. For a ledger that is bootstrapped from a snapshot, this API returns another untyped error (stating that the TxID details not available) if the TxID belongs to a block that is committed prior to the snapshot height. In the current code, in validation path, this error will be interpreted as general ledger error that results in a peer panic.One option is to return a typed error (e.g.,
TxIDBeforeSnapshot
) and modify the validation to check for this error type as well. However, instead of exposing one more error type for validation code, it is cleaner to add an explicit function for checking the existence of a TxID. This makes the existing code relatively more readable as well.Related issues
FAB-18318