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

substrate: return Option in all storage related RPC methods #510

Merged
merged 4 commits into from
Aug 8, 2018

Conversation

andresilva
Copy link
Contributor

Fix #508.

@andresilva andresilva added A0-please_review Pull request needs code review. M6-rpcapi labels Aug 8, 2018
@parity-cla-bot
Copy link

It looks like @andresilva signed our Contributor License Agreement. 👍

Many thanks,

Parity Technologies CLA Bot

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))
Copy link
Contributor Author

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).

Copy link
Contributor

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")

Copy link
Contributor Author

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?

Copy link
Contributor

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

@pepyakin pepyakin added A8-looksgood and removed A0-please_review Pull request needs code review. labels Aug 8, 2018
@pepyakin pepyakin merged commit 23ba290 into master Aug 8, 2018
@pepyakin pepyakin deleted the andre/option-storage-methods branch August 8, 2018 15:46
dvdplm added a commit that referenced this pull request Aug 9, 2018
* 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)
gavofyork pushed a commit that referenced this pull request Aug 10, 2018
* 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
liuchengxu pushed a commit to autonomys/substrate that referenced this pull request Jun 3, 2022
helin6 pushed a commit to boolnetwork/substrate that referenced this pull request Jul 25, 2023
* add system_health rpc

* fmt
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.

4 participants