-
Notifications
You must be signed in to change notification settings - Fork 2.6k
substrate: return Option in all storage related RPC methods #510
Conversation
It looks like @andresilva signed our Contributor License Agreement. 👍 Many thanks, Parity Technologies CLA Bot |
substrate/client/src/client.rs
Outdated
pub fn code_at(&self, id: &BlockId<Block>) -> error::Result<Vec<u8>> { | ||
self.storage(id, &StorageKey(b":code".to_vec())).map(|data| data.0) | ||
pub fn code_at(&self, id: &BlockId<Block>) -> error::Result<Option<Vec<u8>>> { | ||
Ok(self.storage(id, &StorageKey(b":code".to_vec()))?.map(|data| data.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.
Can we expect this key to always exist? (even if set to empty).
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.
Yeah, definitely. Under this key the code of the runtime is stored.
For example, here is a genesis storage for krummelanke (Key 0x3a636f6465
is actually stands for ":code")
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.
Should I call expect
here and return Result<Vec<u8>>
instead?
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 would answer "yes". Personally, I don't see any legal use-cases for it to be None
* master: README: fixed typo in docker run command (#518) Merge *_at methods. (#515) New flags to listen to all interfaces (#495) If contract reaches max depth, return Err (#503) Some networking cleanups (#504) Derivable Encode & Decode (#509) substrate: return Option in all storage related RPC methods (#510) Build with locked Cargo.lock on CI (#514) Place call data into a newly allocated pages (#502)
* substrate: return Option in all storage related RPC methods * substrate: remove unused imports * substrate: remove unused NoValueForKey error variant * substrate: don't return Option on code_at since code is always defined
Set import granularity for rustfmt
* add system_health rpc * fmt
Fix #508.