本站源代码
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

35 lines
1.4KB

  1. /*
  2. Package merkletrie provides support for n-ary trees that are at the same
  3. time Merkle trees and Radix trees (tries).
  4. Git trees are Radix n-ary trees in virtue of the names of their
  5. tree entries. At the same time, git trees are Merkle trees thanks to
  6. their hashes.
  7. This package defines Merkle tries as nodes that should have:
  8. - a hash: the Merkle part of the Merkle trie
  9. - a key: the Radix part of the Merkle trie
  10. The Merkle hash condition is not enforced by this package though. This
  11. means that the hash of a node doesn't have to take into account the hashes of
  12. their children, which is good for testing purposes.
  13. Nodes in the Merkle trie are abstracted by the Noder interface. The
  14. intended use is that git trees implements this interface, either
  15. directly or using a simple wrapper.
  16. This package provides an iterator for merkletries that can skip whole
  17. directory-like noders and an efficient merkletrie comparison algorithm.
  18. When comparing git trees, the simple approach of alphabetically sorting
  19. their elements and comparing the resulting lists is too slow as it
  20. depends linearly on the number of files in the trees: When a directory
  21. has lots of files but none of them has been modified, this approach is
  22. very expensive. We can do better by prunning whole directories that
  23. have not change, just by looking at their hashes. This package provides
  24. the tools to do exactly that.
  25. */
  26. package merkletrie
上海开阖软件有限公司 沪ICP备12045867号-1