Disable debug logs in trie-db (#163)

* Disable logs in trie-db

* FRix unused imports

* Unused imports (part II)

* Ummm, yes.
This commit is contained in:
Jaco Greeff
2018-07-04 13:38:44 +02:00
committed by GitHub
parent a72c71c31e
commit 43031d659a
7 changed files with 30 additions and 37 deletions
-2
View File
@@ -1,2 +0,0 @@
**/build/*
**/node_modules/*
-5
View File
@@ -1,5 +0,0 @@
{
"extends": [
"./node_modules/@polkadot/dev/config/eslint.js"
]
}
+9 -9
View File
@@ -9,11 +9,11 @@ import async from 'async';
// @ts-ignore FIXME, we need to properly check the full file
import levelup from 'levelup';
import memdown from 'memdown';
import logger from '@polkadot/util/logger';
// import logger from '@polkadot/util/logger';
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 u8aToHex from '@polkadot/util/u8a/toHex';
import decodeRlp from '@polkadot/util-rlp/decode';
import { EMPTY_ROOT_U8A, EMPTY_ROOT_STR } from './constants';
@@ -27,7 +27,7 @@ import semaphore from './util/semaphore';
type RawPutFn = (key: Uint8Array, value: Uint8Array) => Promise<any>;
const l = logger('trie/base');
// const l = logger('trie/base');
export default class BaseTrie {
// @ts-ignore we are assigning via this.root in constructor
@@ -54,7 +54,7 @@ export default class BaseTrie {
this.nodeFactory = createFactory(hashing);
this.root = root;
l.debug(() => ['Created BaseTrie', typeof db, u8aToHex(root)]);
// l.debug(() => ['Created BaseTrie', typeof db, u8aToHex(root)]);
}
get root (): Uint8Array {
@@ -78,7 +78,7 @@ export default class BaseTrie {
* @param {Function} cb A callback `Function` which is given the arguments `err` - for errors that may have occured and `value` - the found value in a `Buffer` or if no value was found `null`
*/
async get (key: Uint8Array): Promise<Uint8Array | null> {
l.debug(() => ['get', 'key ->', u8aToHex(key)]);
// l.debug(() => ['get', 'key ->', u8aToHex(key)]);
const result = await this.findPath(key);
@@ -99,7 +99,7 @@ export default class BaseTrie {
* @returns {Function} Promise<void>
*/
async put (key: Uint8Array, value: Uint8Array) {
l.debug(() => ['put', 'key ->', u8aToHex(key), 'value ->', u8aToHex(value, 256)]);
// l.debug(() => ['put', 'key ->', u8aToHex(key), 'value ->', u8aToHex(value, 256)]);
if (!value || value.toString() === '') {
return this.del(key);
@@ -124,7 +124,7 @@ export default class BaseTrie {
* @param {Function} callback the callback `Function`
*/
del (key: Uint8Array) {
l.debug(() => ['del', 'key ->', u8aToHex(key)]);
// l.debug(() => ['del', 'key ->', u8aToHex(key)]);
return this.semaphore(async () => {
const result = await this.findPath(key);
@@ -177,7 +177,7 @@ export default class BaseTrie {
// @ts-ignore FIXME, we need to properly check the full file
value = this.nodeFactory.fromRaw(decodeRlp(value));
} catch (error) {
l.error('_lookupNode decoding', typeof value, value);
// l.error('_lookupNode decoding', typeof value, value);
throw error;
}
}
@@ -789,7 +789,7 @@ export default class BaseTrie {
// creates a new trie backed by the same db
// and starting at the same root
copy () {
l.debug(() => ['Copying BaseTrie', typeof this.dbDown, u8aToHex(this.root)]);
// l.debug(() => ['Copying BaseTrie', typeof this.dbDown, u8aToHex(this.root)]);
return new BaseTrie(this.dbDown, this.root, this.hashing);
}
+10 -10
View File
@@ -11,14 +11,14 @@ import levelws from 'level-ws';
import levelup from 'levelup';
import memdown from 'memdown';
import assert from '@polkadot/util/assert';
import logger from '@polkadot/util/logger';
import u8aToHex from '@polkadot/util/u8a/toHex';
// import logger from '@polkadot/util/logger';
// import u8aToHex from '@polkadot/util/u8a/toHex';
import BaseTrie from './BaseTrie';
import encoder from './encoder';
import ScratchReadStream from './streams/ScratchRead';
const l = logger('trie/checkpt');
// const l = logger('trie/checkpt');
function putRaw (key: Uint8Array, value: Uint8Array) {
return Promise.all(
@@ -42,7 +42,7 @@ export default class CheckpointTrie extends BaseTrie {
this._scratch = null;
this._checkpoints = [];
l.debug(() => 'Created CheckpointTrie');
// l.debug(() => 'Created CheckpointTrie');
}
get isCheckpoint () {
@@ -50,13 +50,13 @@ export default class CheckpointTrie extends BaseTrie {
}
copy () {
l.debug(() => ['Copying CheckpointTrie', typeof this.dbDown, u8aToHex(this.root)]);
// l.debug(() => ['Copying CheckpointTrie', typeof this.dbDown, u8aToHex(this.root)]);
return new CheckpointTrie(this.dbDown, this.root, this.hashing);
}
async checkpoint () {
l.debug(() => 'Marking checkpoint');
// l.debug(() => 'Marking checkpoint');
const wasCheckpoint = this.isCheckpoint;
@@ -68,7 +68,7 @@ export default class CheckpointTrie extends BaseTrie {
}
commit () {
l.debug(() => 'Committing checkpoint');
// l.debug(() => 'Committing checkpoint');
return this.semaphore(async () => {
assert(this.isCheckpoint, 'trying to commit when not checkpointed');
@@ -84,7 +84,7 @@ export default class CheckpointTrie extends BaseTrie {
}
revert () {
l.debug(() => 'Reverting checkpoint');
// l.debug(() => 'Reverting checkpoint');
return this.semaphore(async () => {
if (!this.isCheckpoint) {
@@ -115,7 +115,7 @@ export default class CheckpointTrie extends BaseTrie {
}
_enterCpMode () {
l.debug(() => 'Entering checkpoint mode');
// l.debug(() => 'Entering checkpoint mode');
this._scratch = levelup(encoder(memdown()));
@@ -128,7 +128,7 @@ export default class CheckpointTrie extends BaseTrie {
// @ts-ignore FIXME, we need to properly check the full file
_exitCpMode (commitState) {
l.debug(() => 'Exiting checkpoint mode');
// l.debug(() => 'Exiting checkpoint mode');
const scratch = this._scratch;
this._scratch = null;
+3 -3
View File
@@ -5,13 +5,13 @@
import { HashFn } from './types';
import logger from '@polkadot/util/logger';
// import logger from '@polkadot/util/logger';
import keccakAsU8a from '@polkadot/util-crypto/keccak/asU8a';
import CheckpointTrie from './CheckpointTrie';
import { prove, verifyProof } from './proof';
const l = logger('trie');
// const l = logger('trie');
export default class Trie extends CheckpointTrie {
static prove = prove;
@@ -21,6 +21,6 @@ export default class Trie extends CheckpointTrie {
constructor (db, root, hashing: HashFn = keccakAsU8a) {
super(db, root, hashing);
l.debug('Created Trie');
// l.debug('Created Trie');
}
}
+4 -4
View File
@@ -7,12 +7,12 @@ import { Trie$Base } from '../types';
// @ts-ignore FIXME, we need to properly check the full file
import { Readable } from 'readable-stream';
import logger from '@polkadot/util/logger';
// import logger from '@polkadot/util/logger';
// import u8aToHex from '@polkadot/util/u8a/toHex';
// import rlpToString from '../util/rlpToString';
const l = logger('trie/scratch');
// const l = logger('trie/scratch');
export default class ScratchReadStream extends Readable {
trie: Trie$Base;
@@ -33,7 +33,7 @@ export default class ScratchReadStream extends Readable {
}
const onDone = () => {
l.debug(() => 'onDone');
// l.debug(() => 'onDone');
// @ts-ignore FIXME, we need to properly check the full file
this.push(null);
};
@@ -50,7 +50,7 @@ export default class ScratchReadStream extends Readable {
next();
};
l.debug(() => 'Starting stream');
// l.debug(() => 'Starting stream');
this._started = true;
this.trie._findDbNodes(onFound, onDone);
+4 -4
View File
@@ -7,12 +7,12 @@ import { Trie$Base } from '../types';
// @ts-ignore FIXME, we need to properly check the full file
import { Readable } from 'readable-stream';
import logger from '@polkadot/util/logger';
// import logger from '@polkadot/util/logger';
// import u8aToHex from '@polkadot/util/u8a/toHex';
import { nibblesToU8a } from '../nibbles';
const l = logger('trie/read');
// const l = logger('trie/read');
export default class TrieReadStream extends Readable {
trie: Trie$Base;
@@ -34,7 +34,7 @@ export default class TrieReadStream extends Readable {
}
const onDone = () => {
l.debug(() => 'onDone');
// l.debug(() => 'onDone');
// @ts-ignore FIXME, we need to properly check the full file
this.push(null);
};
@@ -51,7 +51,7 @@ export default class TrieReadStream extends Readable {
next();
};
l.debug(() => 'Starting stream');
// l.debug(() => 'Starting stream');
this._started = true;
this.trie._findValueNodes(onFound, onDone);