-
Notifications
You must be signed in to change notification settings - Fork 1.1k
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
Add in Deposit Map To Cache #9885
Conversation
@@ -54,6 +53,7 @@ type DepositCache struct { | |||
pendingDeposits []*dbpb.DepositContainer | |||
deposits []*dbpb.DepositContainer | |||
finalizedDeposits *FinalizedDeposits | |||
depositMap map[[48]byte][]*dbpb.DepositContainer |
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 will argue that if we always only going to return the first deposit, we dont need a list for value. But i think extensibility is nice, maybe we'll need DepositsByPubkey
one day
@@ -54,6 +53,7 @@ type DepositCache struct { | |||
pendingDeposits []*dbpb.DepositContainer | |||
deposits []*dbpb.DepositContainer | |||
finalizedDeposits *FinalizedDeposits | |||
depositMap map[[48]byte][]*dbpb.DepositContainer |
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.
We tend to avoid giving variables names related to their type in Go. This doesn't tell us much about what the keys in the map are, so maybe we can call it depositsByPubKey
What type of PR is this?
Bug Fix
What does this PR do? Why is it needed?
For our validator rpc methods, a lot of them require knowledge on a particular validator's deposit. If the validator
isn't active yet we have to perform a large search through all our deposits. Adding a map brings this down to
O(1)
fromO(n)
per validator.Fix and add relevant tests.
Which issues(s) does this PR fix?
N.A
Other notes for review