Skip to content
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

td: Handle name changes. #723

Merged
merged 1 commit into from
Apr 17, 2023
Merged

td: Handle name changes. #723

merged 1 commit into from
Apr 17, 2023

Conversation

betterengineering
Copy link
Contributor

This commit updates the change name to try to use the To name first. Given we skip deletes, the to field should always be populated. The library code in question:

type Change struct {
	From ChangeEntry
	To   ChangeEntry
}

var empty ChangeEntry

// Action returns the kind of action represented by the change, an
// insertion, a deletion or a modification.
func (c *Change) Action() (merkletrie.Action, error) {
	if c.From == empty && c.To == empty {
		return merkletrie.Action(0),
			fmt.Errorf("malformed change: empty from and to")
	}

	if c.From == empty {
		return merkletrie.Insert, nil
	}

	if c.To == empty {
		return merkletrie.Delete, nil
	}

	return merkletrie.Modify, nil
}

This commit updates the change name to try to use the `To` name first.
Given we skip deletes, the to field should always be populated.
@betterengineering betterengineering enabled auto-merge (squash) April 17, 2023 15:50
@betterengineering betterengineering merged commit 18292b5 into main Apr 17, 2023
@betterengineering betterengineering deleted the mark/handle-renames branch April 17, 2023 15:51
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant