[CI Skip] 0.32.4
This commit is contained in:
@@ -0,0 +1,38 @@
|
||||
|
||||
@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 hashing (npot only Keccak, but also Blake2 as found in Polkadot).
|
||||
|
||||
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)
|
||||
|
||||
@@ -0,0 +1,10 @@
|
||||
* ["constants"](modules/_constants_.md)
|
||||
* ["index"](modules/_index_.md)
|
||||
* [Trie](classes/_index_.trie.md)
|
||||
* ["types"](modules/_types_.md)
|
||||
* [NodeType](enums/_types_.nodetype.md)
|
||||
* [TrieDb](interfaces/_types_.triedb.md)
|
||||
* ["util/is"](modules/_util_is_.md)
|
||||
* ["util/key"](modules/_util_key_.md)
|
||||
* ["util/nibbles"](modules/_util_nibbles_.md)
|
||||
* ["util/node"](modules/_util_node_.md)
|
||||
@@ -0,0 +1,307 @@
|
||||
|
||||
|
||||
@polkadot/common/trie-db
|
||||
========================
|
||||
|
||||
Overview
|
||||
--------
|
||||
*__name__*: Trie
|
||||
|
||||
*__summary__*: Re-implementation of a Patricia Trie
|
||||
|
||||
*__example__*: See [Polkadot-JS Common Trie-DB Examples](https://polkadot.js.org/api/common/examples/trie-db/)
|
||||
|
||||
# Hierarchy
|
||||
|
||||
**Trie**
|
||||
|
||||
# Implements
|
||||
|
||||
* [TrieDb](../interfaces/_types_.triedb.md)
|
||||
|
||||
# Constructors
|
||||
|
||||
<a id="constructor"></a>
|
||||
|
||||
## constructor
|
||||
|
||||
⊕ **new Trie**(db?: *`TxDb`*, rootHash?: *`Uint8Array`*): [Trie](_index_.trie.md)
|
||||
|
||||
*Defined in [index.ts:33](https://github.com/polkadot-js/common/blob/1fb1f9d/packages/trie-db/src/index.ts#L33)*
|
||||
|
||||
**Parameters:**
|
||||
|
||||
| Param | Type | Default value |
|
||||
| ------ | ------ | ------ |
|
||||
| `Optional` db | `TxDb` | - |
|
||||
| `Default value` rootHash | `Uint8Array` | EMPTY_HASH |
|
||||
|
||||
**Returns:** [Trie](_index_.trie.md)
|
||||
|
||||
___
|
||||
|
||||
# Properties
|
||||
|
||||
<a id="db"></a>
|
||||
|
||||
## db
|
||||
|
||||
**● db**: *`TxDb`*
|
||||
|
||||
*Implementation of [TrieDb](../interfaces/_types_.triedb.md).[db](../interfaces/_types_.triedb.md#db)*
|
||||
|
||||
*Defined in [index.ts:31](https://github.com/polkadot-js/common/blob/1fb1f9d/packages/trie-db/src/index.ts#L31)*
|
||||
|
||||
___
|
||||
|
||||
# Methods
|
||||
|
||||
<a id="close"></a>
|
||||
|
||||
## close
|
||||
|
||||
▸ **close**(): `void`
|
||||
|
||||
*Implementation of [TrieDb](../interfaces/_types_.triedb.md).[close](../interfaces/_types_.triedb.md#close)*
|
||||
|
||||
*Defined in [index.ts:81](https://github.com/polkadot-js/common/blob/1fb1f9d/packages/trie-db/src/index.ts#L81)*
|
||||
|
||||
**Returns:** `void`
|
||||
|
||||
___
|
||||
<a id="del"></a>
|
||||
|
||||
## del
|
||||
|
||||
▸ **del**(key: *`Uint8Array`*): `void`
|
||||
|
||||
*Implementation of [TrieDb](../interfaces/_types_.triedb.md).[del](../interfaces/_types_.triedb.md#del)*
|
||||
|
||||
*Defined in [index.ts:105](https://github.com/polkadot-js/common/blob/1fb1f9d/packages/trie-db/src/index.ts#L105)*
|
||||
|
||||
**Parameters:**
|
||||
|
||||
| Param | Type |
|
||||
| ------ | ------ |
|
||||
| key | `Uint8Array` |
|
||||
|
||||
**Returns:** `void`
|
||||
|
||||
___
|
||||
<a id="drop"></a>
|
||||
|
||||
## drop
|
||||
|
||||
▸ **drop**(): `void`
|
||||
|
||||
*Implementation of [TrieDb](../interfaces/_types_.triedb.md).[drop](../interfaces/_types_.triedb.md#drop)*
|
||||
|
||||
*Defined in [index.ts:89](https://github.com/polkadot-js/common/blob/1fb1f9d/packages/trie-db/src/index.ts#L89)*
|
||||
|
||||
**Returns:** `void`
|
||||
|
||||
___
|
||||
<a id="empty"></a>
|
||||
|
||||
## empty
|
||||
|
||||
▸ **empty**(): `void`
|
||||
|
||||
*Implementation of [TrieDb](../interfaces/_types_.triedb.md).[empty](../interfaces/_types_.triedb.md#empty)*
|
||||
|
||||
*Defined in [index.ts:85](https://github.com/polkadot-js/common/blob/1fb1f9d/packages/trie-db/src/index.ts#L85)*
|
||||
|
||||
**Returns:** `void`
|
||||
|
||||
___
|
||||
<a id="get"></a>
|
||||
|
||||
## get
|
||||
|
||||
▸ **get**(key: *`Uint8Array`*): `Uint8Array` | `null`
|
||||
|
||||
*Implementation of [TrieDb](../interfaces/_types_.triedb.md).[get](../interfaces/_types_.triedb.md#get)*
|
||||
|
||||
*Defined in [index.ts:116](https://github.com/polkadot-js/common/blob/1fb1f9d/packages/trie-db/src/index.ts#L116)*
|
||||
|
||||
**Parameters:**
|
||||
|
||||
| Param | Type |
|
||||
| ------ | ------ |
|
||||
| key | `Uint8Array` |
|
||||
|
||||
**Returns:** `Uint8Array` | `null`
|
||||
|
||||
___
|
||||
<a id="getnode"></a>
|
||||
|
||||
## getNode
|
||||
|
||||
▸ **getNode**(hash?: *`Uint8Array`*): [Node](../modules/_types_.md#node)
|
||||
|
||||
*Defined in [index.ts:147](https://github.com/polkadot-js/common/blob/1fb1f9d/packages/trie-db/src/index.ts#L147)*
|
||||
|
||||
**Parameters:**
|
||||
|
||||
| Param | Type |
|
||||
| ------ | ------ |
|
||||
| `Optional` hash | `Uint8Array` |
|
||||
|
||||
**Returns:** [Node](../modules/_types_.md#node)
|
||||
|
||||
___
|
||||
<a id="getroot"></a>
|
||||
|
||||
## getRoot
|
||||
|
||||
▸ **getRoot**(): `Uint8Array`
|
||||
|
||||
*Implementation of [TrieDb](../interfaces/_types_.triedb.md).[getRoot](../interfaces/_types_.triedb.md#getroot)*
|
||||
|
||||
*Defined in [index.ts:137](https://github.com/polkadot-js/common/blob/1fb1f9d/packages/trie-db/src/index.ts#L137)*
|
||||
|
||||
**Returns:** `Uint8Array`
|
||||
|
||||
___
|
||||
<a id="maintain"></a>
|
||||
|
||||
## maintain
|
||||
|
||||
▸ **maintain**(fn: *`ProgressCb`*): `void`
|
||||
|
||||
*Implementation of [TrieDb](../interfaces/_types_.triedb.md).[maintain](../interfaces/_types_.triedb.md#maintain)*
|
||||
|
||||
*Defined in [index.ts:93](https://github.com/polkadot-js/common/blob/1fb1f9d/packages/trie-db/src/index.ts#L93)*
|
||||
|
||||
**Parameters:**
|
||||
|
||||
| Param | Type |
|
||||
| ------ | ------ |
|
||||
| fn | `ProgressCb` |
|
||||
|
||||
**Returns:** `void`
|
||||
|
||||
___
|
||||
<a id="open"></a>
|
||||
|
||||
## open
|
||||
|
||||
▸ **open**(): `void`
|
||||
|
||||
*Implementation of [TrieDb](../interfaces/_types_.triedb.md).[open](../interfaces/_types_.triedb.md#open)*
|
||||
|
||||
*Defined in [index.ts:77](https://github.com/polkadot-js/common/blob/1fb1f9d/packages/trie-db/src/index.ts#L77)*
|
||||
|
||||
**Returns:** `void`
|
||||
|
||||
___
|
||||
<a id="put"></a>
|
||||
|
||||
## put
|
||||
|
||||
▸ **put**(key: *`Uint8Array`*, value: *`Uint8Array`*): `void`
|
||||
|
||||
*Implementation of [TrieDb](../interfaces/_types_.triedb.md).[put](../interfaces/_types_.triedb.md#put)*
|
||||
|
||||
*Defined in [index.ts:125](https://github.com/polkadot-js/common/blob/1fb1f9d/packages/trie-db/src/index.ts#L125)*
|
||||
|
||||
**Parameters:**
|
||||
|
||||
| Param | Type |
|
||||
| ------ | ------ |
|
||||
| key | `Uint8Array` |
|
||||
| value | `Uint8Array` |
|
||||
|
||||
**Returns:** `void`
|
||||
|
||||
___
|
||||
<a id="rename"></a>
|
||||
|
||||
## rename
|
||||
|
||||
▸ **rename**(base: *`string`*, file: *`string`*): `void`
|
||||
|
||||
*Implementation of [TrieDb](../interfaces/_types_.triedb.md).[rename](../interfaces/_types_.triedb.md#rename)*
|
||||
|
||||
*Defined in [index.ts:97](https://github.com/polkadot-js/common/blob/1fb1f9d/packages/trie-db/src/index.ts#L97)*
|
||||
|
||||
**Parameters:**
|
||||
|
||||
| Param | Type |
|
||||
| ------ | ------ |
|
||||
| base | `string` |
|
||||
| file | `string` |
|
||||
|
||||
**Returns:** `void`
|
||||
|
||||
___
|
||||
<a id="setroot"></a>
|
||||
|
||||
## setRoot
|
||||
|
||||
▸ **setRoot**(rootHash: *`Uint8Array`*): `void`
|
||||
|
||||
*Implementation of [TrieDb](../interfaces/_types_.triedb.md).[setRoot](../interfaces/_types_.triedb.md#setroot)*
|
||||
|
||||
*Defined in [index.ts:151](https://github.com/polkadot-js/common/blob/1fb1f9d/packages/trie-db/src/index.ts#L151)*
|
||||
|
||||
**Parameters:**
|
||||
|
||||
| Param | Type |
|
||||
| ------ | ------ |
|
||||
| rootHash | `Uint8Array` |
|
||||
|
||||
**Returns:** `void`
|
||||
|
||||
___
|
||||
<a id="size"></a>
|
||||
|
||||
## size
|
||||
|
||||
▸ **size**(): `number`
|
||||
|
||||
*Implementation of [TrieDb](../interfaces/_types_.triedb.md).[size](../interfaces/_types_.triedb.md#size)*
|
||||
|
||||
*Defined in [index.ts:101](https://github.com/polkadot-js/common/blob/1fb1f9d/packages/trie-db/src/index.ts#L101)*
|
||||
|
||||
**Returns:** `number`
|
||||
|
||||
___
|
||||
<a id="snapshot"></a>
|
||||
|
||||
## snapshot
|
||||
|
||||
▸ **snapshot**(dest: *[TrieDb](../interfaces/_types_.triedb.md)*, fn: *`ProgressCb`*): `number`
|
||||
|
||||
*Implementation of [TrieDb](../interfaces/_types_.triedb.md).[snapshot](../interfaces/_types_.triedb.md#snapshot)*
|
||||
|
||||
*Defined in [index.ts:156](https://github.com/polkadot-js/common/blob/1fb1f9d/packages/trie-db/src/index.ts#L156)*
|
||||
|
||||
**Parameters:**
|
||||
|
||||
| Param | Type |
|
||||
| ------ | ------ |
|
||||
| dest | [TrieDb](../interfaces/_types_.triedb.md) |
|
||||
| fn | `ProgressCb` |
|
||||
|
||||
**Returns:** `number`
|
||||
|
||||
___
|
||||
<a id="transaction"></a>
|
||||
|
||||
## transaction
|
||||
|
||||
▸ **transaction**(fn: *`function`*): `boolean`
|
||||
|
||||
*Defined in [index.ts:57](https://github.com/polkadot-js/common/blob/1fb1f9d/packages/trie-db/src/index.ts#L57)*
|
||||
|
||||
**Parameters:**
|
||||
|
||||
| Param | Type |
|
||||
| ------ | ------ |
|
||||
| fn | `function` |
|
||||
|
||||
**Returns:** `boolean`
|
||||
|
||||
___
|
||||
|
||||
@@ -0,0 +1,52 @@
|
||||
|
||||
|
||||
# Index
|
||||
|
||||
### Enumeration members
|
||||
|
||||
* [BRANCH](_types_.nodetype.md#branch)
|
||||
* [EMPTY](_types_.nodetype.md#empty)
|
||||
* [EXTENSION](_types_.nodetype.md#extension)
|
||||
* [LEAF](_types_.nodetype.md#leaf)
|
||||
|
||||
---
|
||||
|
||||
# Enumeration members
|
||||
|
||||
<a id="branch"></a>
|
||||
|
||||
## BRANCH
|
||||
|
||||
**BRANCH**: = 3
|
||||
|
||||
*Defined in [types.ts:11](https://github.com/polkadot-js/common/blob/1fb1f9d/packages/trie-db/src/types.ts#L11)*
|
||||
|
||||
___
|
||||
<a id="empty"></a>
|
||||
|
||||
## EMPTY
|
||||
|
||||
**EMPTY**: = 0
|
||||
|
||||
*Defined in [types.ts:8](https://github.com/polkadot-js/common/blob/1fb1f9d/packages/trie-db/src/types.ts#L8)*
|
||||
|
||||
___
|
||||
<a id="extension"></a>
|
||||
|
||||
## EXTENSION
|
||||
|
||||
**EXTENSION**: = 2
|
||||
|
||||
*Defined in [types.ts:10](https://github.com/polkadot-js/common/blob/1fb1f9d/packages/trie-db/src/types.ts#L10)*
|
||||
|
||||
___
|
||||
<a id="leaf"></a>
|
||||
|
||||
## LEAF
|
||||
|
||||
**LEAF**: = 1
|
||||
|
||||
*Defined in [types.ts:9](https://github.com/polkadot-js/common/blob/1fb1f9d/packages/trie-db/src/types.ts#L9)*
|
||||
|
||||
___
|
||||
|
||||
@@ -0,0 +1,451 @@
|
||||
|
||||
<!DOCTYPE HTML>
|
||||
<html lang="" >
|
||||
<head>
|
||||
<meta charset="UTF-8">
|
||||
<meta content="text/html; charset=utf-8" http-equiv="Content-Type">
|
||||
<title>trie-db · Polkadot Common Book</title>
|
||||
<meta http-equiv="X-UA-Compatible" content="IE=edge" />
|
||||
<meta name="description" content="">
|
||||
<meta name="generator" content="GitBook 3.2.3">
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
<link rel="stylesheet" href="../gitbook/style.css">
|
||||
|
||||
|
||||
|
||||
|
||||
<link rel="stylesheet" href="../gitbook/gitbook-plugin-insert-logo-link/plugin.css">
|
||||
|
||||
|
||||
|
||||
<link rel="stylesheet" href="../gitbook/gitbook-plugin-mermaid-gb3/mermaid/mermaid.css">
|
||||
|
||||
|
||||
|
||||
<link rel="stylesheet" href="../gitbook/gitbook-plugin-sunlight-highlighter/sunlight.css">
|
||||
|
||||
|
||||
|
||||
<link rel="stylesheet" href="../gitbook/gitbook-plugin-search/search.css">
|
||||
|
||||
|
||||
|
||||
<link rel="stylesheet" href="../gitbook/gitbook-plugin-fontsettings/website.css">
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
<link rel="stylesheet" href="../styles/website.css">
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
<meta name="HandheldFriendly" content="true"/>
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1, user-scalable=no">
|
||||
<meta name="apple-mobile-web-app-capable" content="yes">
|
||||
<meta name="apple-mobile-web-app-status-bar-style" content="black">
|
||||
<link rel="apple-touch-icon-precomposed" sizes="152x152" href="../gitbook/images/apple-touch-icon-precomposed-152.png">
|
||||
<link rel="shortcut icon" href="../gitbook/images/favicon.ico" type="image/x-icon">
|
||||
|
||||
|
||||
<link rel="next" href="../trie-hash/" />
|
||||
|
||||
|
||||
<link rel="prev" href="../keyring/" />
|
||||
|
||||
|
||||
</head>
|
||||
<body>
|
||||
|
||||
<div class="book">
|
||||
<div class="book-summary">
|
||||
|
||||
|
||||
<div id="book-search-input" role="search">
|
||||
<input type="text" placeholder="Type to search" />
|
||||
</div>
|
||||
|
||||
|
||||
<nav role="navigation">
|
||||
|
||||
|
||||
|
||||
<ul class="summary">
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
<li class="header">Packages</li>
|
||||
|
||||
|
||||
|
||||
<li class="chapter " data-level="1.1" data-path="../">
|
||||
|
||||
<a href="../">
|
||||
|
||||
|
||||
Introduction
|
||||
|
||||
</a>
|
||||
|
||||
|
||||
|
||||
</li>
|
||||
|
||||
<li class="chapter " data-level="1.2" data-path="../keyring/">
|
||||
|
||||
<a href="../keyring/">
|
||||
|
||||
|
||||
keyring
|
||||
|
||||
</a>
|
||||
|
||||
|
||||
|
||||
</li>
|
||||
|
||||
<li class="chapter active" data-level="1.3" data-path="./">
|
||||
|
||||
<a href="./">
|
||||
|
||||
|
||||
trie-db
|
||||
|
||||
</a>
|
||||
|
||||
|
||||
|
||||
</li>
|
||||
|
||||
<li class="chapter " data-level="1.4" data-path="../trie-hash/">
|
||||
|
||||
<a href="../trie-hash/">
|
||||
|
||||
|
||||
trie-hash
|
||||
|
||||
</a>
|
||||
|
||||
|
||||
|
||||
</li>
|
||||
|
||||
<li class="chapter " data-level="1.5" data-path="../util/">
|
||||
|
||||
<a href="../util/">
|
||||
|
||||
|
||||
util
|
||||
|
||||
</a>
|
||||
|
||||
|
||||
|
||||
</li>
|
||||
|
||||
<li class="chapter " data-level="1.6" data-path="../util-crypto/">
|
||||
|
||||
<a href="../util-crypto/">
|
||||
|
||||
|
||||
util-crypto
|
||||
|
||||
</a>
|
||||
|
||||
|
||||
|
||||
</li>
|
||||
|
||||
|
||||
|
||||
|
||||
<li class="header">Examples</li>
|
||||
|
||||
|
||||
|
||||
<li class="chapter " data-level="2.1" data-path="../examples/keyring/">
|
||||
|
||||
<a href="../examples/keyring/">
|
||||
|
||||
|
||||
Keyring
|
||||
|
||||
</a>
|
||||
|
||||
|
||||
|
||||
<ul class="articles">
|
||||
|
||||
|
||||
<li class="chapter " data-level="2.1.1" data-path="../examples/keyring/01_create_account/">
|
||||
|
||||
<a href="../examples/keyring/01_create_account/">
|
||||
|
||||
|
||||
Create Account
|
||||
|
||||
</a>
|
||||
|
||||
|
||||
|
||||
</li>
|
||||
|
||||
<li class="chapter " data-level="2.1.2" data-path="../examples/keyring/02_load_accounts/">
|
||||
|
||||
<a href="../examples/keyring/02_load_accounts/">
|
||||
|
||||
|
||||
Load Accounts
|
||||
|
||||
</a>
|
||||
|
||||
|
||||
|
||||
</li>
|
||||
|
||||
|
||||
</ul>
|
||||
|
||||
</li>
|
||||
|
||||
<li class="chapter " data-level="2.2" data-path="../examples/util-crypto/">
|
||||
|
||||
<a href="../examples/util-crypto/">
|
||||
|
||||
|
||||
Util-Crypto
|
||||
|
||||
</a>
|
||||
|
||||
|
||||
|
||||
<ul class="articles">
|
||||
|
||||
|
||||
<li class="chapter " data-level="2.2.1" data-path="../examples/util-crypto/01_encrypt_decrypt_message_nacl/">
|
||||
|
||||
<a href="../examples/util-crypto/01_encrypt_decrypt_message_nacl/">
|
||||
|
||||
|
||||
Encrypt & Decrypt Message
|
||||
|
||||
</a>
|
||||
|
||||
|
||||
|
||||
</li>
|
||||
|
||||
<li class="chapter " data-level="2.2.2" data-path="../examples/util-crypto/02_sign_verify_message_nacl/">
|
||||
|
||||
<a href="../examples/util-crypto/02_sign_verify_message_nacl/">
|
||||
|
||||
|
||||
Sign & Verify Message
|
||||
|
||||
</a>
|
||||
|
||||
|
||||
|
||||
</li>
|
||||
|
||||
<li class="chapter " data-level="2.2.3" data-path="../examples/util-crypto/03_mnemonic_generate_validate_bip39/">
|
||||
|
||||
<a href="../examples/util-crypto/03_mnemonic_generate_validate_bip39/">
|
||||
|
||||
|
||||
Create & Validate Mnemonic
|
||||
|
||||
</a>
|
||||
|
||||
|
||||
|
||||
</li>
|
||||
|
||||
|
||||
</ul>
|
||||
|
||||
</li>
|
||||
|
||||
|
||||
|
||||
|
||||
<li class="divider"></li>
|
||||
|
||||
<li>
|
||||
<a href="https://www.gitbook.com" target="blank" class="gitbook-link">
|
||||
Published with GitBook
|
||||
</a>
|
||||
</li>
|
||||
</ul>
|
||||
|
||||
|
||||
</nav>
|
||||
|
||||
|
||||
</div>
|
||||
|
||||
<div class="book-body">
|
||||
|
||||
<div class="body-inner">
|
||||
|
||||
|
||||
|
||||
<div class="book-header" role="navigation">
|
||||
|
||||
|
||||
<!-- Title -->
|
||||
<h1>
|
||||
<i class="fa fa-circle-o-notch fa-spin"></i>
|
||||
<a href=".." >trie-db</a>
|
||||
</h1>
|
||||
</div>
|
||||
|
||||
|
||||
|
||||
|
||||
<div class="page-wrapper" tabindex="-1" role="main">
|
||||
<div class="page-inner">
|
||||
|
||||
<div id="book-search-results">
|
||||
<div class="search-noresults">
|
||||
|
||||
<section class="normal markdown-section">
|
||||
|
||||
<h1 id="polkadottrie-db">@polkadot/trie-db</h1>
|
||||
<p>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.</p>
|
||||
<p>This is a JavaScript port of the <a href="https://github.com/ethereum/py-trie" target="_blank">Python Ethereum Trie</a> with additions to support transactions (checkpoints) and multiple hashing (npot only Keccak, but also Blake2 as found in Polkadot).</p>
|
||||
<h2 id="usage">Usage</h2>
|
||||
<p>Installation -</p>
|
||||
<pre><code>yarn add @polkadot/trie-db
|
||||
</code></pre><p>Classes can be imported as follows:</p>
|
||||
<pre><code class="lang-js"><div class="sunlight-container sunlight-theme-gitbook"><div class="sunlight-code-container"><pre class="sunlight-highlight-javascript sunlight-highlighted"><span class="sunlight-javascript"><span class="sunlight-reservedWord">import</span> <span class="sunlight-ident">Trie</span> <span class="sunlight-ident">from</span> <span class="sunlight-string">'@polkadot/trie-db'</span><span class="sunlight-punctuation">;</span> <span class="sunlight-comment">// Default export</span>
|
||||
</span></pre></div></div></code></pre>
|
||||
<h2 id="documentation-and-available-utilities">Documentation and Available Utilities</h2>
|
||||
<p>Below is a list of currently exposed methods published at the <a href="https://polkadot.js.org/common/trie-db/" target="_blank">Polkadot-JS Common Documentation Portal</a>.</p>
|
||||
<ul>
|
||||
<li><a href="https://polkadot.js.org/common/trie-db/README.md" target="_blank">trie-db</a><ul>
|
||||
<li>Classes<ul>
|
||||
<li><a href="https://polkadot.js.org/common/trie-db/classes/_index_.trie.md" target="_blank">Trie</a></li>
|
||||
</ul>
|
||||
</li>
|
||||
<li>Functions<ul>
|
||||
<li>Util<ul>
|
||||
<li><a href="https://polkadot.js.org/common/trie-db/modules/_util_is_.md" target="_blank">is</a></li>
|
||||
<li><a href="https://polkadot.js.org/common/trie-db/modules/_util_key_.md" target="_blank">key</a></li>
|
||||
<li><a href="https://polkadot.js.org/common/trie-db/modules/_util_nibbles_.md" target="_blank">nibbles</a></li>
|
||||
<li><a href="https://polkadot.js.org/common/trie-db/modules/_util_node_.md" target="_blank">node</a></li>
|
||||
</ul>
|
||||
</li>
|
||||
</ul>
|
||||
</li>
|
||||
</ul>
|
||||
</li>
|
||||
</ul>
|
||||
|
||||
|
||||
</section>
|
||||
|
||||
</div>
|
||||
<div class="search-results">
|
||||
<div class="has-results">
|
||||
|
||||
<h1 class="search-results-title"><span class='search-results-count'></span> results matching "<span class='search-query'></span>"</h1>
|
||||
<ul class="search-results-list"></ul>
|
||||
|
||||
</div>
|
||||
<div class="no-results">
|
||||
|
||||
<h1 class="search-results-title">No results matching "<span class='search-query'></span>"</h1>
|
||||
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
</div>
|
||||
</div>
|
||||
|
||||
</div>
|
||||
|
||||
|
||||
|
||||
<a href="../keyring/" class="navigation navigation-prev " aria-label="Previous page: keyring">
|
||||
<i class="fa fa-angle-left"></i>
|
||||
</a>
|
||||
|
||||
|
||||
<a href="../trie-hash/" class="navigation navigation-next " aria-label="Next page: trie-hash">
|
||||
<i class="fa fa-angle-right"></i>
|
||||
</a>
|
||||
|
||||
|
||||
|
||||
</div>
|
||||
|
||||
<script>
|
||||
var gitbook = gitbook || [];
|
||||
gitbook.push(function() {
|
||||
gitbook.page.hasChanged({"page":{"title":"trie-db","level":"1.3","depth":1,"next":{"title":"trie-hash","level":"1.4","depth":1,"path":"trie-hash/README.md","ref":"trie-hash/README.md","articles":[]},"previous":{"title":"keyring","level":"1.2","depth":1,"path":"keyring/README.md","ref":"keyring/README.md","articles":[]},"dir":"ltr"},"config":{"plugins":["include-codeblock","insert-logo-link","mermaid-gb3","-highlight","sunlight-highlighter"],"root":"docs","styles":{"website":"styles/website.css"},"pluginsConfig":{"insert-logo-link":{"src":"/common/logo.png","url":"https://polkadot.js.org"},"search":{},"lunr":{"maxIndexSize":1000000,"ignoreSpecialCharacters":false},"fontsettings":{"theme":"white","family":"sans","size":2},"mermaid-gb3":{},"include-codeblock":{"check":false,"edit":false,"lang":"","fixlang":false,"template":"default","theme":"chrome","unindent":false},"sharing":{"facebook":true,"twitter":true,"google":false,"weibo":false,"instapaper":false,"vk":false,"all":["facebook","google","twitter","weibo","instapaper"]},"theme-default":{"styles":{"website":"styles/website.css","pdf":"styles/pdf.css","epub":"styles/epub.css","mobi":"styles/mobi.css","ebook":"styles/ebook.css","print":"styles/print.css"},"showLevel":false},"sunlight-highlighter":{"theme":"gitbook","lineNumbers":false}},"theme":"default","pdf":{"pageNumbers":true,"fontSize":12,"fontFamily":"Arial","paperSize":"a4","chapterMark":"pagebreak","pageBreaksBefore":"/","margin":{"right":62,"left":62,"top":56,"bottom":56}},"structure":{"langs":"LANGS.md","readme":"README.md","glossary":"GLOSSARY.md","summary":"SUMMARY.md"},"variables":{},"title":"Polkadot Common Book","gitbook":">=2.4.0"},"file":{"path":"trie-db/README.md","mtime":"2018-10-19T15:37:32.102Z","type":"markdown"},"gitbook":{"version":"3.2.3","time":"2018-10-19T15:38:38.079Z"},"basePath":"..","book":{"language":""}});
|
||||
});
|
||||
</script>
|
||||
</div>
|
||||
|
||||
|
||||
|
||||
<script src="../gitbook/gitbook.js"></script>
|
||||
<script src="../gitbook/theme.js"></script>
|
||||
|
||||
|
||||
<script src="../gitbook/gitbook-plugin-insert-logo-link/plugin.js"></script>
|
||||
|
||||
|
||||
|
||||
<script src="../gitbook/gitbook-plugin-mermaid-gb3/book/plugin.js"></script>
|
||||
|
||||
|
||||
|
||||
<script src="../gitbook/gitbook-plugin-search/search-engine.js"></script>
|
||||
|
||||
|
||||
|
||||
<script src="../gitbook/gitbook-plugin-search/search.js"></script>
|
||||
|
||||
|
||||
|
||||
<script src="../gitbook/gitbook-plugin-lunr/lunr.min.js"></script>
|
||||
|
||||
|
||||
|
||||
<script src="../gitbook/gitbook-plugin-lunr/search-lunr.js"></script>
|
||||
|
||||
|
||||
|
||||
<script src="../gitbook/gitbook-plugin-sharing/buttons.js"></script>
|
||||
|
||||
|
||||
|
||||
<script src="../gitbook/gitbook-plugin-fontsettings/fontsettings.js"></script>
|
||||
|
||||
|
||||
|
||||
<script src="../gitbook/gitbook-plugin-mermaid-gb3/mermaid/mermaid.min.js"></script>
|
||||
|
||||
</body>
|
||||
</html>
|
||||
|
||||
@@ -0,0 +1,254 @@
|
||||
|
||||
|
||||
# Hierarchy
|
||||
|
||||
`TxDb`
|
||||
|
||||
**↳ TrieDb**
|
||||
|
||||
# Implemented by
|
||||
|
||||
* [Trie](../classes/_index_.trie.md)
|
||||
|
||||
# Properties
|
||||
|
||||
<a id="db"></a>
|
||||
|
||||
## db
|
||||
|
||||
**● db**: *`TxDb`*
|
||||
|
||||
*Defined in [types.ts:37](https://github.com/polkadot-js/common/blob/1fb1f9d/packages/trie-db/src/types.ts#L37)*
|
||||
|
||||
___
|
||||
|
||||
# Methods
|
||||
|
||||
<a id="close"></a>
|
||||
|
||||
## close
|
||||
|
||||
▸ **close**(): `void`
|
||||
|
||||
*Inherited from BaseDb.close*
|
||||
|
||||
*Defined in [/home/travis/build/polkadot-js/common/packages/db/src/types.d.ts:18](https://github.com/polkadot-js/common/blob/1fb1f9d/packages/db/src/types.d.ts#L18)*
|
||||
|
||||
**Returns:** `void`
|
||||
|
||||
___
|
||||
<a id="del"></a>
|
||||
|
||||
## del
|
||||
|
||||
▸ **del**(key: *`Uint8Array`*): `void`
|
||||
|
||||
*Inherited from BaseDb.del*
|
||||
|
||||
*Defined in [/home/travis/build/polkadot-js/common/packages/db/src/types.d.ts:26](https://github.com/polkadot-js/common/blob/1fb1f9d/packages/db/src/types.d.ts#L26)*
|
||||
|
||||
**Parameters:**
|
||||
|
||||
| Param | Type |
|
||||
| ------ | ------ |
|
||||
| key | `Uint8Array` |
|
||||
|
||||
**Returns:** `void`
|
||||
|
||||
___
|
||||
<a id="drop"></a>
|
||||
|
||||
## drop
|
||||
|
||||
▸ **drop**(): `void`
|
||||
|
||||
*Inherited from BaseDb.drop*
|
||||
|
||||
*Defined in [/home/travis/build/polkadot-js/common/packages/db/src/types.d.ts:20](https://github.com/polkadot-js/common/blob/1fb1f9d/packages/db/src/types.d.ts#L20)*
|
||||
|
||||
**Returns:** `void`
|
||||
|
||||
___
|
||||
<a id="empty"></a>
|
||||
|
||||
## empty
|
||||
|
||||
▸ **empty**(): `void`
|
||||
|
||||
*Inherited from BaseDb.empty*
|
||||
|
||||
*Defined in [/home/travis/build/polkadot-js/common/packages/db/src/types.d.ts:21](https://github.com/polkadot-js/common/blob/1fb1f9d/packages/db/src/types.d.ts#L21)*
|
||||
|
||||
**Returns:** `void`
|
||||
|
||||
___
|
||||
<a id="get"></a>
|
||||
|
||||
## get
|
||||
|
||||
▸ **get**(key: *`Uint8Array`*): `Uint8Array` | `null`
|
||||
|
||||
*Inherited from BaseDb.get*
|
||||
|
||||
*Defined in [/home/travis/build/polkadot-js/common/packages/db/src/types.d.ts:27](https://github.com/polkadot-js/common/blob/1fb1f9d/packages/db/src/types.d.ts#L27)*
|
||||
|
||||
**Parameters:**
|
||||
|
||||
| Param | Type |
|
||||
| ------ | ------ |
|
||||
| key | `Uint8Array` |
|
||||
|
||||
**Returns:** `Uint8Array` | `null`
|
||||
|
||||
___
|
||||
<a id="getroot"></a>
|
||||
|
||||
## getRoot
|
||||
|
||||
▸ **getRoot**(): `Uint8Array`
|
||||
|
||||
*Defined in [types.ts:39](https://github.com/polkadot-js/common/blob/1fb1f9d/packages/trie-db/src/types.ts#L39)*
|
||||
|
||||
**Returns:** `Uint8Array`
|
||||
|
||||
___
|
||||
<a id="maintain"></a>
|
||||
|
||||
## maintain
|
||||
|
||||
▸ **maintain**(fn: *`ProgressCb`*): `void`
|
||||
|
||||
*Inherited from BaseDb.maintain*
|
||||
|
||||
*Defined in [/home/travis/build/polkadot-js/common/packages/db/src/types.d.ts:22](https://github.com/polkadot-js/common/blob/1fb1f9d/packages/db/src/types.d.ts#L22)*
|
||||
|
||||
**Parameters:**
|
||||
|
||||
| Param | Type |
|
||||
| ------ | ------ |
|
||||
| fn | `ProgressCb` |
|
||||
|
||||
**Returns:** `void`
|
||||
|
||||
___
|
||||
<a id="open"></a>
|
||||
|
||||
## open
|
||||
|
||||
▸ **open**(): `void`
|
||||
|
||||
*Inherited from BaseDb.open*
|
||||
|
||||
*Defined in [/home/travis/build/polkadot-js/common/packages/db/src/types.d.ts:19](https://github.com/polkadot-js/common/blob/1fb1f9d/packages/db/src/types.d.ts#L19)*
|
||||
|
||||
**Returns:** `void`
|
||||
|
||||
___
|
||||
<a id="put"></a>
|
||||
|
||||
## put
|
||||
|
||||
▸ **put**(key: *`Uint8Array`*, value: *`Uint8Array`*): `void`
|
||||
|
||||
*Inherited from BaseDb.put*
|
||||
|
||||
*Defined in [/home/travis/build/polkadot-js/common/packages/db/src/types.d.ts:28](https://github.com/polkadot-js/common/blob/1fb1f9d/packages/db/src/types.d.ts#L28)*
|
||||
|
||||
**Parameters:**
|
||||
|
||||
| Param | Type |
|
||||
| ------ | ------ |
|
||||
| key | `Uint8Array` |
|
||||
| value | `Uint8Array` |
|
||||
|
||||
**Returns:** `void`
|
||||
|
||||
___
|
||||
<a id="rename"></a>
|
||||
|
||||
## rename
|
||||
|
||||
▸ **rename**(base: *`string`*, file: *`string`*): `void`
|
||||
|
||||
*Inherited from BaseDb.rename*
|
||||
|
||||
*Defined in [/home/travis/build/polkadot-js/common/packages/db/src/types.d.ts:23](https://github.com/polkadot-js/common/blob/1fb1f9d/packages/db/src/types.d.ts#L23)*
|
||||
|
||||
**Parameters:**
|
||||
|
||||
| Param | Type |
|
||||
| ------ | ------ |
|
||||
| base | `string` |
|
||||
| file | `string` |
|
||||
|
||||
**Returns:** `void`
|
||||
|
||||
___
|
||||
<a id="setroot"></a>
|
||||
|
||||
## setRoot
|
||||
|
||||
▸ **setRoot**(rootHash: *`Uint8Array`*): `void`
|
||||
|
||||
*Defined in [types.ts:40](https://github.com/polkadot-js/common/blob/1fb1f9d/packages/trie-db/src/types.ts#L40)*
|
||||
|
||||
**Parameters:**
|
||||
|
||||
| Param | Type |
|
||||
| ------ | ------ |
|
||||
| rootHash | `Uint8Array` |
|
||||
|
||||
**Returns:** `void`
|
||||
|
||||
___
|
||||
<a id="size"></a>
|
||||
|
||||
## size
|
||||
|
||||
▸ **size**(): `number`
|
||||
|
||||
*Inherited from BaseDb.size*
|
||||
|
||||
*Defined in [/home/travis/build/polkadot-js/common/packages/db/src/types.d.ts:24](https://github.com/polkadot-js/common/blob/1fb1f9d/packages/db/src/types.d.ts#L24)*
|
||||
|
||||
**Returns:** `number`
|
||||
|
||||
___
|
||||
<a id="snapshot"></a>
|
||||
|
||||
## snapshot
|
||||
|
||||
▸ **snapshot**(dest: *[TrieDb](_types_.triedb.md)*, fn: *`ProgressCb`*): `number`
|
||||
|
||||
*Defined in [types.ts:41](https://github.com/polkadot-js/common/blob/1fb1f9d/packages/trie-db/src/types.ts#L41)*
|
||||
|
||||
**Parameters:**
|
||||
|
||||
| Param | Type |
|
||||
| ------ | ------ |
|
||||
| dest | [TrieDb](_types_.triedb.md) |
|
||||
| fn | `ProgressCb` |
|
||||
|
||||
**Returns:** `number`
|
||||
|
||||
___
|
||||
<a id="transaction"></a>
|
||||
|
||||
## transaction
|
||||
|
||||
▸ **transaction**(fn: *`function`*): `boolean`
|
||||
|
||||
*Inherited from TxDb.transaction*
|
||||
|
||||
*Defined in [/home/travis/build/polkadot-js/common/packages/db/src/types.d.ts:32](https://github.com/polkadot-js/common/blob/1fb1f9d/packages/db/src/types.d.ts#L32)*
|
||||
|
||||
**Parameters:**
|
||||
|
||||
| Param | Type |
|
||||
| ------ | ------ |
|
||||
| fn | `function` |
|
||||
|
||||
**Returns:** `boolean`
|
||||
|
||||
___
|
||||
|
||||
@@ -0,0 +1,2 @@
|
||||
|
||||
|
||||
@@ -0,0 +1,10 @@
|
||||
|
||||
|
||||
# Index
|
||||
|
||||
### Classes
|
||||
|
||||
* [Trie](../classes/_index_.trie.md)
|
||||
|
||||
---
|
||||
|
||||
@@ -0,0 +1,104 @@
|
||||
|
||||
|
||||
# Index
|
||||
|
||||
### Enumerations
|
||||
|
||||
* [NodeType](../enums/_types_.nodetype.md)
|
||||
|
||||
### Interfaces
|
||||
|
||||
* [TrieDb](../interfaces/_types_.triedb.md)
|
||||
|
||||
### Type aliases
|
||||
|
||||
* [EncodedPath](_types_.md#encodedpath)
|
||||
* [Node](_types_.md#node)
|
||||
* [NodeBranch](_types_.md#nodebranch)
|
||||
* [NodeEmpty](_types_.md#nodeempty)
|
||||
* [NodeEncoded](_types_.md#nodeencoded)
|
||||
* [NodeEncodedOrEmpty](_types_.md#nodeencodedorempty)
|
||||
* [NodeKv](_types_.md#nodekv)
|
||||
* [NodeNotEmpty](_types_.md#nodenotempty)
|
||||
|
||||
---
|
||||
|
||||
# Type aliases
|
||||
|
||||
<a id="encodedpath"></a>
|
||||
|
||||
## EncodedPath
|
||||
|
||||
**Ƭ EncodedPath**: * `Uint8Array` | `null`
|
||||
*
|
||||
|
||||
*Defined in [types.ts:28](https://github.com/polkadot-js/common/blob/1fb1f9d/packages/trie-db/src/types.ts#L28)*
|
||||
|
||||
___
|
||||
<a id="node"></a>
|
||||
|
||||
## Node
|
||||
|
||||
**Ƭ Node**: * [NodeEmpty](_types_.md#nodeempty) | [NodeNotEmpty](_types_.md#nodenotempty)
|
||||
*
|
||||
|
||||
*Defined in [types.ts:34](https://github.com/polkadot-js/common/blob/1fb1f9d/packages/trie-db/src/types.ts#L34)*
|
||||
|
||||
___
|
||||
<a id="nodebranch"></a>
|
||||
|
||||
## NodeBranch
|
||||
|
||||
**Ƭ NodeBranch**: *[[NodeEncodedOrEmpty](_types_.md#nodeencodedorempty), [NodeEncodedOrEmpty](_types_.md#nodeencodedorempty), [NodeEncodedOrEmpty](_types_.md#nodeencodedorempty), [NodeEncodedOrEmpty](_types_.md#nodeencodedorempty), [NodeEncodedOrEmpty](_types_.md#nodeencodedorempty), [NodeEncodedOrEmpty](_types_.md#nodeencodedorempty), [NodeEncodedOrEmpty](_types_.md#nodeencodedorempty), [NodeEncodedOrEmpty](_types_.md#nodeencodedorempty), [NodeEncodedOrEmpty](_types_.md#nodeencodedorempty), [NodeEncodedOrEmpty](_types_.md#nodeencodedorempty), [NodeEncodedOrEmpty](_types_.md#nodeencodedorempty), [NodeEncodedOrEmpty](_types_.md#nodeencodedorempty), [NodeEncodedOrEmpty](_types_.md#nodeencodedorempty), [NodeEncodedOrEmpty](_types_.md#nodeencodedorempty), [NodeEncodedOrEmpty](_types_.md#nodeencodedorempty), [NodeEncodedOrEmpty](_types_.md#nodeencodedorempty), [NodeEncodedOrEmpty](_types_.md#nodeencodedorempty)]*
|
||||
|
||||
*Defined in [types.ts:20](https://github.com/polkadot-js/common/blob/1fb1f9d/packages/trie-db/src/types.ts#L20)*
|
||||
|
||||
___
|
||||
<a id="nodeempty"></a>
|
||||
|
||||
## NodeEmpty
|
||||
|
||||
**Ƭ NodeEmpty**: *`null`*
|
||||
|
||||
*Defined in [types.ts:14](https://github.com/polkadot-js/common/blob/1fb1f9d/packages/trie-db/src/types.ts#L14)*
|
||||
|
||||
___
|
||||
<a id="nodeencoded"></a>
|
||||
|
||||
## NodeEncoded
|
||||
|
||||
**Ƭ NodeEncoded**: *`Uint8Array`*
|
||||
|
||||
*Defined in [types.ts:16](https://github.com/polkadot-js/common/blob/1fb1f9d/packages/trie-db/src/types.ts#L16)*
|
||||
|
||||
___
|
||||
<a id="nodeencodedorempty"></a>
|
||||
|
||||
## NodeEncodedOrEmpty
|
||||
|
||||
**Ƭ NodeEncodedOrEmpty**: * [NodeEncoded](_types_.md#nodeencoded) | [NodeEmpty](_types_.md#nodeempty)
|
||||
*
|
||||
|
||||
*Defined in [types.ts:18](https://github.com/polkadot-js/common/blob/1fb1f9d/packages/trie-db/src/types.ts#L18)*
|
||||
|
||||
___
|
||||
<a id="nodekv"></a>
|
||||
|
||||
## NodeKv
|
||||
|
||||
**Ƭ NodeKv**: *[[EncodedPath](_types_.md#encodedpath), [NodeEncodedOrEmpty](_types_.md#nodeencodedorempty)]*
|
||||
|
||||
*Defined in [types.ts:30](https://github.com/polkadot-js/common/blob/1fb1f9d/packages/trie-db/src/types.ts#L30)*
|
||||
|
||||
___
|
||||
<a id="nodenotempty"></a>
|
||||
|
||||
## NodeNotEmpty
|
||||
|
||||
**Ƭ NodeNotEmpty**: * [NodeKv](_types_.md#nodekv) | [NodeBranch](_types_.md#nodebranch)
|
||||
*
|
||||
|
||||
*Defined in [types.ts:32](https://github.com/polkadot-js/common/blob/1fb1f9d/packages/trie-db/src/types.ts#L32)*
|
||||
|
||||
___
|
||||
|
||||
@@ -0,0 +1,130 @@
|
||||
|
||||
|
||||
# Functions
|
||||
|
||||
<a id="isbranchnode"></a>
|
||||
|
||||
## isBranchNode
|
||||
|
||||
▸ **isBranchNode**(node: *[Node](_types_.md#node)*): `boolean`
|
||||
|
||||
*Defined in [util/is.ts:57](https://github.com/polkadot-js/common/blob/1fb1f9d/packages/trie-db/src/util/is.ts#L57)*
|
||||
|
||||
*__name__*: isBranchNode
|
||||
|
||||
*__signature__*: isBranchNode (node: Node): node is NodeKv
|
||||
|
||||
*__summary__*: Returns true if node is an Branch 17-item node
|
||||
|
||||
*__description__*: Refer to [Merkle Patricia Trie specification](https://github.com/ethereum/wiki/wiki/Patricia-Tree#optimization)
|
||||
|
||||
**Parameters:**
|
||||
|
||||
| Param | Type |
|
||||
| ------ | ------ |
|
||||
| node | [Node](_types_.md#node) |
|
||||
|
||||
**Returns:** `boolean`
|
||||
|
||||
___
|
||||
<a id="isemptynode"></a>
|
||||
|
||||
## isEmptyNode
|
||||
|
||||
▸ **isEmptyNode**(node: *[Node](_types_.md#node)*): `boolean`
|
||||
|
||||
*Defined in [util/is.ts:17](https://github.com/polkadot-js/common/blob/1fb1f9d/packages/trie-db/src/util/is.ts#L17)*
|
||||
|
||||
*__name__*: isEmptyNode
|
||||
|
||||
*__signature__*: isEmptyNode (node: Node): node is NodeEmpty
|
||||
|
||||
*__summary__*: Returns true if node is NULL
|
||||
|
||||
*__description__*: Refer to [Merkle Patricia Trie specification](https://github.com/ethereum/wiki/wiki/Patricia-Tree#optimization)
|
||||
|
||||
**Parameters:**
|
||||
|
||||
| Param | Type |
|
||||
| ------ | ------ |
|
||||
| node | [Node](_types_.md#node) |
|
||||
|
||||
**Returns:** `boolean`
|
||||
|
||||
___
|
||||
<a id="isextensionnode"></a>
|
||||
|
||||
## isExtensionNode
|
||||
|
||||
▸ **isExtensionNode**(node: *[Node](_types_.md#node)*): `boolean`
|
||||
|
||||
*Defined in [util/is.ts:37](https://github.com/polkadot-js/common/blob/1fb1f9d/packages/trie-db/src/util/is.ts#L37)*
|
||||
|
||||
*__name__*: isExtensionNode
|
||||
|
||||
*__signature__*: isExtensionNode (node: Node): node is NodeKv
|
||||
|
||||
*__summary__*: Returns true if node is an Extension 2-item node
|
||||
|
||||
*__description__*: Refer to [Merkle Patricia Trie specification](https://github.com/ethereum/wiki/wiki/Patricia-Tree#optimization)
|
||||
|
||||
**Parameters:**
|
||||
|
||||
| Param | Type |
|
||||
| ------ | ------ |
|
||||
| node | [Node](_types_.md#node) |
|
||||
|
||||
**Returns:** `boolean`
|
||||
|
||||
___
|
||||
<a id="iskvnode"></a>
|
||||
|
||||
## isKvNode
|
||||
|
||||
▸ **isKvNode**(node: *[Node](_types_.md#node)*): `boolean`
|
||||
|
||||
*Defined in [util/is.ts:27](https://github.com/polkadot-js/common/blob/1fb1f9d/packages/trie-db/src/util/is.ts#L27)*
|
||||
|
||||
*__name__*: isKvNode
|
||||
|
||||
*__signature__*: isKvNode (node: Node): node is NodeKv
|
||||
|
||||
*__summary__*: Returns true if node is not empty and contains a single key/value pair
|
||||
|
||||
*__description__*: Refer to [Merkle Patricia Trie specification](https://github.com/ethereum/wiki/wiki/Patricia-Tree#optimization)
|
||||
|
||||
**Parameters:**
|
||||
|
||||
| Param | Type |
|
||||
| ------ | ------ |
|
||||
| node | [Node](_types_.md#node) |
|
||||
|
||||
**Returns:** `boolean`
|
||||
|
||||
___
|
||||
<a id="isleafnode"></a>
|
||||
|
||||
## isLeafNode
|
||||
|
||||
▸ **isLeafNode**(node: *[Node](_types_.md#node)*): `boolean`
|
||||
|
||||
*Defined in [util/is.ts:47](https://github.com/polkadot-js/common/blob/1fb1f9d/packages/trie-db/src/util/is.ts#L47)*
|
||||
|
||||
*__name__*: isLeafNode
|
||||
|
||||
*__signature__*: isLeafNode (node: Node): node is NodeKv
|
||||
|
||||
*__summary__*: Returns true if node is an Leaf 2-item node
|
||||
|
||||
*__description__*: Refer to [Merkle Patricia Trie specification](https://github.com/ethereum/wiki/wiki/Patricia-Tree#optimization)
|
||||
|
||||
**Parameters:**
|
||||
|
||||
| Param | Type |
|
||||
| ------ | ------ |
|
||||
| node | [Node](_types_.md#node) |
|
||||
|
||||
**Returns:** `boolean`
|
||||
|
||||
___
|
||||
|
||||
@@ -0,0 +1,128 @@
|
||||
|
||||
|
||||
# Functions
|
||||
|
||||
<a id="computeextensionkey"></a>
|
||||
|
||||
## computeExtensionKey
|
||||
|
||||
▸ **computeExtensionKey**(nibbles: *`Uint8Array`*): [EncodedPath](_types_.md#encodedpath)
|
||||
|
||||
*Defined in [util/key.ts:50](https://github.com/polkadot-js/common/blob/1fb1f9d/packages/trie-db/src/util/key.ts#L50)*
|
||||
|
||||
**Parameters:**
|
||||
|
||||
| Param | Type |
|
||||
| ------ | ------ |
|
||||
| nibbles | `Uint8Array` |
|
||||
|
||||
**Returns:** [EncodedPath](_types_.md#encodedpath)
|
||||
|
||||
___
|
||||
<a id="computeleafkey"></a>
|
||||
|
||||
## computeLeafKey
|
||||
|
||||
▸ **computeLeafKey**(nibbles: *`Uint8Array`*): [EncodedPath](_types_.md#encodedpath)
|
||||
|
||||
*Defined in [util/key.ts:54](https://github.com/polkadot-js/common/blob/1fb1f9d/packages/trie-db/src/util/key.ts#L54)*
|
||||
|
||||
**Parameters:**
|
||||
|
||||
| Param | Type |
|
||||
| ------ | ------ |
|
||||
| nibbles | `Uint8Array` |
|
||||
|
||||
**Returns:** [EncodedPath](_types_.md#encodedpath)
|
||||
|
||||
___
|
||||
<a id="consumecommonprefix"></a>
|
||||
|
||||
## consumeCommonPrefix
|
||||
|
||||
▸ **consumeCommonPrefix**(left: *`Uint8Array`*, right: *`Uint8Array`*): [`Uint8Array`, `Uint8Array`, `Uint8Array`]
|
||||
|
||||
*Defined in [util/key.ts:70](https://github.com/polkadot-js/common/blob/1fb1f9d/packages/trie-db/src/util/key.ts#L70)*
|
||||
|
||||
**Parameters:**
|
||||
|
||||
| Param | Type |
|
||||
| ------ | ------ |
|
||||
| left | `Uint8Array` |
|
||||
| right | `Uint8Array` |
|
||||
|
||||
**Returns:** [`Uint8Array`, `Uint8Array`, `Uint8Array`]
|
||||
|
||||
___
|
||||
<a id="extractkey"></a>
|
||||
|
||||
## extractKey
|
||||
|
||||
▸ **extractKey**(node: *[Node](_types_.md#node)*): `Uint8Array`
|
||||
|
||||
*Defined in [util/key.ts:12](https://github.com/polkadot-js/common/blob/1fb1f9d/packages/trie-db/src/util/key.ts#L12)*
|
||||
|
||||
**Parameters:**
|
||||
|
||||
| Param | Type |
|
||||
| ------ | ------ |
|
||||
| node | [Node](_types_.md#node) |
|
||||
|
||||
**Returns:** `Uint8Array`
|
||||
|
||||
___
|
||||
<a id="getcommonprefixlength"></a>
|
||||
|
||||
## getCommonPrefixLength
|
||||
|
||||
▸ **getCommonPrefixLength**(left: *`Uint8Array`*, right: *`Uint8Array`*): `number`
|
||||
|
||||
*Defined in [util/key.ts:60](https://github.com/polkadot-js/common/blob/1fb1f9d/packages/trie-db/src/util/key.ts#L60)*
|
||||
|
||||
**Parameters:**
|
||||
|
||||
| Param | Type |
|
||||
| ------ | ------ |
|
||||
| left | `Uint8Array` |
|
||||
| right | `Uint8Array` |
|
||||
|
||||
**Returns:** `number`
|
||||
|
||||
___
|
||||
<a id="keyequals"></a>
|
||||
|
||||
## keyEquals
|
||||
|
||||
▸ **keyEquals**(key: * `Uint8Array` | `null`*, test: * `Uint8Array` | `null`*): `boolean`
|
||||
|
||||
*Defined in [util/key.ts:24](https://github.com/polkadot-js/common/blob/1fb1f9d/packages/trie-db/src/util/key.ts#L24)*
|
||||
|
||||
**Parameters:**
|
||||
|
||||
| Param | Type |
|
||||
| ------ | ------ |
|
||||
| key | `Uint8Array` | `null`|
|
||||
| test | `Uint8Array` | `null`|
|
||||
|
||||
**Returns:** `boolean`
|
||||
|
||||
___
|
||||
<a id="keystartswith"></a>
|
||||
|
||||
## keyStartsWith
|
||||
|
||||
▸ **keyStartsWith**(key: * `Uint8Array` | `null`*, partial: * `Uint8Array` | `null`*): `boolean`
|
||||
|
||||
*Defined in [util/key.ts:34](https://github.com/polkadot-js/common/blob/1fb1f9d/packages/trie-db/src/util/key.ts#L34)*
|
||||
|
||||
**Parameters:**
|
||||
|
||||
| Param | Type |
|
||||
| ------ | ------ |
|
||||
| key | `Uint8Array` | `null`|
|
||||
| partial | `Uint8Array` | `null`|
|
||||
|
||||
**Returns:** `boolean`
|
||||
|
||||
___
|
||||
|
||||
@@ -0,0 +1,90 @@
|
||||
|
||||
|
||||
# Functions
|
||||
|
||||
<a id="addnibblesterminator"></a>
|
||||
|
||||
## addNibblesTerminator
|
||||
|
||||
▸ **addNibblesTerminator**(nibbles: *`Uint8Array`*): `Uint8Array`
|
||||
|
||||
*Defined in [util/nibbles.ts:22](https://github.com/polkadot-js/common/blob/1fb1f9d/packages/trie-db/src/util/nibbles.ts#L22)*
|
||||
|
||||
**Parameters:**
|
||||
|
||||
| Param | Type |
|
||||
| ------ | ------ |
|
||||
| nibbles | `Uint8Array` |
|
||||
|
||||
**Returns:** `Uint8Array`
|
||||
|
||||
___
|
||||
<a id="decodenibbles"></a>
|
||||
|
||||
## decodeNibbles
|
||||
|
||||
▸ **decodeNibbles**(value: *[NodeEncodedOrEmpty](_types_.md#nodeencodedorempty)*): `Uint8Array`
|
||||
|
||||
*Defined in [util/nibbles.ts:43](https://github.com/polkadot-js/common/blob/1fb1f9d/packages/trie-db/src/util/nibbles.ts#L43)*
|
||||
|
||||
**Parameters:**
|
||||
|
||||
| Param | Type |
|
||||
| ------ | ------ |
|
||||
| value | [NodeEncodedOrEmpty](_types_.md#nodeencodedorempty) |
|
||||
|
||||
**Returns:** `Uint8Array`
|
||||
|
||||
___
|
||||
<a id="encodenibbles"></a>
|
||||
|
||||
## encodeNibbles
|
||||
|
||||
▸ **encodeNibbles**(nibbles: *`Uint8Array`*): [NodeEncoded](_types_.md#nodeencoded)
|
||||
|
||||
*Defined in [util/nibbles.ts:56](https://github.com/polkadot-js/common/blob/1fb1f9d/packages/trie-db/src/util/nibbles.ts#L56)*
|
||||
|
||||
**Parameters:**
|
||||
|
||||
| Param | Type |
|
||||
| ------ | ------ |
|
||||
| nibbles | `Uint8Array` |
|
||||
|
||||
**Returns:** [NodeEncoded](_types_.md#nodeencoded)
|
||||
|
||||
___
|
||||
<a id="isnibblesterminated"></a>
|
||||
|
||||
## isNibblesTerminated
|
||||
|
||||
▸ **isNibblesTerminated**(nibbles: *`Uint8Array`*): `boolean`
|
||||
|
||||
*Defined in [util/nibbles.ts:18](https://github.com/polkadot-js/common/blob/1fb1f9d/packages/trie-db/src/util/nibbles.ts#L18)*
|
||||
|
||||
**Parameters:**
|
||||
|
||||
| Param | Type |
|
||||
| ------ | ------ |
|
||||
| nibbles | `Uint8Array` |
|
||||
|
||||
**Returns:** `boolean`
|
||||
|
||||
___
|
||||
<a id="removenibblesterminator"></a>
|
||||
|
||||
## removeNibblesTerminator
|
||||
|
||||
▸ **removeNibblesTerminator**(nibbles: *`Uint8Array`*): `Uint8Array`
|
||||
|
||||
*Defined in [util/nibbles.ts:35](https://github.com/polkadot-js/common/blob/1fb1f9d/packages/trie-db/src/util/nibbles.ts#L35)*
|
||||
|
||||
**Parameters:**
|
||||
|
||||
| Param | Type |
|
||||
| ------ | ------ |
|
||||
| nibbles | `Uint8Array` |
|
||||
|
||||
**Returns:** `Uint8Array`
|
||||
|
||||
___
|
||||
|
||||
@@ -0,0 +1,56 @@
|
||||
|
||||
|
||||
# Functions
|
||||
|
||||
<a id="decodenode"></a>
|
||||
|
||||
## decodeNode
|
||||
|
||||
▸ **decodeNode**(encoded: * `Uint8Array` | [Node](_types_.md#node)*): [Node](_types_.md#node)
|
||||
|
||||
*Defined in [util/node.ts:31](https://github.com/polkadot-js/common/blob/1fb1f9d/packages/trie-db/src/util/node.ts#L31)*
|
||||
|
||||
**Parameters:**
|
||||
|
||||
| Param | Type |
|
||||
| ------ | ------ |
|
||||
| encoded | `Uint8Array` | [Node](_types_.md#node)|
|
||||
|
||||
**Returns:** [Node](_types_.md#node)
|
||||
|
||||
___
|
||||
<a id="encodenode"></a>
|
||||
|
||||
## encodeNode
|
||||
|
||||
▸ **encodeNode**(node: *[Node](_types_.md#node)*): `Uint8Array`
|
||||
|
||||
*Defined in [util/node.ts:48](https://github.com/polkadot-js/common/blob/1fb1f9d/packages/trie-db/src/util/node.ts#L48)*
|
||||
|
||||
**Parameters:**
|
||||
|
||||
| Param | Type |
|
||||
| ------ | ------ |
|
||||
| node | [Node](_types_.md#node) |
|
||||
|
||||
**Returns:** `Uint8Array`
|
||||
|
||||
___
|
||||
<a id="getnodetype"></a>
|
||||
|
||||
## getNodeType
|
||||
|
||||
▸ **getNodeType**(node: *[Node](_types_.md#node)*): [NodeType](../enums/_types_.nodetype.md)
|
||||
|
||||
*Defined in [util/node.ts:14](https://github.com/polkadot-js/common/blob/1fb1f9d/packages/trie-db/src/util/node.ts#L14)*
|
||||
|
||||
**Parameters:**
|
||||
|
||||
| Param | Type |
|
||||
| ------ | ------ |
|
||||
| node | [Node](_types_.md#node) |
|
||||
|
||||
**Returns:** [NodeType](../enums/_types_.nodetype.md)
|
||||
|
||||
___
|
||||
|
||||
Reference in New Issue
Block a user