-
Notifications
You must be signed in to change notification settings - Fork 22
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
feature/ethereum refactor accounts table #983
Conversation
…ory and transactions tables
30b7a4d
to
1923764
Compare
…factor-accounts-table
implicit ec: ExecutionContext | ||
): DBIOAction[List[Unit], NoStream, Effect.Read with Effect.Write with Effect.Transactional] = { | ||
import tech.cryptonomic.conseil.common.sql.CustomProfileExtension.api._ | ||
DBIO.sequence( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Maybe I don't understand something, but why didn't you use something like this: Tables.Accounts.insertOrUpdateAll(accounts.map(_.convertTo[Tables.AccountsRow]))
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Basically I want to update Account with the latest data (blockHash, blockNumber, timestamp, balance)
without overwriting contract/token data (bytecode, bytecode_hash, token_standard, name, symbol, decimals, total_supply)
That's why I take the existing row, update a subset of fields and write the updated row to DB
*/ | ||
def createTokens(tokens: List[Token]) = | ||
def createAccountBalances(accounts: List[Account]): DBIOAction[Unit, NoStream, Effect.Write] = |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I believe this also works - a bit cleaner:
def createAccountBalances(accounts: List[Account]): DBIO[Option[Int]] =
Tables.AccountsHistory ++= accounts.map(_.convertTo[Tables.AccountsHistoryRow])
*/ | ||
def createContracts(contracts: List[Contract]) = | ||
def createContractAccounts(contractAccounts: List[Account]): DBIOAction[Unit, NoStream, Effect.Write] = |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
can you refactor this like in example for createAccountBalances
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
added few comments regarding simplification in ETH persistence, but besides that it looks ok
Kudos, SonarCloud Quality Gate passed! 0 Bugs No Coverage information |
To be merged to master after #981
This PR brings a number of ethereum improvements:
(block_hash, block_number, timestamp)
wherever necessarylog_index
totoken_transfers
table for orderingaccounts
table to contain account, contract and token dataaccounts_history
table for temporal queries along with accounts_history endpointcontracts
andtokens
as views ofaccounts
tabletokenStandard
instead ofisERC20
andisERC721
fields