dcrdata icon indicating copy to clipboard operation
dcrdata copied to clipboard

support searches for partial strings

Open raedah opened this issue 6 years ago • 3 comments

When doing a search, accept any string as the search term, and return a list of block hashes, transaction hashes, and addresses, etc (all objects) that contain the search term.

raedah avatar Jul 01 '18 19:07 raedah

I had though about this and I'm concerned that if we don't take extra care, we'll be creating a really easy way to load the server.

chappjc avatar Jul 03 '18 14:07 chappjc

Came to my mind that we could support this for just some recent set. Such as mempool, recent X blocks, or recent X transactions. Could test out the capability and leave X set at some number that would not cause any problems. Goal would be to make it easier for users to find some recent transaction id sent on another device without having to type the whole string in.

raedah avatar Oct 09 '19 19:10 raedah

Still make sense to me. I can see that with addresses too. e.g. "Dcur2" as a search string:

select distinct(address) from addresses where address like 'Dcur2%';

That kind of query is just much more expensive since the address column index isn't usable.

And then there's the need to handle ambiguous results.

# select tx_hash from transactions where tx_hash like '1da8328455d7d620036d3%';
                             tx_hash                              
------------------------------------------------------------------
 1da8328455d7d620036d3d8a72923ff934c802b2a332a368518c1d11287ad73c
(1 row)

# select tx_hash from transactions where tx_hash like '1da83%';
                             tx_hash                              
------------------------------------------------------------------
 1da83a3718c63facb17c63895705552c4d862a2a1c85c7ac2d74d9d8a5ee6993
 1da83cfc5d9ac91c097726472a40c658c938b07a0b7d3a23f48af573c9f79b09
 1da8300fcf0a2b5149bad0839622a249cfdf9947941fa2061ce9f85efaf79b31
 1da83c19b09355fac94a541cc704b365722ce70144f46e3326786265558130d7
 1da8337274ff8a34df7e13448c6b77987c772d87bdcefd115a6942e46a426a24
 1da8328455d7d620036d3d8a72923ff934c802b2a332a368518c1d11287ad73c
(6 rows)

This can all be done, but it's going to take a clear plan to cover the edge cases and prevent excessive CPU usage that opens the door to an attack.

chappjc avatar Oct 09 '19 19:10 chappjc

This can all be done, but it's going to take a clear plan to cover the edge cases and prevent excessive CPU usage that opens the door to an attack.

@chappjc, what's the way forward with this?

ukane-philemon avatar Dec 26 '22 02:12 ukane-philemon