Conversation
Use unambiguous and consistent name referencing of indices. REFERENCE: maidsafe#120
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.
Looks great!
I just noticed that the documentation in append_only_data.rs
is not generated by cargo doc
, because it is a private module! I'll write an issue about that.
src/append_only_data.rs
Outdated
@@ -581,7 +596,7 @@ macro_rules! impl_appendable_data { | |||
self.inner.permissions.get(index) | |||
} | |||
|
|||
/// Returns the owner's public key and the indices at the time it was added. | |||
/// Returns the owner's public key and the indices at the time it was added. // <--- confusing docs |
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'm not sure if you meant to commit this, but won't this comment appear in the public documentation for this function? I would say either move it into a separate TODO:
comment or just address it 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.
I did not actually, I'm sorry it slipped through. It was a note to myself to get to the bottom with what it meant. It can be removed.
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.
Great work with this @oetyng !
Just one small comment.
src/append_only_data.rs
Outdated
if owner.entries_index != self.entries_index() { | ||
return Err(Error::InvalidSuccessor(self.entries_index())); | ||
/// If the specified `expected_index` does not equal | ||
/// the count of owners index, an error will be returned. |
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.
/// the count of owners index, an error will be returned. | |
/// the count of owners, an error will be returned. |
Do you think we should change this as well?
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.
Absolutely, I'll do the change.
Closing this since this data type is being replaced with |
Use unambiguous and consistent name referencing of indices.
Closes: #120
This introduces an
AppendOnlyData
indices naming convention, as to avoid confusion and simplify in all repos and on all levels. Applies toEntries
,Owners
andPermissions
.The goal is to never mix-up what current, next, last index means or refers to, because it does lead to bugs and issues (like off by one error).
Index naming convention
Current
-> the index where the last item in the collection is. Can beNone
when empty.-->
Current item
resides atcurrent index
.Expected
-> the index that is expected to be current when adding an item, the index where additions are expected.--> A new item to be appended, will then reside at what is now the
expected index
. After it is appended, it is thecurrent item
at thecurrent index
.Not yet found use case for
Previous
andNext
, but they are part of the convention in the following way:From any index we refer to preceding and subsequent index as
Previous
andNext
respectively.From index 0,
Previous
isNone
. FromCurrent
index,Next
isNone
.