Swap default backing DB to FileFlat (interim)

This commit is contained in:
Jaco Greeff
2018-09-02 00:35:52 +02:00
parent 5c9d894b5c
commit 9dc836d061
2 changed files with 12 additions and 12 deletions
+3 -3
View File
@@ -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)
)
);
}
+9 -9
View File
@@ -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 {