Skip to content

Commit a4e2053

Browse files
trie: fix secureTrie copy
1 parent 895f995 commit a4e2053

File tree

2 files changed

+7
-4
lines changed

2 files changed

+7
-4
lines changed

packages/trie/src/checkpointTrie.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ export class CheckpointTrie extends BaseTrie {
1616
* Is the trie during a checkpoint phase?
1717
*/
1818
get isCheckpoint() {
19-
return this.db.checkpoints.length > 0
19+
return this.db.isCheckpoint
2020
}
2121

2222
/**

packages/trie/src/secure.ts

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -89,8 +89,11 @@ export class SecureTrie extends CheckpointTrie {
8989
* @param includeCheckpoints - If true and during a checkpoint, the copy will contain the checkpointing metadata and will use the same scratch as underlying db.
9090
*/
9191
copy(includeCheckpoints = true): SecureTrie {
92-
const trie = super.copy(includeCheckpoints)
93-
const db = trie.db.copy()
94-
return new SecureTrie(db._leveldb, this.root)
92+
const db = this.db.copy()
93+
const secureTrie = new SecureTrie(db._leveldb, this.root)
94+
if (includeCheckpoints && this.isCheckpoint) {
95+
secureTrie.db.checkpoints = this.db.checkpoints.slice()
96+
}
97+
return secureTrie
9598
}
9699
}

0 commit comments

Comments
 (0)