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

Refactor chain store types #144

Closed
wants to merge 5 commits into from
Closed

Refactor chain store types #144

wants to merge 5 commits into from

Conversation

dutterbutter
Copy link
Contributor

Changes introduced in this PR:

  • Added Read / Write traits for TipIndex similar to the key-value store
  • Included datastore in ChainStore
  • Added Chain struct to lib.rs

Not including the checkpoint type definitions as I think it's better to hold off on implementing until we have a clearer idea of how they are used with our verifier node.

Closes #116 , closes #81

* Added Read / Write traits for TipIndex similiar to key-value store
* Included rocksdb in ChainStore
Comment on lines +11 to +20
pub trait Write {
fn put(&mut self, meta: &TipSetMetadata) -> Result<(), Error>;
}

pub trait Read {
fn get(&self, key: u64) -> Result<TipSetMetadata, Error>;
fn get_tipset(&self, idx: &dyn Index) -> Result<Tipset, Error>;
fn get_tipset_state_root(&self, idx: &dyn Index) -> Result<Cid, Error>;
fn get_tipset_receipts_root(&self, idx: &dyn Index) -> Result<Cid, Error>;
}
Copy link
Contributor

Choose a reason for hiding this comment

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

what is the benefit to having these as traits? They will never need to be used ambiguously. If so, why do they need to be two seperate traits?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I suppose there no real benefit other than having our read and write operations set up similar to the way the datastore is set up for improved consistency.

Copy link
Contributor

Choose a reason for hiding this comment

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

I mean attaching these functions to a trait in any context, when would the implementation be swapped out?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Fair point. I can revert.

@@ -1,6 +1,15 @@
// Copyright 2020 ChainSafe Systems
// SPDX-License-Identifier: Apache-2.0

#![allow(dead_code)]
Copy link
Contributor

Choose a reason for hiding this comment

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

shouldn't need this?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Without it, the compiler complains that Chain is never constructed.

Copy link
Contributor

Choose a reason for hiding this comment

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

ahh gotcha, so I'm fine with this as is but why are you including this private struct before it is even used or without a constructor? Definitely alright if you remember to come back to it but could lead to bloated unused code if we do this a lot.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

The main reason its without a constructor is because of the lack of clarity of what should be included within this struct via the spec. Once we have established what should be included than I can include it. Within go-filecoin it is comprised of the following fields:

ChainStore
MessageStore
StateReadWriter
HeaviestTipSet
Consensus

However, we only have the ChainStore included thus far.

Comment on lines +7 to 8
pub use rocks::RocksDb;
pub use rocks::*;
Copy link
Contributor

Choose a reason for hiding this comment

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

Not sure why rust doesn't detect this is redundant, but only need to export the wildcard (only public is RocksDb)

@@ -1,6 +1,15 @@
// Copyright 2020 ChainSafe Systems
// SPDX-License-Identifier: Apache-2.0

#![allow(dead_code)]
Copy link
Contributor

Choose a reason for hiding this comment

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

ahh gotcha, so I'm fine with this as is but why are you including this private struct before it is even used or without a constructor? Definitely alright if you remember to come back to it but could lead to bloated unused code if we do this a lot.

@dutterbutter dutterbutter deleted the dustin/refactor branch January 22, 2020 14:56
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.

Implement Initial Chain Reader Trait Implementing Chain Types
2 participants