-
Notifications
You must be signed in to change notification settings - Fork 117
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
Updated ListAssetRequest to include additional filter options #1199
base: main
Are you sure you want to change the base?
Updated ListAssetRequest to include additional filter options #1199
Conversation
84ac4c8
to
b6e90aa
Compare
f31d9f4
to
f189364
Compare
Pull Request Test Coverage Report for Build 12439004519Details
💛 - Coveralls |
f189364
to
ccf4b76
Compare
6abd778
to
3c0141b
Compare
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.
looking good!
it's in the right direction 💯
13eabd1
to
241d98d
Compare
f5d1985
to
9c7b7e9
Compare
9c7b7e9
to
4566b97
Compare
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.
lots of improvements! ⬆️
I have one comment on the types of filters
We'll also need that unit test coverage ✔️
Int64: int64(query.MaxAmt), | ||
Valid: true, | ||
} | ||
} else { |
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.
this whole block is not needed, you can just leave query.MaxAmt
initialized to default values (Valid: false
)
tapdb/assets_store.go
Outdated
@@ -980,6 +1008,10 @@ type AssetQueryFilters struct { | |||
// MinAnchorHeight is the minimum block height the asset's anchor tx | |||
// must have been confirmed at. | |||
MinAnchorHeight int32 | |||
|
|||
ScriptKeyID *int64 |
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.
missing godocs (see MinAnchorHeight
above)
tapdb/assets_store.go
Outdated
if query.MinAnchorHeight != 0 { | ||
assetFilter.MinAnchorHeight = sqlInt32( | ||
query.MinAnchorHeight, | ||
) | ||
} | ||
|
||
if query.ScriptKeyID != nil { |
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.
we can't really have user-facing arguments that reference database IDs
the ScriptKeyID
is the DB identifier for a script key and there's no possible way a user could (...easily) get their hands on one of them in order to filter the assets
Instead we could have *AssetQueryFilters
expose scriptKey []byte
and anchorOutpoint []byte
filters, which the user can easily acquire, then on this point in the code we could map these values to the unique db ID that the underlying layer requires for filtering (that is QueryAssetFilters
struct)
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.
if you add some tests with the current way things work, you'll see that when you'll try to query a specific script key you'll have trouble finding the ID to filter by
|
||
assets, err := r.cfg.AssetStore.FetchAllAssets( | ||
ctx, includeSpent, includeLeased, nil, | ||
ctx, includeSpent, includeLeased, queryFilters, |
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.
you should add some unit test coverage in tapdb
to test the behavior of AssetStore.FetchAllAssets
I think this function can help resolve the issue w.r.t getting the internal ID, you can just specify all the normal bytes (script key, anchor point, etc): taproot-assets/tapdb/assets_store.go Lines 904 to 935 in ec84760
|
850c549
to
ccaf4e4
Compare
ccaf4e4
to
ffa733e
Compare
@itsrachelfish, remember to re-request review from reviewers when ready |
Resolves #876
This PR adds new filter options to the
ListAssets
RPC call.ListAssetRequest
proto definition was updated to include the new filter options.fetchRpcAssets
function was refactored to accept aAssetQueryFilters
argument so that separate arguments don't need to be added for each filter option.constraintsToDbFilter
function was updated to use the new filter options.assets.sql
file was updated to include a newmaxAmount
option.