Conversation
dc6ea74 to
fa92ea9
Compare
fa92ea9 to
dca3ddb
Compare
nebolsin
left a comment
There was a problem hiding this comment.
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?
charlie-wasp
left a comment
There was a problem hiding this comment.
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/>= balanceand also introduce strict condition onaccountidfrom 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
balancesfor better consistency with the result data type andAccountside.
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
AssetandAssetWithInfo. And by the way, do we still need those two separate types? Looks like theAssettype andAssetIDscalar 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
beforeparam 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
nebolsin
left a comment
There was a problem hiding this comment.
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+issuerfields intrustlinestable to speed things upThis change is