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

Refactor API for clean separation of Mutable vs Immutable access to tree #88

Closed
UnitylChaos opened this issue Jul 19, 2018 · 2 comments
Closed
Assignees

Comments

@UnitylChaos
Copy link
Contributor

Refactor API to split functionality into mutable and immutable interfaces. This will enable read only snapshots to previously stored versions, (fixing #68, see also #87). With these changes, it will be possible to load read-only snapshots at previous versions on demand, and only load mutable trees at the most recently saved tree. This should speed up load times for trees with many versions, as we are currently loading each root into memory, which takes a linear number of database calls.

Steps:

  • Replace Tree with ImmutableTree
  • Merge VersionedTree and orphaningTree into MutableTree
  • Move mutable methods on Tree into MutableTree
  • Move recursive mutation methods on Node into MutableTree
  • Move recursive lookup methods on Node into ImmutableTree

High level overview of resulting interfaces:

MutableTree

  • tree *ImmutableTree
  • Load()
  • Set(key, value)
  • Remove(key)
  • Commit()
  • Rollback()
  • GetImmutable(version)
  • DeleteImmutable(version)

ImmutableTree

  • root *Node
  • Has(key)
  • Get(key)
  • GetWithProof(key)
  • GetByIndex(index)
  • IterateRange(start, end)
  • GetRangeWithProof(start, end)
  • Hash()
  • Size()
  • Version()

Node

  • isLeaf()
  • hash()
  • getLeftNode()
  • getRightNode()
@UnitylChaos UnitylChaos self-assigned this Jul 19, 2018
@silasdavis
Copy link
Contributor

Looks good to me, would be happy to help review

@liamsi
Copy link
Contributor

liamsi commented Jul 20, 2018

Great! Would very much appreciate your input @silasdavis!

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

No branches or pull requests

3 participants