-
Notifications
You must be signed in to change notification settings - Fork 79
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
Initial implementation of new, more convenient Map wrapping HAMT #1349
Conversation
@Stebalien can you help me figure out how to take the key as a reference? I was hoping to simplify callers by setting the key type as |
a7b581f
to
f2c6bfc
Compare
Codecov Report
Additional details and impacted files@@ Coverage Diff @@
## master #1349 +/- ##
==========================================
+ Coverage 90.19% 90.72% +0.53%
==========================================
Files 144 145 +1
Lines 27457 27427 -30
==========================================
+ Hits 24764 24884 +120
+ Misses 2693 2543 -150
|
b33527f
to
aa0f2b4
Compare
beed0f4
to
d1b003a
Compare
runtime/src/util/map.rs
Outdated
K: MapKey, | ||
V: DeserializeOwned + Serialize, | ||
{ | ||
hamt: hamt::Hamt<&'bs BS, V, hamt::BytesKey, Hasher>, |
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.
nit: I'd make this own the underlying blockstore. There's a blanket Blockstore for &Blockstore
impl anyways.
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.e., even if it owns the blockstore, you can still use Map2<&SomeBS, ...>
.
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.
Done
runtime/src/util/map.rs
Outdated
|
||
impl MapKey for u64 { | ||
fn from_bytes(b: &[u8]) -> Result<Self, String> { | ||
let (v, _) = unsigned_varint::decode::u64(b).map_err(|e| e.to_string())?; |
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 validate that b
doesn't contain any extra bytes.
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.
Done
Work towards #1346, as well as a general improvement in noisy code.