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

Attempt to get rid of macros in chainstate storage #1233

Merged
merged 6 commits into from
Sep 27, 2023

Conversation

TheQuantumPhysicist
Copy link
Collaborator

@TheQuantumPhysicist TheQuantumPhysicist commented Sep 25, 2023

Unfortunately, the biggest culprit here is the Schema trait impls.

In struct impls, many trait bounds can be detected automatically. But then in traits, all these trait bounds have to be specified manually. To some degree I'm OK with that, but then when this trait bound is required:

57  |         K: EncodeLike<DbMap::Key>, (DBValue, (DBBlock, (DBBlockIndex, (DBTxIndex, (DBBlockByHeight, (DBUtxo, (DBUtxosBlockUndo, (DBEpochData, (DBTokensAuxData, (DBIssuanceTxVsTokenId, (DBAccountNonceCount, (DBAccountingBlockUndo, (DBAccountingEpochDelta, (DBAccountingEpochDeltaUndo, (DBAccountingPoolDataTip, (DBAccountingPoolBalancesTip, (DBAccountingDelegationDataTip, (DBAccountingDelegationBalancesTip, (DBAccountingPoolDelegationSharesTip, (DBAccountingPoolDataSealed, (DBAccountingPoolBalancesSealed, (DBAccountingDelegationDataSealed, (DBAccountingDelegationBalancesSealed, (DBAccountingPoolDelegationSharesSealed, ())))))))))))))))))))))))): HasDbMap<DbMap, I>

That basically makes it infeasible to do it.

So, what I did was that I factored out some of the repetitive code, but the basis is already factored out in read and read_value functions. So these calls are repeated, but it's minimal.

At least my IDE recognizes these functions and their contents now and they're readable and parsable.

Let me know what you think.


Edit: I seem to have forgotten to mentioned my original plan..

So my original plan was to use the MakeMapRef trait that I created to abstract getting the database map proxy, but then this failed because all the trait bounds are leaked to the trait implementing these properties due to the schema complexity.

@TheQuantumPhysicist TheQuantumPhysicist merged commit e7f1349 into master Sep 27, 2023
23 checks passed
@TheQuantumPhysicist TheQuantumPhysicist deleted the fix/less_macros_storage branch September 27, 2023 09:41
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

Successfully merging this pull request may close these issues.

None yet

3 participants