Skip to content
This repository has been archived by the owner on Dec 8, 2022. It is now read-only.

Hashes are stored in database as hex encoded binary instead of raw binary #42

Open
erikd opened this issue Aug 8, 2020 · 1 comment
Labels
bug Something isn't working

Comments

@erikd
Copy link
Member

erikd commented Aug 8, 2020

PostgreSQL is able to store binary strings and queries with display them sensibly as hex. Eg for the db-sync database:

cexplorer=# select * from pool_hash limit 5 ;
 id |                            hash                            
----+------------------------------------------------------------
  1 | \x153806dbcd134ddee69a8c5204e38ac80448f62342f8c23cfe4b7edf
  2 | \x0f292fcaa02b8b2f9b3c8f9fd8e0bb21abedb692a6d5058df3ef2735
  3 | \xc1ede3cc9133209466774d4826044e408db13d6fe6df751a73500f16
(3 rows)

The above hashes were stored as raw binary ByteString and Postgres just does the right thing.

By contrast, smash stores hashes in the database as hex encoded ByteStrings eg:

smash=# select id, pool_id from pool_metadata limit 3;
 id |                                                      pool_id                                                       
----+--------------------------------------------------------------------------------------------------------------------
  1 | \x3135333830366462636431333464646565363961386335323034653338616338303434386636323334326638633233636665346237656466
  2 | \x3066323932666361613032623862326639623363386639666438653062623231616265646236393261366435303538646633656632373335
  3 | \x6331656465336363393133333230393436363737346434383236303434653430386462313364366665366466373531613733353030663136

This is bad because query results take up twice as much real estate as the raw ByteString version and the hashes need to be hex decoded before they can be compared to values in the db-sync database.

@erikd erikd added the bug Something isn't working label Aug 8, 2020
@erikd
Copy link
Member Author

erikd commented Aug 8, 2020

Related to #37 .

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

1 participant