-
Notifications
You must be signed in to change notification settings - Fork 51
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
Convert coordinator/substrate/db to use create_db macro #436
Conversation
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.
All LGTM, minus a few minor nits :)
coordinator/src/substrate/db.rs
Outdated
LatestCosignedBlock: () -> u64, | ||
CosignTransactions: (network: NetworkId) -> Vec<(Session, u64, [u8; 32])>, | ||
BlockDb: () -> u64, | ||
EventDb: (id: &[u8], index: u32) -> [u8; 0], |
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.
-> ()
coordinator/src/substrate/mod.rs
Outdated
@@ -568,25 +568,25 @@ async fn handle_new_blocks<D: Db, Pro: Processors>( | |||
) | |||
.await?; | |||
*next_block += 1; | |||
db.set_next_block(*next_block); | |||
let mut txn = db.txn(); // TODO: this line belongs to a removed method, remove SubstrateDb |
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.
This TODO doesn't seem still needed.
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 was thinking about making it a helper but decided against it. I’ll investigate tonight. But I think you’re correct, the comment is old and can be removed if you have a moment.
4dbacf9
to
7e74785
Compare
91fe3b9
to
4b1a2b4
Compare
These may be rebase artifacts.
👍 Will merge once CI passes. Thanks :) |
Description
This is a continuation of pr #408.
SubstrateDb
was split intoBlockDb
,EventDb
,SessionDb
, andBatchDb
, some helper methods to convert to/from the expected type were removed as they're covered by the macro.Considerations
handled
was renamed tois_unhandled
. Calling code was largely in the formif !SubstrateDb::handled(...) { ... }
, removing the negation and changing the name helps align the code with the intent.handle_event
could be refactored into a simple set method, I noticed that the calling code often performs the necessary checks however I didn't feel comfortable making this change due to someasync
statements that could break the previous assertions.