Skip to content
This repository has been archived by the owner on Jun 25, 2021. It is now read-only.

AD indices refactor #126

Closed
wants to merge 5 commits into from
Closed

Conversation

oetyng
Copy link
Contributor

@oetyng oetyng commented Nov 15, 2019

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 to Entries, Owners and Permissions.
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 be None when empty.
    --> Current item resides at current 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 the current item at the current index.

Not yet found use case for Previous and Next, but they are part of the convention in the following way:
From any index we refer to preceding and subsequent index as Previous and Next respectively.
From index 0, Previous is None. From Current index, Next is None.

IndicesConcept

Use unambiguous and consistent name referencing of indices.
REFERENCE: maidsafe#120
@oetyng oetyng changed the title Ad indices refactor AD indices refactor Nov 15, 2019
Copy link
Contributor

@mrcnski mrcnski left a 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.

@@ -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
Copy link
Contributor

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.

Copy link
Contributor Author

@oetyng oetyng Nov 15, 2019

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.

@oetyng oetyng requested a review from mrcnski November 15, 2019 22:02
mrcnski
mrcnski previously approved these changes Nov 16, 2019
Copy link
Contributor

@lionel-faber lionel-faber left a 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.

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.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
/// 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?

Copy link
Contributor Author

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.

@lionel-faber
Copy link
Contributor

Closing this since this data type is being replaced with Sequence and Map

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Adjust naming and docs to reflect actual index behaviour
3 participants