Move trieRoot default to inheritance root (#184)

This commit is contained in:
Jaco Greeff
2018-07-30 11:50:19 +02:00
committed by GitHub
parent 6263358e08
commit 0c896363c5
3 changed files with 4 additions and 6 deletions
+2 -1
View File
@@ -14,6 +14,7 @@ import assert from '@polkadot/util/assert';
import isU8a from '@polkadot/util/is/u8a';
import promisify from '@polkadot/util/promisify';
// import u8aToHex from '@polkadot/util/u8a/toHex';
import keccakAsU8a from '@polkadot/util-crypto/keccak/asU8a';
import decodeRlp from '@polkadot/util-rlp/decode';
import { EMPTY_ROOT_U8A, EMPTY_ROOT_STR } from './constants';
@@ -41,7 +42,7 @@ export default class BaseTrie {
putRaw: RawPutFn;
semaphore: SemaphorePromise;
constructor (db: any, root: Uint8Array, hashing: HashFn) {
constructor (db: any, root: Uint8Array = EMPTY_ROOT_U8A, hashing: HashFn = keccakAsU8a) {
this.putRaw = this._putRaw;
this.semaphore = semaphore(1);
+1 -1
View File
@@ -36,7 +36,7 @@ export default class CheckpointTrie extends BaseTrie {
__putDBs: any[]; // tslint:disable-line
// @ts-ignore FIXME, we need to properly check the full file
constructor (db: any, root: Uint8Array, hashing: HashFn) {
constructor (db: any, root?: Uint8Array, hashing?: HashFn) {
super(db, root, hashing);
this._scratch = null;
+1 -4
View File
@@ -6,10 +6,7 @@
import { HashFn } from './types';
// import logger from '@polkadot/util/logger';
import keccakAsU8a from '@polkadot/util-crypto/keccak/asU8a';
import CheckpointTrie from './CheckpointTrie';
import { EMPTY_ROOT_U8A } from './constants';
import { prove, verifyProof } from './proof';
// const l = logger('trie');
@@ -18,7 +15,7 @@ export default class Trie extends CheckpointTrie {
static prove = prove;
static verifyProof = verifyProof;
constructor (db: any, root: Uint8Array = EMPTY_ROOT_U8A, hashing: HashFn = keccakAsU8a) {
constructor (db: any, root?: Uint8Array, hashing?: HashFn) {
super(db, root, hashing);
// l.debug('Created Trie');