Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

trie: remove use of deprecated setRoot #1376

Merged
merged 6 commits into from
Jul 26, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 12 additions & 0 deletions packages/trie/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,18 @@ The format is based on [Keep a Changelog](http://keepachangelog.com/en/1.0.0/)
(modification: no type change headlines) and this project adheres to
[Semantic Versioning](http://semver.org/spec/v2.0.0.html).

## [UNRELEASED]

**New Features**

**Bug Fixes**

**Maintenance**

- Remove use of deprecated setRoot, PR [#1376](https://github.com/ethereumjs/ethereumjs-monorepo/pull/1376)

**Dependencies, CI and Docs**

## 4.2.0 - 2021-05-20

### Changed Delete Behavior: NO Default Node Deletes
Expand Down
23 changes: 14 additions & 9 deletions packages/trie/src/baseTrie.ts
Original file line number Diff line number Diff line change
Expand Up @@ -65,16 +65,25 @@ export class Trie {
this._deleteFromDB = deleteFromDB

if (root) {
this.setRoot(root)
this.root = root
}
}

/** Sets the current root of the `trie` */
/**
* Sets the current root of the `trie`
*/
set root(value: Buffer) {
this.setRoot(value)
// eslint-disable-next-line @typescript-eslint/no-unnecessary-condition
if (!value) {
value = this.EMPTY_TRIE_ROOT
}
assert(value.length === 32, 'Invalid root length. Roots are 32 bytes')
this._root = value
}

/** Gets the current root of the `trie` */
/**
* Gets the current root of the `trie`
*/
get root(): Buffer {
return this._root
}
Expand All @@ -87,11 +96,7 @@ export class Trie {
* @deprecated
*/
setRoot(value?: Buffer) {
if (!value) {
value = this.EMPTY_TRIE_ROOT
}
assert(value.length === 32, 'Invalid root length. Roots are 32 bytes')
this._root = value
this.root = value ?? this.EMPTY_TRIE_ROOT
}

/**
Expand Down