Correct uniqueness lookup for nil location #1433
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.
It's extremely hard for an external client calling the
AddContractListener
REST API to determine whether the listener already exists, because the details are a factor of a complex FFI payload.For this reason FireFly provides a uniqueness check for the:
namespace
topic
- allows multiple listeners to the same event, for different appslocation
- can be nil, or a blockchain-specific locationsignature
- generated by FireFly in a protocol specific way from the supplied FFI signatureHowever, the code doing a lookup in the DB was not working for the nil check, due to a
.ToString()
Annoyingly there's a weirdness with
fftypes.JSONAny.Value()
in thenil
case, and for some reason passing a(*fftypes.JSONAny)(nil)
intofb.Eq()
is not generating anIS NULL
SQL query.So instead this code passes actual
nil
in the nil case, and this works.