-
Notifications
You must be signed in to change notification settings - Fork 11
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
Asset holders query #155
Asset holders query #155
Conversation
dc6ea74
to
fa92ea9
Compare
fa92ea9
to
dca3ddb
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.
Reviewed 12 of 12 files at r1.
Reviewable status: all files reviewed, 4 unresolved discussions (waiting on @charlie-wasp)
src/repo/assets.ts, line 68 at r1 (raw file):
if (paging.after) { queryBuilder.where("balance < ?", balance);
We should use <= balance
/>= balance
and also introduce strict condition on accountid
from the cursor. Currently the pagination will stop as soon as you reach a first zero-balance account, because the next page request will result in where balance < 0
.
src/schema/assets.ts, line 18 at r1 (raw file):
code: AssetCode! "All accounts that trust this asset, ordered by balance" holders(first: Int, last: Int, after: String, before: String): BalanceConnection
Let's call it balances
for better consistency with the result data type and Account
side.
src/schema/assets.ts, line 36 at r1 (raw file):
flags: AccountFlags "All accounts that trust this asset, ordered by balance" holders(first: Int, last: Int, after: String, before: String): BalanceConnection
I'm not sure we need to introduce holders to both Asset
and AssetWithInfo
. And by the way, do we still need those two separate types? Looks like the Asset
type and AssetID
scalar provide exactly the same information.
src/util/paging.ts, line 31 at r1 (raw file):
export function properlyOrdered(records: any[], pagingParams: PagingParams): any[] { if (pagingParams.last && pagingParams.before) {
Hmm, I believe that presence of before
param should not affect our ordering in any way, should it?
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.
Reviewable status: 9 of 12 files reviewed, 4 unresolved discussions (waiting on @nebolsin)
src/repo/assets.ts, line 68 at r1 (raw file):
Previously, nebolsin (Sergey Nebolsin) wrote…
We should use
<= balance
/>= balance
and also introduce strict condition onaccountid
from the cursor. Currently the pagination will stop as soon as you reach a first zero-balance account, because the next page request will result inwhere balance < 0
.
Done.
src/schema/assets.ts, line 18 at r1 (raw file):
Previously, nebolsin (Sergey Nebolsin) wrote…
Let's call it
balances
for better consistency with the result data type andAccount
side.
Done.
src/schema/assets.ts, line 36 at r1 (raw file):
Previously, nebolsin (Sergey Nebolsin) wrote…
I'm not sure we need to introduce holders to both
Asset
andAssetWithInfo
. And by the way, do we still need those two separate types? Looks like theAsset
type andAssetID
scalar provide exactly the same information.
Well, AssetWithInfo
is the type for a data, which Horizon returns. It contains additional amount
and numAccounts
fields. We would be able to reduce them to the single type, when we'll fetch assets from core database.
If we don't want to get a list of assets with corresponding holders, we can drop holders
from here
src/util/paging.ts, line 31 at r1 (raw file):
Previously, nebolsin (Sergey Nebolsin) wrote…
Hmm, I believe that presence of
before
param should not affect our ordering in any way, should it?
Oh my god, this pagination discussion seems to be infinite 😅 Give me a sec... We need to reverse records on backward motion, because we call invertSortOrder
, if before
is set (look at parseCursorPagination
method above). Quite opaque and convoluted logic 😔
94f7135
to
4bc4cc5
Compare
805a68c
to
9ba34d5
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.
Reviewed 2 of 3 files at r2, 2 of 3 files at r3, 1 of 1 files at r4.
Reviewable status:complete! all files reviewed, all discussions resolved
Here's asset holders query implementation. It somewhat depends on #154 in technical details regarding pagination, but all necessary parts are duplicated, so this PR can be merged first
We may want to add index on
assetcode
+issuer
fields intrustlines
table to speed things upThis change is![Reviewable](https://camo.githubusercontent.com/1541c4039185914e83657d3683ec25920c672c6c5c7ab4240ee7bff601adec0b/68747470733a2f2f72657669657761626c652e696f2f7265766965775f627574746f6e2e737667)