Skip to content
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

Support addresses filter for transaction search #3511

Closed
faustbrian opened this issue Feb 17, 2020 · 3 comments
Closed

Support addresses filter for transaction search #3511

faustbrian opened this issue Feb 17, 2020 · 3 comments

Comments

@faustbrian
Copy link
Contributor

When using the addresses filter for the /api/transactions/search endpoint you would expect that multi payments are also shown based on their recipients. That's not the case because the only searches that are performed are on the recipientId and senderPublicKey columns while the recipients for a multi payment are in the asset column.

if (params.addresses) {
    if (!params.recipientId) {
        params.recipientId = params.addresses;
    }

    if (!params.senderPublicKey) {
        params.senderPublicKey = params.addresses.map(address => {
            return this.getPublicKeyFromAddress(address);
        });
    }

    delete params.addresses;
}

The query needs to be extended to also look up recipients through asset->payments->*->recipient. These kind of queries are very expensive on large databases and need to be properly benchmarked before being released into production.

@faustbrian
Copy link
Contributor Author

faustbrian commented Feb 17, 2020

A simple query like the following will suffice to get this working without too much of a performance hit.

SELECT id FROM transactions WHERE type = 6 AND asset->>'payments' like '%AJ97QsBNxYr4UAWdoKP2DStDCHAJGirmSM%' LIMIT 1;

Using the type is important because the query otherwise will be very slow. The reason for that is that the type column has an index while asset doesn't.

@faustbrian faustbrian added this to the 3.0.0 milestone May 3, 2020
@faustbrian
Copy link
Contributor Author

Implemented in 3.0

@rainydio
Copy link
Contributor

rainydio commented May 5, 2020

It's implemented not as separate addresses filter. Wallet api controller filters transactions using three expressions (joined with OR):

  • ...filter_from_request AND recipientId = :wallet_address
  • ...filter_from_request AND asset @> :payment_with_wallet_address
  • ...filter_from_request AND sender_public_key = :wallet_public_key (if public key is known)

https://github.com/ArkEcosystem/core/blob/develop/packages/core-api/src/controllers/wallets.ts#L50-L57

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants