Skip to content

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

@UnitylChaos

Description

@UnitylChaos

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()

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions