-
Notifications
You must be signed in to change notification settings - Fork 759
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
trie: improve node typings and class architecture (#3708)
* trie: add RawNode types and replace EmbeddedNode type * trie: implement new types in BranchNode class * trie: improve extension and leaf node class architecture * trie: small improvements * trie: improve raw nodes comments * trie: improve comments for raw nodes
- Loading branch information
1 parent
657cdad
commit f1fda27
Showing
7 changed files
with
50 additions
and
56 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,15 +1,13 @@ | ||
import { addHexPrefix } from '../util/hex.js' | ||
import { ExtensionOrLeafNodeBase } from './extensionOrLeafNodeBase.js' | ||
|
||
import { Node } from './node.js' | ||
import type { Nibbles, RawExtensionNode } from '../types.js' | ||
|
||
import type { Nibbles } from '../types.js' | ||
|
||
export class ExtensionNode extends Node { | ||
export class ExtensionNode extends ExtensionOrLeafNodeBase { | ||
constructor(nibbles: Nibbles, value: Uint8Array) { | ||
super(nibbles, value, false) | ||
} | ||
|
||
static encodeKey(key: Nibbles): Nibbles { | ||
return addHexPrefix(key, false) | ||
raw(): RawExtensionNode { | ||
return super.raw() | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,15 +1,13 @@ | ||
import { addHexPrefix } from '../util/hex.js' | ||
import { ExtensionOrLeafNodeBase } from './extensionOrLeafNodeBase.js' | ||
|
||
import { Node } from './node.js' | ||
import type { Nibbles, RawLeafNode } from '../types.js' | ||
|
||
import type { Nibbles } from '../types.js' | ||
|
||
export class LeafNode extends Node { | ||
export class LeafNode extends ExtensionOrLeafNodeBase { | ||
constructor(nibbles: Nibbles, value: Uint8Array) { | ||
super(nibbles, value, true) | ||
} | ||
|
||
static encodeKey(key: Nibbles): Nibbles { | ||
return addHexPrefix(key, true) | ||
raw(): RawLeafNode { | ||
return super.raw() | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters