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

feat(db): initialize db with tables #13130

Merged

Conversation

alessandromazza98
Copy link
Contributor

crates/cli/commands/src/common.rs Outdated Show resolved Hide resolved
crates/storage/db-api/src/table.rs Outdated Show resolved Hide resolved
crates/storage/db/src/implementation/mdbx/mod.rs Outdated Show resolved Hide resolved
type TableIter: Iterator<Item = Box<dyn TableMetadata>>;

/// Returns an iterator over the tables.
fn tables() -> Self::TableIter;
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this can just return Boxed iter of Table instead, no need for the associated type

Copy link
Contributor Author

@alessandromazza98 alessandromazza98 Dec 5, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

you mean directly using Box<dyn Iterator<Item = Box<dyn TableMetadata>>> as return type for the tables function and remove the TableIter associated type?

Copy link
Contributor Author

@alessandromazza98 alessandromazza98 Dec 5, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

or it could be like this:

pub trait TableSet {
    /// Returns an iterator over the tables
    fn tables() -> Box<dyn Iterator<Item = Box<dyn TableMetadata>>>;
}

and then the impl inside the tables! macro:

impl TableSet for Tables {
    fn tables() -> Box<dyn Iterator<Item = Box<dyn TableMetadata>>> {
        Box::new(Self::ALL.iter().map(|table| Box::new(*table) as Box<dyn TableMetadata>))
    }
}

crates/storage/db-api/src/table.rs Outdated Show resolved Hide resolved
Copy link
Collaborator

@mattsse mattsse left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

some suggestions

crates/storage/db-api/src/table.rs Outdated Show resolved Hide resolved
crates/storage/db/src/implementation/mdbx/mod.rs Outdated Show resolved Hide resolved
crates/storage/db-api/src/table.rs Outdated Show resolved Hide resolved
Copy link
Collaborator

@mattsse mattsse left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

lgtm

next step would be repeating the same thing for functions that call create_tables, like

https://github.com/paradigmxyz/reth/blob/main/crates/storage/db/src/mdbx.rs#L31-L39

essentially walking up the call graph

@mattsse mattsse enabled auto-merge December 6, 2024 16:12
@mattsse mattsse added the A-db Related to the database label Dec 6, 2024
@mattsse mattsse added this pull request to the merge queue Dec 6, 2024
Merged via the queue into paradigmxyz:main with commit 627ceae Dec 6, 2024
41 checks passed
@alessandromazza98
Copy link
Contributor Author

alessandromazza98 commented Dec 6, 2024

lgtm

next step would be repeating the same thing for functions that call create_tables, like

https://github.com/paradigmxyz/reth/blob/main/crates/storage/db/src/mdbx.rs#L31-L39

essentially walking up the call graph

great, im gonna work on it

@alessandromazza98 alessandromazza98 deleted the ale/initialize-db-with-tables branch December 9, 2024 13:50
@alessandromazza98 alessandromazza98 restored the ale/initialize-db-with-tables branch December 9, 2024 13:50
@alessandromazza98 alessandromazza98 deleted the ale/initialize-db-with-tables branch December 9, 2024 13:50
lean-apple pushed a commit to lean-apple/reth that referenced this pull request Dec 12, 2024
Co-authored-by: Matthias Seitz <matthias.seitz@outlook.de>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-db Related to the database
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants