Skip to content

Commit

Permalink
trie: remove use of deprecated setRoot (#1376)
Browse files Browse the repository at this point in the history
  • Loading branch information
acolytec3 authored Jul 26, 2021
1 parent 8b358df commit 6461858
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 9 deletions.
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

0 comments on commit 6461858

Please sign in to comment.