-
Notifications
You must be signed in to change notification settings - Fork 266
Conversation
Codecov Report
@@ Coverage Diff @@
## develop #79 +/- ##
===========================================
+ Coverage 79.35% 80.32% +0.96%
===========================================
Files 13 13
Lines 499 549 +50
===========================================
+ Hits 396 441 +45
- Misses 103 108 +5
Continue to review full report at Codecov.
|
core/src/chain/entry.rs
Outdated
|
||
// @TODO do NOT serialize entry_type in Entry as it should only be in Header | ||
// @see https://github.com/holochain/holochain-rust/issues/80 | ||
entry_type: String, | ||
} | ||
|
||
impl _Hash for Entry { |
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.
Since the standard Hash
trait doesn't clash with anything in this context, could you remove the alias for now?
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.
it clashes with Entry::hash()
doesn't it?
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.
It shouldn't. Not in this particular context.
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.
@sphinxc0re it causes recursion issues if i try self.hash()
but i can drop the alias, check out the latest commit
@@ -24,7 +24,7 @@ pub struct Header { | |||
signature: String, | |||
} | |||
|
|||
impl _Hash for Header { | |||
impl Hash for Header { |
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.
You could just #[derive(Hash)]
this.
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.
let's continue this in #20
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.
Nice work. You inspire me in the thoroughness of your tests.
// same type different content is not equal | ||
assert_ne!(Entry::new(t1, c1), Entry::new(t1, c2)); | ||
|
||
// same content different type is equal |
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 deserves a little bit more in the comment to explain why, because at first glance you might think not. The reason is that what's hashed is JUST the content. i.e. the type is just a convenience value for the implementation, not part of what's getting hashed.
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.
heh, i'm not even sure if this is desirable behaviour!
part of the reason for writing this test was to highlight something unintuitive about the code :/
i opened up #85 because intuitively the hash of an entry, and also its concept of equality, would contain its type
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.
#73
this diverges from the legacy golang code which has fn signatures looking like this:
which is analogous to our
chain.push()
trait method in rust.the limitations of the go version, that i see:
prepareHeader
is even worsepush()
time? @zippy can probably provide more context here.changes:
Entry::new()
Entry::new("content")
new:Entry::new("type", "content")
chain.push("type", Entry::new("content"))
new:chain.push(Entry::new("type", "content"))
pros:
push
timenew()
callchain.push()
time
as well, locking down time at the actual Entry creation timecons: