kardiachain / kardia-explorer-backend

Backend repo for explorer
2 stars 7 forks source link

Check and update correct KRC20 balances of holders #105

Closed trinhdn97 closed 3 years ago

trinhdn97 commented 3 years ago

Fixes https://github.com/kardiachain/kardia-explorer-backend/issues/104

Type of change

ngdlong91 commented 3 years ago

also, please just implement logic which presents by its name https://github.com/kardiachain/kardia-explorer-backend/blob/267d9b15a5c5c56f999780d1727ba2cb4c9cbd8c/server/info.go#L880

So the logic in this flow look weird, you fetch ABI in base64 encoded from cache, then reupdate after decoded?

trinhdn97 commented 3 years ago

It should store the type of the contract if any. If the contract isn't belong to any contract type, its own ABI will be stored to cache.

I will fix and refactor the function name

ngdlong91 commented 3 years ago

It should store the type of the contract if any. If the contract isn't belong to any contract type, its own ABI will be stored to cache.

I will fix and refactor the function name

Store normal SMC ABI in cache is quite bad, imo. Rare usage, when schema design for contract contain a ABI column

trinhdn97 commented 3 years ago

Most of contracts' ABI will have a type, I store only the type to reduce redundant data. The ABI column in database design will be used to store contracts' ABI which doesn't belong to any type.

In cache, I also store one ABI of a type, for example: Key: SMCType:KRC20 - Value: <KRC20 ABI> Key: 0xCe7b4ecd9D0f1A06bB7DAbfdE718e00093D5b212 - Value: SMCType:KRC20 Key: 0x1935E466B027bBabA4aC73762B3D6005d32B3D63 - Value: SMCType:KRC20

Also, we should omit the ABI or Type column in Contracts collection if empty. I think storing data like this schema will optimize space.