Skip to content
This repository has been archived by the owner on Jun 7, 2023. It is now read-only.

RFC: storage #47

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open

RFC: storage #47

wants to merge 2 commits into from

Conversation

louaykamel
Copy link

@louaykamel louaykamel commented Jul 29, 2020

@louaykamel louaykamel self-assigned this Jul 29, 2020
@louaykamel louaykamel changed the title RFC: storage RFC: storage Jul 29, 2020

#[cfg(feature = "rocks_db")]
pub struct Storage {
inner: ::rocksdb::DB // The storage backend
Copy link
Contributor

Choose a reason for hiding this comment

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

Perhaps it should be the inner field that has the feature flag?

Copy link
Author

Choose a reason for hiding this comment

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

Interesting, I agree it makes more sense.

/// It starts RocksDB instance and then initialize the required column familes
async fn start(config_path: String) -> Result<Self, Box<dyn Error>> {
let config_as_string = fs::read_to_string(config_path)?;
let config: config::Config = toml::from_str(&config_as_string)?;
Copy link
Contributor

Choose a reason for hiding this comment

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

Where is this Config type from? The config crate? If so, it might make more sense to have the config loading abstracted such that storage API users can customise it.

Copy link
Author

Choose a reason for hiding this comment

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

Yes it's already abstracted using feature, you can check that in storage branch.

)?;
Ok(())
}
async fn find_by_hash(hash: Hash, storage: &Storage) -> Result<Option<Self>, OpError> {
Copy link
Contributor

Choose a reason for hiding this comment

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

Hash should be passed by reference to avoid unnecessary cloning (I think Hash implements Deref<Trits> now, so you can just call .encode() on it directly.

Copy link
Author

Choose a reason for hiding this comment

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

Perfect, yeah I will force reference everywhere.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants