-
Notifications
You must be signed in to change notification settings - Fork 2.6k
Embed runtime version as a custom section #8688
Changes from 3 commits
217a874
259d06a
03eea2b
d4a3038
ceced97
422363a
76f6c37
53ffc97
866b13f
0f13caa
93f2036
78fb99e
84c63c0
d0ec418
1621d6c
689116a
bc41d06
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
| Original file line number | Diff line number | Diff line change | ||||||||
|---|---|---|---|---|---|---|---|---|---|---|
|
|
@@ -85,9 +85,24 @@ impl RuntimeBlob { | |||||||||
| }) | ||||||||||
| } | ||||||||||
|
|
||||||||||
| /// Scans the wasm blob for the first section with the name that matches the given. Returns the | ||||||||||
| /// contents of the custom section if found or `None` otherwise. | ||||||||||
| pub fn custom_section_contents(&self, section_name: &str) -> Option<&[u8]> { | ||||||||||
| self.raw_module | ||||||||||
| .custom_sections() | ||||||||||
| .filter(|cs| cs.name() == section_name) | ||||||||||
| .next() | ||||||||||
| .map(|cs| cs.payload()) | ||||||||||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I am not entirely sure how would that work. Currently, this code takes an iterator of custom sections, leaves only sections that we are interested in, takes the first one which gives us an option and then we narrow the contents of this section to only its payload. But in the proposed version the result seems to be not an option
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Maybe I can introduce you to: https://doc.rust-lang.org/std/primitive.bool.html#method.then ;)
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. TIL. This however misses the point, if I understand you correctly. The problem is the expression in the proposed code is typed as
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
We can simplify the code to We could use a |
||||||||||
| } | ||||||||||
|
|
||||||||||
| /// Consumes this runtime blob and serializes it. | ||||||||||
| pub fn serialize(self) -> Vec<u8> { | ||||||||||
| serialize(self.raw_module) | ||||||||||
| .expect("serializing into a vec should succeed; qed") | ||||||||||
| } | ||||||||||
|
|
||||||||||
| /// Destruct this structure into the underlying parity-wasm Module. | ||||||||||
|
pepyakin marked this conversation as resolved.
Outdated
|
||||||||||
| pub fn into_inner(self) -> RawModule { | ||||||||||
| self.raw_module | ||||||||||
| } | ||||||||||
| } | ||||||||||
Uh oh!
There was an error while loading. Please reload this page.