-
Notifications
You must be signed in to change notification settings - Fork 137
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
feat: allow constructing an AMT from an iterator or borrowed values. #1083
Conversation
Codecov Report
Additional details and impacted files@@ Coverage Diff @@
## master #1083 +/- ##
==========================================
+ Coverage 51.69% 51.80% +0.10%
==========================================
Files 125 125
Lines 10914 10928 +14
==========================================
+ Hits 5642 5661 +19
+ Misses 5272 5267 -5
|
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.
This ended up a lot cleaner than I expected!
ipld/amt/src/amt.rs
Outdated
D: fvm_ipld_encoding::serde_bytes::Deserializer<'de>, | ||
{ | ||
use serde::de::Error; | ||
Err(D::Error::custom("can't deserialize")) |
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.
"FakeDeserialize can't be deserialized"
/// Generates an AMT with block store and array of cbor marshallable objects and returns Cid | ||
/// | ||
/// This can be called with an iterator of _references_ to values to avoid copying. | ||
pub fn new_from_iter(block_store: BS, vals: impl IntoIterator<Item = V>) -> Result<Cid, 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.
Need the bitwidth here; that's another reason I couldn't use this method. Because event HAMTs are not mutable, I think it makes sense to optimise for lower depth, but curious about your opinion. I think a bitwidth of 5 or 8 makes the most sense here?
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.
Depends on the max serialized size of an event, really.
This works because we never have to read or deserialize when creating an AMT from scratch.
760435b
to
f865fd9
Compare
f865fd9
to
aeed415
Compare
This works because we never have to read or deserialize when creating an AMT from scratch.
Most of the code changes are actually just re-arranging the implementation into three sections:
V: DeserializeOwned
requirement.