* Start codec implementation * Expose all constants * NodeHeader encoding/decoding * Encoding in NodeHeader * Constants for Node types * Moce codec to trie-codec * Encode/decode in place (untested) * WIP, tests starting to be put in place * One passing test :) * Another test bites the dust... * One more test down... * One more down * Additional tests * Formatting * Long keys passing * Trie tests * Follow the script, no all-in-all encoder * First simple trie test passing * Another one down * Extra checks remove (debug) * 80% there with tests... * One more, one left * Trie tests passing * ISC -> Apache-2.0 * Add compact util functions * Tests to TypeScript * Remove @polkadot/types deps, ethereum stub * Bump * Genesis tests with chainspecs * Cleanup tests (ease of debugging) * Substrate test passes, branch fails (again) * Checks passing, tests passing * Re-add Ethereum & snapshot tests (not passing atm) * Re-add index test (also not 100%) * Mid-way in generic trie-root * Cleanup ethereumjs-testing definitions * Update deps * Less intrusive renames in trie-hash * Self-review cleanups #1 * asNibbles -> toNibbles * Cleanups * Expand tests * Cleanup imports * Fix logger test (fly-by refactor) * Update snapshot test
34 lines
1.2 KiB
Markdown
34 lines
1.2 KiB
Markdown
# @polkadot/trie-db
|
|
|
|
A re-implementation of a Patricia Trie. Unlike other implementations, this allows for the specification of a hash function as well as encoder/decoder and operates in a sync fashion by default.
|
|
|
|
This is a JavaScript port of the [Python Ethereum Trie](https://github.com/ethereum/py-trie) with additions to support transactions (checkpoints) and multiple codecs, by default only the Substrate codec.
|
|
|
|
## Usage
|
|
|
|
Installation -
|
|
|
|
```
|
|
yarn add @polkadot/trie-db
|
|
```
|
|
|
|
Classes can be imported as follows:
|
|
|
|
```js
|
|
import Trie from '@polkadot/trie-db'; // Default export
|
|
```
|
|
|
|
## Documentation and Available Utilities
|
|
|
|
Below is a list of currently exposed methods published at the [Polkadot-JS Common Documentation Portal](https://polkadot.js.org/common/trie-db/).
|
|
|
|
- [trie-db](https://polkadot.js.org/common/trie-db/README.md)
|
|
- Classes
|
|
- [Trie](https://polkadot.js.org/common/trie-db/classes/_index_.trie.md)
|
|
- Functions
|
|
- Util
|
|
- [is](https://polkadot.js.org/common/trie-db/modules/_util_is_.md)
|
|
- [key](https://polkadot.js.org/common/trie-db/modules/_util_key_.md)
|
|
- [nibbles](https://polkadot.js.org/common/trie-db/modules/_util_nibbles_.md)
|
|
- [node](https://polkadot.js.org/common/trie-db/modules/_util_node_.md)
|