diff --git a/packages/db/src/Disk.ts b/packages/db/src/Disk.ts index 0e47c5120..41a69071e 100644 --- a/packages/db/src/Disk.ts +++ b/packages/db/src/Disk.ts @@ -2,15 +2,15 @@ // This software may be modified and distributed under the terms // of the ISC license. See the LICENSE file for details. -import LevelDb from './engines/LevelDb'; +import FileFlatDb from './engines/FileFlatDb'; import LruDb from './engines/LruDb'; import TransactionDb from './engines/TransactionDb'; export default class DiskDb extends TransactionDb { - constructor (location: string) { + constructor (location: string, file?: string) { super( new LruDb( - new LevelDb(location) + new FileFlatDb(location, file) ) ); } diff --git a/packages/db/src/engines/FileFlatDb.ts b/packages/db/src/engines/FileFlatDb.ts index 1943e08b4..578f42a50 100644 --- a/packages/db/src/engines/FileFlatDb.ts +++ b/packages/db/src/engines/FileFlatDb.ts @@ -5,7 +5,7 @@ import { BaseDb, ProgressCb } from '../types'; import fs from 'fs'; -// import snappy from 'snappy'; +import snappy from 'snappy'; import assert from '@polkadot/util/assert'; import logger from '@polkadot/util/logger'; import bufferToU8a from '@polkadot/util/buffer/toU8a'; @@ -141,19 +141,19 @@ export default class FileFlatDb implements BaseDb { } private _deserializeValue (value: Buffer): Uint8Array | null { - // return bufferToU8a( - // snappy.uncompressSync(value) - // ); + // return bufferToU8a(value); - return bufferToU8a(value); + return bufferToU8a( + snappy.uncompressSync(value) + ); } private _serializeValue (value: Uint8Array): Buffer { - // return snappy.compressSync( - // u8aToBuffer(value) - // ); + // return u8aToBuffer(value); - return u8aToBuffer(value); + return snappy.compressSync( + u8aToBuffer(value) + ); } private _serializeKey (key: Uint8Array): Buffer {