-
Notifications
You must be signed in to change notification settings - Fork 624
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
Implemented store module for near-network #7010
Conversation
&mut self, | ||
account_id: &AccountId, | ||
aa: &AnnounceAccount, | ||
) -> Result<(), Error> { |
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.
Debating whether store::Result<()>
alias would make sense 🤔
If many higher-level functions can only fail with store-related errors, it would be nice
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.
The fact that all the functions in a module return the same error type is a coincidence. In this particular implementation they effectively aggregate all the error variants, but I don't want it to be a rule.
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.
The fact that all the functions in a module return the same error type is a coincidence.
Not always: "the only way this can fail is due to error X
" can be a powerful architectural invariant to keep unwanted dependencies outside the module.
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.
"the only way this can fail is due to error Y, which is more specific than X" is an even more powerful invariant. It is terribly annoying when a function returns an error which has variants, which can never happen (and it is usually even documented that they never happen, but authors were too lazy to make the error more specific).
Also the invariant "the only way this can fail is due to error X" becomes architecturally useless (equivalent to anyhow::Error) as soon as it is possible to embed an arbitrary error in X (std::io::Error is a great example of that).
pub struct AccountAnnouncements; | ||
impl Column for AccountAnnouncements { | ||
const COL: DBCol = DBCol::AccountAnnouncements; | ||
type Key = AccountIdFormat; |
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.
nice !
/// methods writing to the DB. | ||
pub struct Store(schema::Store); | ||
|
||
impl Store { |
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.
consider calling it NetworkStore (makes it a lot easier to read - and less confusion with 'main' Store)
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.
NetworkStore is stuttering with the crate name. near_store::Store shouldn't be visible wherever store::Store is used (except for the moment of wrapping, but that's unavoidable).
7fd31e3
to
05186d4
Compare
cffc173
to
d788d6f
Compare
It consists of 2 layers: 1. schema definition layer - enforcing type-safe access to the DB columns 2. atomic access layer - defining all DB transactions, which are the high level operations that business logic can execute.
It consists of 2 layers: