Bump deps (#396)
* Bump deps * Remove env-specific DB engines (client-use only)
This commit is contained in:
-29
@@ -7,38 +7,9 @@ cache:
|
||||
yarn: true
|
||||
directories:
|
||||
- node_modules
|
||||
# compiler & addons are both used for RocksDb
|
||||
# compiler:
|
||||
# - clang
|
||||
# - gcc
|
||||
# addons:
|
||||
# apt:
|
||||
# sources:
|
||||
# - ubuntu-toolchain-r-test
|
||||
# packages:
|
||||
# - curl
|
||||
# - g++-8
|
||||
# - libbz2-dev
|
||||
# - libgflags-dev
|
||||
# - libsnappy-dev
|
||||
# - mingw-w64
|
||||
# - zlib1g-dev
|
||||
before_install:
|
||||
- curl -o- -L https://yarnpkg.com/install.sh | bash
|
||||
- export PATH=$HOME/.yarn/bin:$(yarn global bin):$PATH
|
||||
# install:
|
||||
# - export ROCKSDB=$HOME/rocksdb-master
|
||||
# - pushd $HOME
|
||||
# - curl -sLO https://github.com/facebook/rocksdb/archive/master.zip
|
||||
# - unzip -q master.zip
|
||||
# - cd rocksdb-master
|
||||
# - make shared_lib
|
||||
# - popd
|
||||
# - export CFLAGS="-I${ROCKSDB}/include/"
|
||||
# - export CXXFLAGS="-I${ROCKSDB}/include/"
|
||||
# - export LDFLAGS="-L${ROCKSDB} -lrocksdb -lstdc++ -lm -lz"
|
||||
# - export LD_LIBRARY_PATH="${ROCKSDB}:/usr/local/lib"
|
||||
# - yarn
|
||||
script:
|
||||
- yarn polkadot-dev-travis-build
|
||||
deploy:
|
||||
|
||||
+2
-2
@@ -21,8 +21,8 @@
|
||||
"test": "jest --coverage"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@babel/core": "^7.4.0",
|
||||
"@polkadot/dev": "^0.29.1",
|
||||
"@babel/core": "^7.4.3",
|
||||
"@polkadot/dev": "^0.30.0-beta.0",
|
||||
"@polkadot/ts": "^0.1.56",
|
||||
"gh-pages": "^2.0.1"
|
||||
}
|
||||
|
||||
@@ -28,7 +28,7 @@
|
||||
},
|
||||
"homepage": "https://github.com/polkadot-js/common/tree/master/packages/chainspec#readme",
|
||||
"dependencies": {
|
||||
"@babel/runtime": "^7.4.2",
|
||||
"@babel/runtime": "^7.4.3",
|
||||
"@polkadot/util": "^0.76.0-beta.6"
|
||||
}
|
||||
}
|
||||
|
||||
@@ -28,15 +28,9 @@
|
||||
},
|
||||
"homepage": "https://github.com/polkadot-js/common/tree/master/packages/db#readme",
|
||||
"dependencies": {
|
||||
"@babel/runtime": "^7.4.2",
|
||||
"@babel/runtime": "^7.4.3",
|
||||
"@polkadot/trie-hash": "^0.76.0-beta.6",
|
||||
"@polkadot/util": "^0.76.0-beta.6",
|
||||
"@types/mkdirp": "^0.5.2",
|
||||
"@types/rimraf": "^2.0.2",
|
||||
"@types/snappy": "^6.0.0",
|
||||
"lru_map": "^0.3.3",
|
||||
"mkdirp": "^0.5.1",
|
||||
"node-lmdb": "^0.6.2",
|
||||
"snappy": "^6.1.2"
|
||||
"lru_map": "^0.3.3"
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,79 +0,0 @@
|
||||
// Copyright 2017-2019 @polkadot/db authors & contributors
|
||||
// This software may be modified and distributed under the terms
|
||||
// of the Apache-2.0 license. See the LICENSE file for details.
|
||||
|
||||
import { BaseDbOptions } from './types';
|
||||
|
||||
import FileFlatDb from './FileFlatDb';
|
||||
import LmDb from './engines/LmDb';
|
||||
import LruDb from './engines/LruDb';
|
||||
import TransactionDb from './engines/TransactionDb';
|
||||
|
||||
/**
|
||||
* @name DiskDb
|
||||
* @summary Creates DiskDb database using LruDb for caching with FileFlatDb and extending TransactionDb.
|
||||
* @description Create an instance of a Disk database using
|
||||
* LruDb (for caching with FileFlatDb) and extending TransactionDb.
|
||||
* Note that LruDB uses the [Least Recently Used (LRU) cache algorithm](https://www.npmjs.com/package/lru_map)
|
||||
* @example
|
||||
* <BR>
|
||||
*
|
||||
* ```javascript
|
||||
* import stringToU8a from '@polkadot/util/string/toU8a';
|
||||
* import DiskDb from '@polkadot/db/Disk';
|
||||
* import TransactionDb from '@polkadot/db/engines/TransactionDb';
|
||||
*
|
||||
* // Creat diskDb instance that wraps LruDb with backing and Lru cache
|
||||
* const diskDb = new DiskDb();
|
||||
*
|
||||
* // Creat txDb instance that uses diskDb
|
||||
* const txDb = new TransactionDb(diskDb);
|
||||
*
|
||||
* // Open the disk db backing database. Clears the Lru cache
|
||||
* diskDb.open();
|
||||
*
|
||||
* // Declare key/value pair to allocate to store under a the key
|
||||
* const key = stringToU8a('key');
|
||||
* const value = stringToU8a('some value');
|
||||
*
|
||||
* // Store key/value pair in disk db backing and also in Lru cache
|
||||
* diskDb.put(key, value);
|
||||
*
|
||||
* // Retrieve value for key from disk db. Returns cached value if key
|
||||
* // in cache, otherwise returns backing value for key and stores
|
||||
* // this latest retrieved key/value pair in Lru cache
|
||||
* valueRetrieved = diskDb.get(key);
|
||||
*
|
||||
* // Delete key/value pair from disk db backing and set the key to null in Lru cache
|
||||
* diskDb.del(key);
|
||||
*
|
||||
* // Transaction to Store key/value pair in transaction db
|
||||
* const isTxSuccess = txDb.transaction(() => {
|
||||
* txDb.put(key, value);
|
||||
*
|
||||
* // Boolean to indicate whether transaction was successful or not
|
||||
* return true;
|
||||
* });
|
||||
*
|
||||
* console.log(`Transaction successful?: ${isTxSuccess}`);
|
||||
*
|
||||
* // Retrieve transaction value from diskDb db
|
||||
* console.log(`Transfered value: ${diskDb.get(key)}`);
|
||||
*
|
||||
* // Close the diskDb database and clear Lru cache
|
||||
* diskDb.close();
|
||||
* ```
|
||||
*/
|
||||
export default class DiskDb extends TransactionDb {
|
||||
constructor (base: string, name: string, options: BaseDbOptions = {}) {
|
||||
const backing = options.isNative
|
||||
? new FileFlatDb(base, name, options)
|
||||
: new LmDb(base, name, options);
|
||||
|
||||
super(
|
||||
options.isLru
|
||||
? new LruDb(backing)
|
||||
: backing
|
||||
);
|
||||
}
|
||||
}
|
||||
@@ -1,57 +0,0 @@
|
||||
// Copyright 2017-2019 @polkadot/db authors & contributors
|
||||
// This software may be modified and distributed under the terms
|
||||
// of the Apache-2.0 license. See the LICENSE file for details.
|
||||
|
||||
import { BaseDbOptions } from '../types';
|
||||
|
||||
import fs from 'fs';
|
||||
import { LRUMap } from 'lru_map';
|
||||
|
||||
import File from './File';
|
||||
import defaults from './defaults';
|
||||
|
||||
export default class Cache extends File {
|
||||
protected _lruBranch: LRUMap<number, Buffer>;
|
||||
protected _lruData: LRUMap<number, Buffer>;
|
||||
|
||||
constructor (base: string, file: string, options: BaseDbOptions) {
|
||||
super(base, file, options);
|
||||
|
||||
this._lruBranch = new LRUMap(defaults.LRU_BRANCH_COUNT);
|
||||
this._lruData = new LRUMap(defaults.LRU_DATA_COUNT);
|
||||
}
|
||||
|
||||
protected _cacheBranch (branchAt: number, branch: Buffer): void {
|
||||
this._lruBranch.set(branchAt, branch);
|
||||
}
|
||||
|
||||
protected _cacheData (dataAt: number, data: Buffer): void {
|
||||
this._lruData.set(dataAt, data);
|
||||
}
|
||||
|
||||
protected _getCachedBranch (branchAt: number): Buffer {
|
||||
let branch = this._lruBranch.get(branchAt);
|
||||
|
||||
if (!branch) {
|
||||
branch = Buffer.alloc(defaults.BRANCH_SIZE);
|
||||
|
||||
fs.readSync(this._fd, branch, 0, defaults.BRANCH_SIZE, branchAt);
|
||||
this._cacheBranch(branchAt, branch);
|
||||
}
|
||||
|
||||
return branch;
|
||||
}
|
||||
|
||||
protected _getCachedData (dataAt: number, length: number): Buffer {
|
||||
let data = this._lruData.get(dataAt);
|
||||
|
||||
if (!data) {
|
||||
data = Buffer.alloc(length);
|
||||
|
||||
fs.readSync(this._fd, data, 0, length, dataAt);
|
||||
this._cacheData(dataAt, data);
|
||||
}
|
||||
|
||||
return data;
|
||||
}
|
||||
}
|
||||
@@ -1,17 +0,0 @@
|
||||
// Copyright 2017-2019 @polkadot/db authors & contributors
|
||||
// This software may be modified and distributed under the terms
|
||||
// of the Apache-2.0 license. See the LICENSE file for details.
|
||||
|
||||
import FileFlatDb from '.';
|
||||
|
||||
describe.skip('FileFlatDb (compacting)', () => {
|
||||
const combined = new FileFlatDb(process.cwd());
|
||||
|
||||
it('compacts without failing', () => {
|
||||
expect(
|
||||
combined.maintain(() => {
|
||||
// noop
|
||||
})
|
||||
).not.toBe(0);
|
||||
});
|
||||
});
|
||||
@@ -1,164 +0,0 @@
|
||||
// Copyright 2017-2019 @polkadot/db authors & contributors
|
||||
// This software may be modified and distributed under the terms
|
||||
// of the Apache-2.0 license. See the LICENSE file for details.
|
||||
|
||||
import { ProgressCb } from '../types';
|
||||
import { Slot } from './types';
|
||||
|
||||
import fs from 'fs';
|
||||
import { assert, logger } from '@polkadot/util';
|
||||
|
||||
import defaults from './defaults';
|
||||
|
||||
const l = logger('db/compact');
|
||||
|
||||
export default class Compact {
|
||||
private _fd: number;
|
||||
private _file: string;
|
||||
|
||||
constructor (file: string) {
|
||||
this._fd = -1;
|
||||
this._file = file;
|
||||
}
|
||||
|
||||
maintain (fn: ProgressCb): void {
|
||||
assert(this._fd === -1, 'Database cannot be open for compacting');
|
||||
|
||||
l.log('compacting database');
|
||||
|
||||
const start = Date.now();
|
||||
const newFile = `${this._file}.compacted`;
|
||||
const newFd = this._open(newFile, true);
|
||||
const oldFd = this._open(this._file);
|
||||
const keys = this._compact(fn, newFd, oldFd);
|
||||
|
||||
fs.closeSync(oldFd);
|
||||
fs.closeSync(newFd);
|
||||
|
||||
const newStat = fs.lstatSync(newFile);
|
||||
const oldStat = fs.lstatSync(this._file);
|
||||
const percentage = 100 * (newStat.size / oldStat.size);
|
||||
const sizeMB = newStat.size / (1024 * 1024);
|
||||
const elapsed = (Date.now() - start) / 1000;
|
||||
|
||||
fs.unlinkSync(this._file);
|
||||
fs.renameSync(newFile, this._file);
|
||||
|
||||
l.log(`compacted in ${elapsed.toFixed(2)}s, ${(keys / 1000).toFixed(2)}k keys, ${sizeMB.toFixed(2)}MB (${percentage.toFixed(2)}%)`);
|
||||
}
|
||||
|
||||
private _open (file: string, startEmpty: boolean = false): number {
|
||||
if (!fs.existsSync(file) || startEmpty) {
|
||||
fs.writeFileSync(file, Buffer.alloc(defaults.BRANCH_SIZE));
|
||||
}
|
||||
|
||||
return fs.openSync(file, 'r+');
|
||||
}
|
||||
|
||||
private _compact (fn: ProgressCb, newFd: number, oldFd: number): number {
|
||||
// l.debug(() => ['_compact', debug({ newFd, oldFd, newAt, oldAt })]);
|
||||
|
||||
let keys = 0;
|
||||
let percent = 0;
|
||||
|
||||
const doCompact = (newAt: number, oldAt: number, depth: number) => {
|
||||
const increment = (100 / defaults.ENTRY_NUM) / Math.pow(defaults.ENTRY_NUM, depth);
|
||||
|
||||
for (let index = 0; index < defaults.ENTRY_NUM; index++) {
|
||||
const entry = this._compactReadEntry(oldFd, oldAt, index);
|
||||
const dataAt = entry.readUIntBE(1, defaults.UINT_SIZE);
|
||||
const entryType = entry[0];
|
||||
|
||||
if (entryType === Slot.EMPTY) {
|
||||
// l.debug(() => '_compact/isEmpty');
|
||||
percent += increment;
|
||||
} else if (entryType === Slot.LEAF) {
|
||||
// l.debug(() => '_compact/isLeaf');
|
||||
|
||||
const [key, value] = this._compactReadKey(oldFd, dataAt);
|
||||
const keyAt = this._compactWriteKey(newFd, key, value);
|
||||
|
||||
this._compactUpdateLink(newFd, newAt, index, keyAt, Slot.LEAF);
|
||||
|
||||
keys++;
|
||||
percent += increment;
|
||||
} else if (entryType === Slot.BRANCH) {
|
||||
// l.debug(() => '_compact/isBranch');
|
||||
|
||||
const headerAt = this._compactWriteHeader(newFd, newAt, index);
|
||||
|
||||
doCompact(headerAt, dataAt, depth + 1);
|
||||
} else {
|
||||
throw new Error(`Unknown entry type, ${entryType}`);
|
||||
}
|
||||
|
||||
fn({
|
||||
isCompleted: depth === 0 && index === (defaults.ENTRY_NUM - 1),
|
||||
keys,
|
||||
percent
|
||||
});
|
||||
}
|
||||
|
||||
// l.debug(() => ['_compact', '=>', `${depth}: ${keys} keys written`]);
|
||||
};
|
||||
|
||||
doCompact(0, 0, 0);
|
||||
|
||||
return keys;
|
||||
}
|
||||
|
||||
private _compactReadEntry (fd: number, at: number, index: number): Buffer {
|
||||
const entry = Buffer.alloc(defaults.ENTRY_SIZE);
|
||||
const entryAt = at + (index * defaults.ENTRY_SIZE);
|
||||
|
||||
fs.readSync(fd, entry, 0, defaults.ENTRY_SIZE, entryAt);
|
||||
|
||||
return entry;
|
||||
}
|
||||
|
||||
private _compactReadKey (fd: number, at: number): [Buffer, Buffer] {
|
||||
const key = Buffer.alloc(defaults.KEY_TOTAL_SIZE);
|
||||
|
||||
fs.readSync(fd, key, 0, defaults.KEY_TOTAL_SIZE, at);
|
||||
|
||||
const valueLength = key.readUIntBE(defaults.KEY_SIZE, defaults.UINT_SIZE);
|
||||
const valueAt = key.readUIntBE(defaults.KEY_SIZE + defaults.UINT_SIZE, defaults.UINT_SIZE);
|
||||
const value = Buffer.alloc(valueLength);
|
||||
|
||||
fs.readSync(fd, value, 0, valueLength, valueAt);
|
||||
|
||||
return [key, value];
|
||||
}
|
||||
|
||||
private _compactWriteKey (fd: number, key: Buffer, value: Buffer): number {
|
||||
const valueAt = fs.fstatSync(fd).size;
|
||||
const keyAt = valueAt + value.length;
|
||||
|
||||
key.writeUIntBE(valueAt, defaults.KEY_SIZE + defaults.UINT_SIZE, defaults.UINT_SIZE);
|
||||
|
||||
fs.writeSync(fd, value, 0, value.length, valueAt);
|
||||
fs.writeSync(fd, key, 0, defaults.KEY_TOTAL_SIZE, keyAt);
|
||||
|
||||
return keyAt;
|
||||
}
|
||||
|
||||
private _compactUpdateLink (fd: number, at: number, index: number, pointer: number, type: Slot): void {
|
||||
const entry = Buffer.alloc(defaults.ENTRY_SIZE);
|
||||
|
||||
entry.set([type], 0);
|
||||
entry.writeUIntBE(pointer, 1, defaults.UINT_SIZE);
|
||||
|
||||
fs.writeSync(fd, entry, 0, defaults.ENTRY_SIZE, at + (index * defaults.ENTRY_SIZE));
|
||||
}
|
||||
|
||||
private _compactWriteHeader (fd: number, at: number, index: number): number {
|
||||
const headerAt = fs.fstatSync(fd).size;
|
||||
const header = Buffer.alloc(defaults.BRANCH_SIZE);
|
||||
|
||||
fs.writeSync(fd, header, 0, defaults.BRANCH_SIZE, headerAt);
|
||||
|
||||
this._compactUpdateLink(fd, at, index, headerAt, Slot.BRANCH);
|
||||
|
||||
return headerAt;
|
||||
}
|
||||
}
|
||||
@@ -1,61 +0,0 @@
|
||||
// Copyright 2017-2019 @polkadot/db authors & contributors
|
||||
// This software may be modified and distributed under the terms
|
||||
// of the Apache-2.0 license. See the LICENSE file for details.
|
||||
|
||||
import { BaseDbOptions } from '../types';
|
||||
|
||||
import fs from 'fs';
|
||||
import mkdirp from 'mkdirp';
|
||||
import path from 'path';
|
||||
import { assert, isUndefined } from '@polkadot/util';
|
||||
|
||||
import Serialize from './Serialize';
|
||||
import defaults from './defaults';
|
||||
|
||||
export default class File extends Serialize {
|
||||
protected _fd: number = -1;
|
||||
protected _fileSize: number = 0;
|
||||
protected _path: string;
|
||||
protected _file: string;
|
||||
|
||||
constructor (base: string, file: string, options: BaseDbOptions) {
|
||||
super();
|
||||
|
||||
this._file = file;
|
||||
this._path = path.join(base, file);
|
||||
this._isCompressed = options && !isUndefined(options.isCompressed)
|
||||
? options.isCompressed
|
||||
: false;
|
||||
|
||||
mkdirp.sync(base);
|
||||
}
|
||||
|
||||
protected assertOpen (open: boolean = true): void {
|
||||
const test = open
|
||||
? this._fd !== -1
|
||||
: this._fd === -1;
|
||||
|
||||
assert(test, `Expected ${open ? 'an open' : 'a closed'} database`);
|
||||
}
|
||||
|
||||
protected _close (): void {
|
||||
fs.closeSync(this._fd);
|
||||
|
||||
this._fd = -1;
|
||||
}
|
||||
|
||||
protected _open (file: string, startEmpty: boolean = false): void {
|
||||
const isExisting = fs.existsSync(file);
|
||||
|
||||
if (!isExisting || startEmpty) {
|
||||
if (isExisting) {
|
||||
fs.renameSync(file, `${file}.${Date.now()}`);
|
||||
}
|
||||
|
||||
fs.writeFileSync(file, Buffer.alloc(defaults.BRANCH_SIZE));
|
||||
}
|
||||
|
||||
this._fd = fs.openSync(file, 'r+');
|
||||
this._fileSize = fs.fstatSync(this._fd).size;
|
||||
}
|
||||
}
|
||||
@@ -1,248 +0,0 @@
|
||||
// Copyright 2017-2019 @polkadot/db authors & contributors
|
||||
// This software may be modified and distributed under the terms
|
||||
// of the Apache-2.0 license. See the LICENSE file for details.
|
||||
|
||||
import { Key, NibbleBuffer, Slot, Value } from './types';
|
||||
|
||||
import fs from 'fs';
|
||||
import { logger } from '@polkadot/util';
|
||||
|
||||
import Cache from './Cache';
|
||||
import defaults from './defaults';
|
||||
|
||||
const l = logger('db/flat');
|
||||
|
||||
export default class Impl extends Cache {
|
||||
protected _getKeyValue (keyAt: number): Buffer {
|
||||
return this._getCachedData(keyAt, defaults.KEY_TOTAL_SIZE);
|
||||
}
|
||||
|
||||
protected _retrieveBranch (doCreate: boolean, branch: Buffer, entryIndex: number, keyIndex: number, key: NibbleBuffer): Key | null {
|
||||
const nextBranchAt = branch.readUIntBE(entryIndex + 1, defaults.UINT_SIZE);
|
||||
|
||||
l.debug(() => ['findKey/isBranch', { nextBranchAt }]);
|
||||
|
||||
return this._findKey(key, doCreate, keyIndex + 1, nextBranchAt);
|
||||
}
|
||||
|
||||
protected _retrieveEmpty (doCreate: boolean, branch: Buffer, branchAt: number, entryIndex: number, key: NibbleBuffer): Key | null {
|
||||
l.debug(() => ['findKey/isEmpty']);
|
||||
|
||||
return doCreate
|
||||
? this.writeNewLeaf(branch, branchAt, entryIndex, key)
|
||||
: null;
|
||||
}
|
||||
|
||||
protected _retrieveLeaf (doCreate: boolean, branch: Buffer, branchAt: number, entryIndex: number, keyIndex: number, key: NibbleBuffer): Key | null {
|
||||
const keyAt = branch.readUIntBE(entryIndex + 1, defaults.UINT_SIZE);
|
||||
const keyValue = this._getKeyValue(keyAt);
|
||||
const prevKey = this._serializeKey(keyValue.subarray(0, defaults.KEY_SIZE));
|
||||
let matchIndex = keyIndex;
|
||||
|
||||
l.debug(() => ['findKey/isLeaf', { keyAt, branch, branchAt, entryIndex, keyValue }]);
|
||||
|
||||
while (matchIndex < defaults.KEY_PARTS_LENGTH) {
|
||||
if (prevKey.parts[matchIndex] !== key.parts[matchIndex]) {
|
||||
break;
|
||||
}
|
||||
|
||||
matchIndex++;
|
||||
}
|
||||
|
||||
if (matchIndex !== defaults.KEY_PARTS_LENGTH) {
|
||||
return doCreate
|
||||
? this.writeNewBranch(branch, branchAt, entryIndex, key, keyAt, prevKey, matchIndex, matchIndex - keyIndex - 1)
|
||||
: null;
|
||||
}
|
||||
|
||||
return {
|
||||
key,
|
||||
keyAt,
|
||||
keyValue
|
||||
};
|
||||
}
|
||||
|
||||
protected _findKey (key: NibbleBuffer, doCreate: boolean, keyIndex: number, branchAt: number): Key | null {
|
||||
const entryIndex = key.parts[keyIndex] * defaults.ENTRY_SIZE;
|
||||
const branch = this._getCachedBranch(branchAt);
|
||||
|
||||
l.debug(() => ['findKey', { key, doCreate, keyIndex, branchAt, branch, entryIndex }]);
|
||||
|
||||
const entryType = branch[entryIndex];
|
||||
|
||||
switch (entryType) {
|
||||
case Slot.BRANCH:
|
||||
return this._retrieveBranch(doCreate, branch, entryIndex, keyIndex, key);
|
||||
|
||||
case Slot.EMPTY:
|
||||
return this._retrieveEmpty(doCreate, branch, branchAt, entryIndex, key);
|
||||
|
||||
case Slot.LEAF:
|
||||
return this._retrieveLeaf(doCreate, branch, branchAt, entryIndex, keyIndex, key);
|
||||
|
||||
default:
|
||||
throw new Error(`Unhandled entry type ${entryType}`);
|
||||
}
|
||||
}
|
||||
|
||||
protected _extractValueInfo (keyValue: Buffer): { valueAt: number, valueLength: number } {
|
||||
return {
|
||||
valueLength: keyValue.readUIntBE(defaults.KEY_SIZE, defaults.UINT_SIZE),
|
||||
valueAt: keyValue.readUIntBE(defaults.KEY_SIZE + defaults.UINT_SIZE, defaults.UINT_SIZE)
|
||||
};
|
||||
}
|
||||
|
||||
protected _readValue (keyValue: Buffer): Value {
|
||||
l.debug(() => ['readValue', { keyValue }]);
|
||||
|
||||
const { valueAt, valueLength } = this._extractValueInfo(keyValue);
|
||||
const value = this._getCachedData(valueAt, valueLength);
|
||||
|
||||
return {
|
||||
value,
|
||||
valueAt
|
||||
};
|
||||
}
|
||||
|
||||
protected _writeValue (keyAt: number, keyValue: Buffer, value: Buffer): Value {
|
||||
// l.debug(() => ['writeValue', { keyAt, keyValue, value }]);
|
||||
|
||||
const current = this._extractValueInfo(keyValue);
|
||||
const valueAt = value.length > current.valueLength
|
||||
? this._writeNewBuffer(value)
|
||||
: this._writeUpdatedBuffer(value, current.valueAt);
|
||||
|
||||
keyValue.writeUIntBE(value.length, defaults.KEY_SIZE, defaults.UINT_SIZE);
|
||||
keyValue.writeUIntBE(valueAt, defaults.KEY_SIZE + defaults.UINT_SIZE, defaults.UINT_SIZE);
|
||||
fs.writeSync(this._fd, keyValue, defaults.KEY_SIZE, 2 * defaults.UINT_SIZE, keyAt + defaults.KEY_SIZE);
|
||||
|
||||
return {
|
||||
value,
|
||||
valueAt
|
||||
};
|
||||
}
|
||||
|
||||
protected _writeNewKey (key: NibbleBuffer): Key {
|
||||
// l.debug(() => ['writeNewKey', { key }]);
|
||||
|
||||
const keyValue = Buffer.alloc(defaults.KEY_TOTAL_SIZE);
|
||||
|
||||
keyValue.set(key.buffer, 0);
|
||||
|
||||
const keyAt = this._writeNewBuffer(keyValue);
|
||||
|
||||
return {
|
||||
key,
|
||||
keyAt,
|
||||
keyValue
|
||||
};
|
||||
}
|
||||
|
||||
protected writeNewKey (key: NibbleBuffer): Key {
|
||||
const result = this._writeNewKey(key);
|
||||
|
||||
l.debug(() => ['writeNewKey', '=>', { result }]);
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
protected _writeNewBranch (branch: Buffer, branchAt: number, entryIndex: number, key: NibbleBuffer, prevAt: number, prevKey: NibbleBuffer, matchIndex: number, depth: number): Key {
|
||||
// l.debug(() => ['writeNewBranch', { branch, branchAt, entryIndex, key, prevAt, prevKey, matchIndex, depth }]);
|
||||
|
||||
const { keyAt, keyValue } = this.writeNewKey(key);
|
||||
const keyIndex = key.parts[matchIndex] * defaults.ENTRY_SIZE;
|
||||
const prevIndex = prevKey.parts[matchIndex] * defaults.ENTRY_SIZE;
|
||||
const buffers: Array<Buffer> = [];
|
||||
let newBranchAt = this._fileSize;
|
||||
let newBranch = Buffer.alloc(defaults.BRANCH_SIZE);
|
||||
|
||||
newBranch.set([Slot.LEAF], keyIndex);
|
||||
newBranch.writeUIntBE(keyAt, keyIndex + 1, defaults.UINT_SIZE);
|
||||
newBranch.set([Slot.LEAF], prevIndex);
|
||||
newBranch.writeUIntBE(prevAt, prevIndex + 1, defaults.UINT_SIZE);
|
||||
buffers.push(newBranch);
|
||||
|
||||
for (let offset = 1; depth > 0; depth--, offset++) {
|
||||
const branchIndex = key.parts[matchIndex - offset] * defaults.ENTRY_SIZE;
|
||||
|
||||
newBranch = Buffer.alloc(defaults.BRANCH_SIZE);
|
||||
newBranch.set([Slot.BRANCH], branchIndex);
|
||||
newBranch.writeUIntBE(newBranchAt, branchIndex + 1, defaults.UINT_SIZE);
|
||||
buffers.push(newBranch);
|
||||
newBranchAt += defaults.BRANCH_SIZE;
|
||||
}
|
||||
|
||||
this._writeNewBuffers(buffers);
|
||||
|
||||
branch.set([Slot.BRANCH], entryIndex);
|
||||
branch.writeUIntBE(newBranchAt, entryIndex + 1, defaults.UINT_SIZE);
|
||||
fs.writeSync(this._fd, branch, entryIndex, defaults.ENTRY_SIZE, branchAt + entryIndex);
|
||||
|
||||
return { key, keyAt, keyValue };
|
||||
}
|
||||
|
||||
protected writeNewBranch (branch: Buffer, branchAt: number, entryIndex: number, key: NibbleBuffer, prevAt: number, prevValue: NibbleBuffer, matchIndex: number, depth: number): Key {
|
||||
const result = this._writeNewBranch(branch, branchAt, entryIndex, key, prevAt, prevValue, matchIndex, depth);
|
||||
|
||||
l.debug(() => ['writeNewBranch', '=>', { result }]);
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
protected _writeNewLeaf (branch: Buffer, branchAt: number, entryIndex: number, key: NibbleBuffer): Key {
|
||||
l.debug(() => ['writeNewLeaf', { branch, branchAt, entryIndex, key }]);
|
||||
|
||||
const { keyAt, keyValue } = this.writeNewKey(key);
|
||||
|
||||
branch.set([Slot.LEAF], entryIndex);
|
||||
branch.writeUIntBE(keyAt, entryIndex + 1, defaults.UINT_SIZE);
|
||||
|
||||
fs.writeSync(this._fd, branch, entryIndex, defaults.ENTRY_SIZE, branchAt + entryIndex);
|
||||
|
||||
return {
|
||||
key,
|
||||
keyAt,
|
||||
keyValue
|
||||
};
|
||||
}
|
||||
|
||||
protected writeNewLeaf (branch: Buffer, branchAt: number, entryIndex: number, key: NibbleBuffer): Key {
|
||||
const result = this._writeNewLeaf(branch, branchAt, entryIndex, key);
|
||||
|
||||
l.debug(() => ['writeNewLeaf', '=>', { result }]);
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
protected _writeUpdatedBuffer (buffer: Buffer, bufferAt: number): number {
|
||||
fs.writeSync(this._fd, buffer, 0, buffer.length, bufferAt);
|
||||
this._cacheData(bufferAt, buffer);
|
||||
|
||||
return bufferAt;
|
||||
}
|
||||
|
||||
protected _writeNewBuffer (buffer: Buffer, withCache: boolean = true): number {
|
||||
const startAt = this._fileSize;
|
||||
|
||||
fs.writeSync(this._fd, buffer, 0, buffer.length, startAt);
|
||||
|
||||
if (withCache) {
|
||||
this._cacheData(startAt, buffer);
|
||||
}
|
||||
|
||||
this._fileSize += buffer.length;
|
||||
|
||||
return startAt;
|
||||
}
|
||||
|
||||
protected _writeNewBuffers (buffers: Array<Buffer>): number {
|
||||
let bufferAt = this._fileSize;
|
||||
|
||||
buffers.forEach((buffer) => {
|
||||
this._cacheData(bufferAt, buffer);
|
||||
bufferAt += buffer.length;
|
||||
});
|
||||
|
||||
return this._writeNewBuffer(Buffer.concat(buffers), false);
|
||||
}
|
||||
}
|
||||
@@ -1,55 +0,0 @@
|
||||
// Copyright 2017-2019 @polkadot/db authors & contributors
|
||||
// This software may be modified and distributed under the terms
|
||||
// of the Apache-2.0 license. See the LICENSE file for details.
|
||||
|
||||
import { NibbleBuffer } from './types';
|
||||
|
||||
import snappy from 'snappy';
|
||||
import { toNibbles } from '@polkadot/trie-codec/util';
|
||||
import { assert, bufferToU8a, u8aToBuffer, u8aToHex } from '@polkadot/util';
|
||||
|
||||
import defaults from './defaults';
|
||||
|
||||
export default class Serialize {
|
||||
protected _isCompressed: boolean = false;
|
||||
|
||||
protected _deserializeValue (value: Buffer): Uint8Array | null {
|
||||
return bufferToU8a(
|
||||
this._isCompressed
|
||||
? snappy.uncompressSync(value)
|
||||
: value
|
||||
);
|
||||
}
|
||||
|
||||
protected _serializeValue (value: Uint8Array): Buffer {
|
||||
return this._isCompressed
|
||||
? snappy.compressSync(
|
||||
u8aToBuffer(value)
|
||||
)
|
||||
: u8aToBuffer(value);
|
||||
}
|
||||
|
||||
protected _serializeKey (u8a: Uint8Array): NibbleBuffer {
|
||||
assert(u8a.length <= defaults.KEY_SIZE, `${u8aToHex(u8a)} too large, expected <= 32 bytes`);
|
||||
|
||||
let buffer;
|
||||
let full;
|
||||
|
||||
if (u8a.length === defaults.KEY_SIZE) {
|
||||
full = u8a;
|
||||
} else {
|
||||
full = new Uint8Array(defaults.KEY_SIZE);
|
||||
|
||||
full.set(u8a, 0);
|
||||
}
|
||||
|
||||
buffer = u8aToBuffer(full);
|
||||
|
||||
return {
|
||||
buffer,
|
||||
parts: defaults.KEY_IS_NIBBLES
|
||||
? toNibbles(full)
|
||||
: full
|
||||
};
|
||||
}
|
||||
}
|
||||
@@ -1,54 +0,0 @@
|
||||
// Copyright 2017-2019 @polkadot/db authors & contributors
|
||||
// This software may be modified and distributed under the terms
|
||||
// of the Apache-2.0 license. See the LICENSE file for details.
|
||||
|
||||
import mkdirp from 'mkdirp';
|
||||
import path from 'path';
|
||||
import rimraf from 'rimraf';
|
||||
import { alexander } from '@polkadot/chainspec';
|
||||
import TrieDb from '@polkadot/trie-db';
|
||||
import { hexToU8a, u8aToHex } from '@polkadot/util';
|
||||
|
||||
import DiskDb from '../Disk';
|
||||
|
||||
describe.skip('DB via a trie', () => {
|
||||
const location = path.join(process.cwd(), '--test-FileFlatDb-ViaTrie');
|
||||
const { genesis: { raw }, genesisRoot } = alexander;
|
||||
|
||||
beforeAll(() => {
|
||||
rimraf.sync(location);
|
||||
mkdirp.sync(location);
|
||||
});
|
||||
|
||||
it('creates a trie with the correct root', () => {
|
||||
const trie = new TrieDb(new DiskDb(location, 'test.db', { isNative: true }));
|
||||
|
||||
trie.open();
|
||||
trie.transaction(() => {
|
||||
Object.keys(raw).forEach((key) => {
|
||||
trie.put(hexToU8a(key), hexToU8a(raw[key]));
|
||||
});
|
||||
|
||||
return true;
|
||||
});
|
||||
|
||||
expect(
|
||||
u8aToHex(trie.getRoot())
|
||||
).toEqual(genesisRoot);
|
||||
});
|
||||
|
||||
describe('re-opens and has all the correct keys', () => {
|
||||
const trie = new TrieDb(new DiskDb(location, 'test.db', { isNative: true }));
|
||||
|
||||
trie.open();
|
||||
trie.setRoot(hexToU8a(genesisRoot));
|
||||
|
||||
Object.keys(raw).forEach((key) => {
|
||||
it(key, () => {
|
||||
expect(
|
||||
u8aToHex(trie.get(hexToU8a(key)))
|
||||
).toEqual(raw[key]);
|
||||
});
|
||||
});
|
||||
});
|
||||
});
|
||||
@@ -1,46 +0,0 @@
|
||||
// Copyright 2017-2019 @polkadot/db authors & contributors
|
||||
// This software may be modified and distributed under the terms
|
||||
// of the Apache-2.0 license. See the LICENSE file for details.
|
||||
|
||||
// Allows for 1,099,511,627,776 filesize (max allowed here is 6 as per Nodejs)
|
||||
const UINT_SIZE = 5;
|
||||
const DEFAULT_FILE = 'store.db';
|
||||
const ONE_K = 1024;
|
||||
|
||||
// 16 for nibbles (key -> asNibbles), 256 for bytes (key -> asU8a)
|
||||
// There is a tradeof here:
|
||||
// - with nibbles there are more writes and more read branching traversals
|
||||
// - with bytes there are less writes, however more disk space
|
||||
const ENTRY_NUM: 16 | 256 = 16;
|
||||
const ENTRY_SIZE = 1 + UINT_SIZE;
|
||||
|
||||
// the size of a branch entry, 96 for nibbles, 1,536 for bytes
|
||||
const BRANCH_SIZE = ENTRY_NUM * ENTRY_SIZE;
|
||||
|
||||
// key calculations
|
||||
const KEY_IS_NIBBLES = (ENTRY_NUM as any) === 16;
|
||||
const KEY_SIZE = 32;
|
||||
const KEY_PARTS_LENGTH = KEY_IS_NIBBLES
|
||||
? KEY_SIZE * 2
|
||||
: KEY_SIZE;
|
||||
const KEY_TOTAL_SIZE = KEY_SIZE + UINT_SIZE + UINT_SIZE;
|
||||
|
||||
// LRU caches so things don't need to be read directly from disk when fresh
|
||||
const LRU_BRANCH_COUNT = KEY_IS_NIBBLES
|
||||
? 32 * ONE_K
|
||||
: 4 * ONE_K;
|
||||
const LRU_DATA_COUNT = 32 * ONE_K;
|
||||
|
||||
export default {
|
||||
BRANCH_SIZE,
|
||||
DEFAULT_FILE,
|
||||
ENTRY_NUM,
|
||||
ENTRY_SIZE,
|
||||
KEY_IS_NIBBLES,
|
||||
KEY_PARTS_LENGTH,
|
||||
KEY_SIZE,
|
||||
KEY_TOTAL_SIZE,
|
||||
LRU_BRANCH_COUNT,
|
||||
LRU_DATA_COUNT,
|
||||
UINT_SIZE
|
||||
};
|
||||
@@ -1,156 +0,0 @@
|
||||
// Copyright 2017-2019 @polkadot/db authors & contributors
|
||||
// This software may be modified and distributed under the terms
|
||||
// of the Apache-2.0 license. See the LICENSE file for details.
|
||||
|
||||
import mkdirp from 'mkdirp';
|
||||
import path from 'path';
|
||||
import rimraf from 'rimraf';
|
||||
|
||||
import FileFlatDb from '.';
|
||||
|
||||
const KEY_A = new Uint8Array([
|
||||
0x10, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
|
||||
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0
|
||||
]);
|
||||
const KEY_B = new Uint8Array([
|
||||
0x20, 2, 2, 2, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
|
||||
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0
|
||||
]);
|
||||
const KEY_C = new Uint8Array([
|
||||
0x10, 2, 6, 6, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
|
||||
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0
|
||||
]);
|
||||
const KEY_D = new Uint8Array([
|
||||
0x10, 2, 6, 7, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
|
||||
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0
|
||||
]);
|
||||
const KEY_E = new Uint8Array([
|
||||
0x10, 2, 4, 5, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
|
||||
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0
|
||||
]);
|
||||
const KEY_F = new Uint8Array([
|
||||
0x50, 2, 4, 5, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
|
||||
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0
|
||||
]);
|
||||
const VAL_A = new Uint8Array([0x42, 1, 0x69]);
|
||||
const VAL_B = new Uint8Array([0x42, 1, 2, 0x69]);
|
||||
const VAL_C = new Uint8Array([0x42, 1, 2, 3, 0x69]);
|
||||
const VAL_D = new Uint8Array([0x42, 1, 2, 3, 4, 0x69]);
|
||||
const VAL_E = new Uint8Array([0x42, 1, 2, 3, 4, 5, 0x69]);
|
||||
const VAL_F = new Uint8Array([0x42, 1, 2, 3, 4, 5, 6, 0x69]);
|
||||
|
||||
// NOTE Skipped, doesn't seem to be too happy on CI (cwd issues?)
|
||||
describe.skip('FileFlatDb (basics)', () => {
|
||||
const location = path.join(process.cwd(), '--test-FileFlatDb-index');
|
||||
let store: FileFlatDb;
|
||||
|
||||
const testGet = (key: Uint8Array, value: Uint8Array) =>
|
||||
expect(store.get(key)).toEqual(value);
|
||||
|
||||
beforeAll(() => {
|
||||
mkdirp.sync(location);
|
||||
|
||||
store = new FileFlatDb(location);
|
||||
store.open();
|
||||
});
|
||||
|
||||
afterAll(() => {
|
||||
store.close();
|
||||
rimraf.sync(location);
|
||||
});
|
||||
|
||||
it('writes an entry', () => {
|
||||
console.error('A: execute');
|
||||
|
||||
store.put(KEY_A, VAL_A);
|
||||
|
||||
console.error('A: expectations');
|
||||
|
||||
testGet(KEY_A, VAL_A);
|
||||
});
|
||||
|
||||
it('writes an entry (additional)', () => {
|
||||
console.error('B: execute');
|
||||
|
||||
store.put(KEY_B, VAL_B);
|
||||
|
||||
console.error('A: expectations');
|
||||
|
||||
testGet(KEY_A, VAL_A);
|
||||
testGet(KEY_B, VAL_B);
|
||||
});
|
||||
|
||||
it('writes an entry (expanding the tree)', () => {
|
||||
console.error('C: execute');
|
||||
|
||||
store.put(KEY_C, VAL_C);
|
||||
|
||||
console.error('C: expectations');
|
||||
|
||||
// testGet(KEY_A, VAL_A);
|
||||
// testGet(KEY_B, VAL_B);
|
||||
testGet(KEY_C, VAL_C);
|
||||
});
|
||||
|
||||
it('writes an entry (expanding the tree, again)', () => {
|
||||
console.error('D: execute');
|
||||
|
||||
store.put(KEY_D, VAL_D);
|
||||
|
||||
console.error('D: expectations');
|
||||
|
||||
testGet(KEY_A, VAL_A);
|
||||
testGet(KEY_B, VAL_B);
|
||||
testGet(KEY_C, VAL_C);
|
||||
testGet(KEY_D, VAL_D);
|
||||
});
|
||||
|
||||
it('writes an entry (expanding the tree, yet again)', () => {
|
||||
console.error('E: execute');
|
||||
|
||||
store.put(KEY_E, VAL_E);
|
||||
|
||||
console.error('E: expectations');
|
||||
|
||||
testGet(KEY_A, VAL_A);
|
||||
testGet(KEY_B, VAL_B);
|
||||
testGet(KEY_C, VAL_C);
|
||||
testGet(KEY_D, VAL_D);
|
||||
testGet(KEY_E, VAL_E);
|
||||
});
|
||||
|
||||
it('writes an entry, expanding the top-level', () => {
|
||||
console.error('F: execute');
|
||||
|
||||
store.put(KEY_F, VAL_F);
|
||||
|
||||
console.error('F: expectations');
|
||||
|
||||
testGet(KEY_A, VAL_A);
|
||||
testGet(KEY_B, VAL_B);
|
||||
testGet(KEY_C, VAL_C);
|
||||
testGet(KEY_D, VAL_D);
|
||||
testGet(KEY_E, VAL_E);
|
||||
testGet(KEY_F, VAL_F);
|
||||
});
|
||||
|
||||
it('overrides with smaller values', () => {
|
||||
console.error('G: execute');
|
||||
|
||||
store.put(KEY_F, VAL_A);
|
||||
|
||||
console.error('G: expectations');
|
||||
|
||||
testGet(KEY_F, VAL_A);
|
||||
});
|
||||
|
||||
it('overrides with larger values', () => {
|
||||
console.error('H: execute');
|
||||
|
||||
store.put(KEY_A, VAL_F);
|
||||
|
||||
console.error('H: expectations');
|
||||
|
||||
testGet(KEY_A, VAL_F);
|
||||
});
|
||||
});
|
||||
@@ -1,136 +0,0 @@
|
||||
// Copyright 2017-2019 @polkadot/db authors & contributors
|
||||
// This software may be modified and distributed under the terms
|
||||
// of the Apache-2.0 license. See the LICENSE file for details.
|
||||
|
||||
import { BaseDb, BaseDbOptions, ProgressCb } from '../types';
|
||||
import { Key, NibbleBuffer, Value } from './types';
|
||||
|
||||
import fs from 'fs';
|
||||
import path from 'path';
|
||||
import { logger } from '@polkadot/util';
|
||||
|
||||
import defaults from './defaults';
|
||||
import Compact from './Compact';
|
||||
import Impl from './Impl';
|
||||
|
||||
const l = logger('db/flat');
|
||||
|
||||
export default class FileFlatDb extends Impl implements BaseDb {
|
||||
constructor (base: string, file: string = defaults.DEFAULT_FILE, options: BaseDbOptions = {}) {
|
||||
super(base, file, options);
|
||||
}
|
||||
|
||||
open (): void {
|
||||
this.assertOpen(false);
|
||||
|
||||
this._open(this._path);
|
||||
this._lruBranch.clear();
|
||||
this._lruData.clear();
|
||||
}
|
||||
|
||||
close (): void {
|
||||
this.assertOpen();
|
||||
|
||||
this._close();
|
||||
this._lruBranch.clear();
|
||||
this._lruData.clear();
|
||||
}
|
||||
|
||||
drop (): void {
|
||||
this.assertOpen(false);
|
||||
|
||||
fs.unlinkSync(this._path);
|
||||
}
|
||||
|
||||
empty (): void {
|
||||
this.assertOpen(false);
|
||||
|
||||
this._open(this._path, true);
|
||||
}
|
||||
|
||||
size (): number {
|
||||
return this._fileSize;
|
||||
}
|
||||
|
||||
rename (base: string, file: string): void {
|
||||
this.assertOpen(false);
|
||||
|
||||
const oldPath = this._path;
|
||||
|
||||
this._file = file;
|
||||
this._path = path.join(base, file);
|
||||
|
||||
fs.renameSync(oldPath, this._path);
|
||||
}
|
||||
|
||||
maintain (fn: ProgressCb): void {
|
||||
this.assertOpen(false);
|
||||
|
||||
const compactor = new Compact(this._file);
|
||||
|
||||
compactor.maintain(fn);
|
||||
}
|
||||
|
||||
del (key: Uint8Array): void {
|
||||
throw new Error('delete not implemented, only stubbed');
|
||||
}
|
||||
|
||||
get (key: Uint8Array): Uint8Array | null {
|
||||
this.assertOpen();
|
||||
|
||||
l.debug(() => ['get', { key }]);
|
||||
|
||||
const desc = this.findKey(this._serializeKey(key), false);
|
||||
|
||||
if (!desc) {
|
||||
return null;
|
||||
}
|
||||
|
||||
const result = this.readValue(desc);
|
||||
|
||||
return result && result.value
|
||||
? this._deserializeValue(result.value)
|
||||
: null;
|
||||
}
|
||||
|
||||
put (key: Uint8Array, value: Uint8Array): void {
|
||||
this.assertOpen();
|
||||
|
||||
l.debug(() => ['set', { key, value }]);
|
||||
|
||||
const desc = this.findKey(this._serializeKey(key), true);
|
||||
|
||||
if (!desc) {
|
||||
throw new Error('Unable to create key');
|
||||
}
|
||||
|
||||
this.writeValue(
|
||||
desc,
|
||||
this._serializeValue(value)
|
||||
);
|
||||
}
|
||||
|
||||
protected findKey (key: NibbleBuffer, doCreate: boolean): Key | null {
|
||||
const result = this._findKey(key, doCreate, 0, 0);
|
||||
|
||||
l.debug(() => ['findKey', { result }]);
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
protected readValue ({ keyValue }: Key): Value {
|
||||
const result = this._readValue(keyValue);
|
||||
|
||||
l.debug(() => ['readValue', { result }]);
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
protected writeValue ({ keyAt, keyValue }: Key, value: Buffer): Value {
|
||||
const result = this._writeValue(keyAt, keyValue, value);
|
||||
|
||||
l.debug(() => ['writeValue', '=>', { result }]);
|
||||
|
||||
return result;
|
||||
}
|
||||
}
|
||||
@@ -1,25 +0,0 @@
|
||||
// Copyright 2017-2019 @polkadot/db authors & contributors
|
||||
// This software may be modified and distributed under the terms
|
||||
// of the Apache-2.0 license. See the LICENSE file for details.
|
||||
|
||||
export enum Slot {
|
||||
EMPTY = 0,
|
||||
BRANCH = 1,
|
||||
LEAF = 2
|
||||
}
|
||||
|
||||
export type NibbleBuffer = {
|
||||
buffer: Buffer,
|
||||
parts: Uint8Array
|
||||
};
|
||||
|
||||
export type Key = {
|
||||
key: NibbleBuffer,
|
||||
keyAt: number,
|
||||
keyValue: Buffer
|
||||
};
|
||||
|
||||
export type Value = {
|
||||
value: Buffer,
|
||||
valueAt: number
|
||||
};
|
||||
@@ -1,111 +0,0 @@
|
||||
// Copyright 2017-2019 @polkadot/db authors & contributors
|
||||
// This software may be modified and distributed under the terms
|
||||
// of the Apache-2.0 license. See the LICENSE file for details.
|
||||
|
||||
import { BaseDb, ProgressCb } from '../types';
|
||||
|
||||
import fs from 'fs';
|
||||
import mkdirp from 'mkdirp';
|
||||
import { bufferToU8a, logger, u8aToBuffer, u8aToHex } from '@polkadot/util';
|
||||
|
||||
type FilePath = {
|
||||
directory: string,
|
||||
file: string
|
||||
};
|
||||
|
||||
const DIR_DEPTH = 1;
|
||||
|
||||
const l = logger('db/tree');
|
||||
|
||||
export default class FileTreeDb implements BaseDb {
|
||||
_location: string;
|
||||
|
||||
constructor (location: string) {
|
||||
this._location = location;
|
||||
}
|
||||
|
||||
private _getFilePath (key: Uint8Array): FilePath {
|
||||
// NOTE We want to limit the number of entries in any specific directory. Split the
|
||||
// key into parts and use this to construct the path and the actual filename. We want
|
||||
// to limit the entries per directory, but at the same time minimize the number of
|
||||
// directories we need to create (when non-existent as well as the size overhead)
|
||||
const parts = u8aToHex(key).match(/.{1,6}/g) || [];
|
||||
const directory = `${this._location}/${parts.slice(0, DIR_DEPTH).join('/')}`;
|
||||
const file = `${directory}/${parts.slice(DIR_DEPTH).join('')}`;
|
||||
|
||||
return {
|
||||
directory,
|
||||
file
|
||||
};
|
||||
}
|
||||
|
||||
open (): void {
|
||||
// noop
|
||||
}
|
||||
|
||||
close (): void {
|
||||
// noop
|
||||
}
|
||||
|
||||
drop (): void {
|
||||
l.error('drop() is not implemented');
|
||||
}
|
||||
|
||||
empty (): void {
|
||||
l.error('empty() is not implemented');
|
||||
}
|
||||
|
||||
rename (base: string, file: string): void {
|
||||
l.error('rename() is not implemented');
|
||||
}
|
||||
|
||||
size (): number {
|
||||
l.error('size() is not implemented');
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
maintain (fn: ProgressCb): void {
|
||||
fn({
|
||||
isCompleted: true,
|
||||
keys: 0,
|
||||
percent: 100
|
||||
});
|
||||
}
|
||||
|
||||
del (key: Uint8Array): void {
|
||||
l.debug(() => ['del', { key }]);
|
||||
|
||||
const { file } = this._getFilePath(key);
|
||||
|
||||
if (fs.existsSync(file)) {
|
||||
fs.unlinkSync(file);
|
||||
}
|
||||
}
|
||||
|
||||
get (key: Uint8Array): Uint8Array | null {
|
||||
l.debug(() => ['get', { key }]);
|
||||
|
||||
const { file } = this._getFilePath(key);
|
||||
|
||||
if (!fs.existsSync(file)) {
|
||||
return null;
|
||||
}
|
||||
|
||||
return bufferToU8a(
|
||||
fs.readFileSync(file)
|
||||
);
|
||||
}
|
||||
|
||||
put (key: Uint8Array, value: Uint8Array): void {
|
||||
l.debug(() => ['set', { key, value }]);
|
||||
|
||||
const { directory, file } = this._getFilePath(key);
|
||||
|
||||
if (!fs.existsSync(directory)) {
|
||||
mkdirp.sync(directory);
|
||||
}
|
||||
|
||||
fs.writeFileSync(file, u8aToBuffer(value));
|
||||
}
|
||||
}
|
||||
@@ -1,162 +0,0 @@
|
||||
// Copyright 2017-2019 @polkadot/db authors & contributors
|
||||
// This software may be modified and distributed under the terms
|
||||
// of the Apache-2.0 license. See the LICENSE file for details.
|
||||
|
||||
import { BaseDb, BaseDbOptions, ProgressCb } from '../types';
|
||||
|
||||
import fs from 'fs';
|
||||
import mkdirp from 'mkdirp';
|
||||
import lmdb from 'node-lmdb';
|
||||
import path from 'path';
|
||||
import { bufferToU8a, logger, u8aToBuffer } from '@polkadot/util';
|
||||
|
||||
const GB = 1 * 1024 * 1024 * 1024;
|
||||
|
||||
const l = logger('db/lmdb');
|
||||
|
||||
// NOTE we manage 2 transaction types, one for read and one for write. For
|
||||
// triedbs we assume that the transaction _only_ contains writes (managed by
|
||||
// the transaction overlay). At the same time have a read that we keep open
|
||||
// so we don't need to re-create the transaction, otherwise wastefull.
|
||||
//
|
||||
// There is reasoning behind this madness, reads cannot overlap with writes,
|
||||
// so the database grows more than needed while making actual reads interleaved
|
||||
// with writes. So manage these completely seperately.
|
||||
export default class LmDb implements BaseDb {
|
||||
private _env: any;
|
||||
private _dbi: any | null;
|
||||
private _path: string;
|
||||
private _rtxn: any | null;
|
||||
private _wtxn: any | null;
|
||||
|
||||
constructor (base: string, name: string, options?: BaseDbOptions) {
|
||||
this._env = new lmdb.Env();
|
||||
this._path = path.join(base, name);
|
||||
this._rtxn = null;
|
||||
this._wtxn = null;
|
||||
|
||||
mkdirp.sync(this._path);
|
||||
|
||||
const dbsize = this.size(true);
|
||||
const mapSize = Math.ceil(1 + (dbsize / GB)) * GB;
|
||||
|
||||
l.debug(() => `Current mapsize set to ${(mapSize / GB).toFixed(1)}GB`);
|
||||
|
||||
this._env.open({
|
||||
path: this._path,
|
||||
mapSize
|
||||
});
|
||||
}
|
||||
|
||||
private getNextMapSize (): number {
|
||||
const dbsize = this.size();
|
||||
const mapSize = this._env.info().mapSize;
|
||||
const remaining = (mapSize - dbsize) / GB;
|
||||
|
||||
return (remaining < 0.25)
|
||||
? (mapSize + GB)
|
||||
: mapSize;
|
||||
}
|
||||
|
||||
private growMapSize (): void {
|
||||
const info = this._env.info();
|
||||
const next = this.getNextMapSize();
|
||||
|
||||
if (next > info.mapSize) {
|
||||
l.debug(() => `Growing mapsize to ${(next / GB).toFixed(1)}GB`);
|
||||
|
||||
this._env.resize(next);
|
||||
}
|
||||
}
|
||||
|
||||
close (): void {
|
||||
this.exitRead();
|
||||
|
||||
this._dbi.close();
|
||||
this._dbi = null;
|
||||
this._env.close();
|
||||
}
|
||||
|
||||
open (): void {
|
||||
this._dbi = this._env.openDbi({
|
||||
create: true,
|
||||
keyIsBuffer: true
|
||||
});
|
||||
|
||||
this.enterRead();
|
||||
}
|
||||
|
||||
drop (): void {
|
||||
throw new Error('drop() not implemented');
|
||||
}
|
||||
|
||||
empty (): void {
|
||||
throw new Error('empty() not implemented');
|
||||
}
|
||||
|
||||
maintain (fn: ProgressCb): void {
|
||||
fn({
|
||||
isCompleted: true,
|
||||
keys: 0,
|
||||
percent: 100
|
||||
});
|
||||
}
|
||||
|
||||
rename (base: string, file: string): void {
|
||||
// nothing
|
||||
}
|
||||
|
||||
size (withExistsSync: boolean = false): number {
|
||||
const db = path.join(this._path, 'data.mdb');
|
||||
|
||||
return !withExistsSync || fs.existsSync(db)
|
||||
? fs.statSync(db).size
|
||||
: 0;
|
||||
}
|
||||
|
||||
private enterRead (): void {
|
||||
this._rtxn = this._env.beginTxn({ readOnly: true });
|
||||
}
|
||||
|
||||
private exitRead (): void {
|
||||
this._rtxn.abort();
|
||||
this._rtxn = null;
|
||||
}
|
||||
|
||||
txCommit (): void {
|
||||
this._wtxn.commit();
|
||||
this._wtxn = null;
|
||||
this.enterRead();
|
||||
}
|
||||
|
||||
txRevert (): void {
|
||||
this._wtxn.abort();
|
||||
this._wtxn = null;
|
||||
this.enterRead();
|
||||
}
|
||||
|
||||
txStart (): void {
|
||||
this.exitRead();
|
||||
|
||||
// grow between transactions
|
||||
this.growMapSize();
|
||||
|
||||
this._wtxn = this._env.beginTxn();
|
||||
}
|
||||
|
||||
del (key: Uint8Array): void {
|
||||
this._wtxn.del(this._dbi, u8aToBuffer(key));
|
||||
}
|
||||
|
||||
get (_key: Uint8Array): Uint8Array | null {
|
||||
const value = this._rtxn.getBinary(this._dbi, u8aToBuffer(_key));
|
||||
|
||||
return value
|
||||
? bufferToU8a(value)
|
||||
: null;
|
||||
}
|
||||
|
||||
put (key: Uint8Array, value: Uint8Array): void {
|
||||
this._wtxn.putBinary(this._dbi, u8aToBuffer(key), u8aToBuffer(value));
|
||||
}
|
||||
}
|
||||
-1
@@ -1 +0,0 @@
|
||||
declare module 'node-lmdb';
|
||||
@@ -1,64 +0,0 @@
|
||||
// Copyright 2017-2019 @polkadot/db authors & contributors
|
||||
// This software may be modified and distributed under the terms
|
||||
// of the Apache-2.0 license. See the LICENSE file for details.
|
||||
|
||||
import mkdirp from 'mkdirp';
|
||||
import os from 'os';
|
||||
import path from 'path';
|
||||
import stringToU8a from '@polkadot/util/string/toU8a';
|
||||
|
||||
import LevelDb from './LevelDb';
|
||||
|
||||
describe.skip('LevelDb', () => {
|
||||
const base = path.join(os.tmpdir(), '--test--');
|
||||
const name = 'LevelDb';
|
||||
const location = path.join(base, name);
|
||||
let db;
|
||||
|
||||
beforeAll(() => {
|
||||
db = new LevelDb(base, name);
|
||||
db.open();
|
||||
});
|
||||
|
||||
afterAll(() => {
|
||||
db.close();
|
||||
rimraf.sync(location);
|
||||
});
|
||||
|
||||
it('sets & retrieves', () => {
|
||||
const key = stringToU8a('key0');
|
||||
const value = stringToU8a('value0');
|
||||
|
||||
db.put(key, value);
|
||||
|
||||
expect(db.get(key)).toEqual(value);
|
||||
});
|
||||
|
||||
it('retrieves null for non-existing', () => {
|
||||
const key = stringToU8a('key1');
|
||||
|
||||
expect(db.get(key)).toEqual(null);
|
||||
});
|
||||
|
||||
it('overrides values', () => {
|
||||
const key = stringToU8a('key2');
|
||||
const value = stringToU8a('value1');
|
||||
const replace = stringToU8a('value2');
|
||||
|
||||
db.put(key, value);
|
||||
|
||||
expect(db.get(key)).toEqual(value);
|
||||
|
||||
db.put(key, replace);
|
||||
|
||||
expect(db.get(key)).toEqual(replace);
|
||||
});
|
||||
|
||||
it('deletes values', () => {
|
||||
const key = stringToU8a('key2');
|
||||
|
||||
db.del(key);
|
||||
|
||||
expect(db.get(key)).toEqual(null);
|
||||
});
|
||||
});
|
||||
@@ -1,109 +0,0 @@
|
||||
// Copyright 2017-2019 @polkadot/db authors & contributors
|
||||
// This software may be modified and distributed under the terms
|
||||
// of the Apache-2.0 license. See the LICENSE file for details.
|
||||
|
||||
"nosql-leveldb": "^3.0.1",
|
||||
|
||||
import { BaseDb, ProgressCb } from '../types';
|
||||
|
||||
import leveldb, { LevelDb } from 'nosql-leveldb';
|
||||
import mkdirp from 'mkdirp';
|
||||
import path from 'path';
|
||||
// import snappy from 'snappy';
|
||||
import logger from '@polkadot/util/logger';
|
||||
import stringToU8a from '@polkadot/util/u8a/fromUtf8';
|
||||
import u8aToString from '@polkadot/util/u8a/toUtf8';
|
||||
// import u8aToHex from '@polkadot/util/u8a/toHex';
|
||||
|
||||
// import assert from '@polkadot/util/assert';
|
||||
// import u8aToHex from '@polkadot/util/u8a/toHex';
|
||||
|
||||
const l = logger('db/leveldb');
|
||||
|
||||
// NOTE Looking at the implementation, the getSync does a new Buffer when requested as a Buffer.
|
||||
// With this in mind, we always work with utf8 strings as encoded - serializing/deserializing
|
||||
// on the way in and out
|
||||
|
||||
export default class Level implements BaseDb {
|
||||
private db: LevelDb;
|
||||
|
||||
constructor (base: string, name: string) {
|
||||
const location = path.join(base, name);
|
||||
|
||||
mkdirp.sync(location);
|
||||
|
||||
this.db = leveldb(location);
|
||||
}
|
||||
|
||||
close (): void {
|
||||
l.debug(() => ['close']);
|
||||
|
||||
this.db.closeSync();
|
||||
}
|
||||
|
||||
open (): void {
|
||||
l.debug(() => ['open']);
|
||||
|
||||
this.db.openSync({
|
||||
createIfMissing: true
|
||||
});
|
||||
}
|
||||
|
||||
maintain (fn: ProgressCb): void {
|
||||
fn({
|
||||
isCompleted: true,
|
||||
keys: 0,
|
||||
percent: 100
|
||||
});
|
||||
}
|
||||
|
||||
del (key: Uint8Array): void {
|
||||
this.db.delSync(
|
||||
this._serializeKey(key)
|
||||
);
|
||||
}
|
||||
|
||||
get (key: Uint8Array): Uint8Array | null {
|
||||
try {
|
||||
return this._deserializeValue(
|
||||
this.db.getSync(
|
||||
this._serializeKey(key),
|
||||
{ asBuffer: false }
|
||||
) as string
|
||||
);
|
||||
} catch (error) {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
put (key: Uint8Array, value: Uint8Array): void {
|
||||
this.db.putSync(
|
||||
this._serializeKey(key),
|
||||
this._serializeValue(value)
|
||||
);
|
||||
}
|
||||
|
||||
private _deserializeValue (value: string): Uint8Array | null {
|
||||
return value
|
||||
? stringToU8a(value)
|
||||
: null;
|
||||
// return value
|
||||
// ? bufferToU8a(value)
|
||||
// // ? bufferToU8a(
|
||||
// // snappy.uncompressSync(value)
|
||||
// // )
|
||||
// : null;
|
||||
}
|
||||
|
||||
private _serializeKey (key: Uint8Array): string {
|
||||
return u8aToString(key);
|
||||
}
|
||||
|
||||
private _serializeValue (value: Uint8Array): string {
|
||||
return u8aToString(value);
|
||||
|
||||
// return snappy.compressSync(
|
||||
// u8aToBuffer(value)
|
||||
// );
|
||||
}
|
||||
}
|
||||
@@ -1,64 +0,0 @@
|
||||
// Copyright 2017-2019 @polkadot/db authors & contributors
|
||||
// This software may be modified and distributed under the terms
|
||||
// of the Apache-2.0 license. See the LICENSE file for details.
|
||||
|
||||
import os from 'os';
|
||||
import path from 'path';
|
||||
import rimraf from 'rimraf';
|
||||
import { stringToU8a } from '@polkadot/util';
|
||||
|
||||
import RocksDb from '../RocksDb';
|
||||
|
||||
describe.skip('RocksDb', () => {
|
||||
const base = path.join(os.tmpdir(), '--test--');
|
||||
const name = 'RocksDb';
|
||||
const location = path.join(base, name);
|
||||
let db: any;
|
||||
|
||||
beforeAll(() => {
|
||||
db = new RocksDb(base, name);
|
||||
db.open();
|
||||
});
|
||||
|
||||
afterAll(() => {
|
||||
db.close();
|
||||
rimraf.sync(location);
|
||||
});
|
||||
|
||||
it('sets & retrieves', () => {
|
||||
const key = stringToU8a('key0');
|
||||
const value = stringToU8a('value0');
|
||||
|
||||
db.put(key, value);
|
||||
|
||||
expect(db.get(key)).toEqual(value);
|
||||
});
|
||||
|
||||
it('retrieves null for non-existing', () => {
|
||||
const key = stringToU8a('key1');
|
||||
|
||||
expect(db.get(key)).toEqual(null);
|
||||
});
|
||||
|
||||
it('overrides values', () => {
|
||||
const key = stringToU8a('key2');
|
||||
const value = stringToU8a('value1');
|
||||
const replace = stringToU8a('value2');
|
||||
|
||||
db.put(key, value);
|
||||
|
||||
expect(db.get(key)).toEqual(value);
|
||||
|
||||
db.put(key, replace);
|
||||
|
||||
expect(db.get(key)).toEqual(replace);
|
||||
});
|
||||
|
||||
it('deletes values', () => {
|
||||
const key = stringToU8a('key2');
|
||||
|
||||
db.del(key);
|
||||
|
||||
expect(db.get(key)).toEqual(null);
|
||||
});
|
||||
});
|
||||
@@ -1,121 +0,0 @@
|
||||
// Copyright 2017-2019 @polkadot/db authors & contributors
|
||||
// This software may be modified and distributed under the terms
|
||||
// of the Apache-2.0 license. See the LICENSE file for details.
|
||||
|
||||
// At this point, it doesn't seem to write anything to disk, so subsequent startups
|
||||
// has an empty database - again. Something is wrong in the config and with
|
||||
// life being too short...
|
||||
|
||||
// "rocksdb-node": "jacogr/rocksdb-node#00ebfdbf0462ee615f4f48f1db403fd4df8471ea",
|
||||
|
||||
import { BaseDb, ProgressCb } from '../types';
|
||||
|
||||
import rocksdb, { RocksDb } from 'rocksdb-node';
|
||||
import mkdirp from 'mkdirp';
|
||||
import path from 'path';
|
||||
// import snappy from 'snappy';
|
||||
import { bufferToU8a, logger, u8aToBuffer, u8aToHex } from '@polkadot/util';
|
||||
|
||||
const l = logger('db/rocksdb');
|
||||
|
||||
const OPEN_OPTIONS = {
|
||||
allow_mmap_reads: true,
|
||||
allow_mmap_writes: true,
|
||||
bytes_per_sync: 1 * 1024 * 1024, // 1MB default
|
||||
create_if_missing: true
|
||||
};
|
||||
|
||||
export default class Rocks implements BaseDb {
|
||||
private db: RocksDb;
|
||||
|
||||
constructor (base: string, name: string) {
|
||||
const location = path.join(base, name);
|
||||
|
||||
mkdirp.sync(location);
|
||||
|
||||
this.db = rocksdb.open(OPEN_OPTIONS, location);
|
||||
}
|
||||
|
||||
close (): void {
|
||||
l.debug(() => ['close']);
|
||||
|
||||
this.db.close();
|
||||
}
|
||||
|
||||
drop (): void {
|
||||
throw new Error('unimplemented');
|
||||
}
|
||||
|
||||
empty (): void {
|
||||
throw new Error('unimplemented');
|
||||
}
|
||||
|
||||
open (): void {
|
||||
l.debug(() => ['open']);
|
||||
}
|
||||
|
||||
maintain (fn: ProgressCb): void {
|
||||
fn({
|
||||
isCompleted: true,
|
||||
keys: 0,
|
||||
percent: 100
|
||||
});
|
||||
}
|
||||
|
||||
rename (base: string, file: string): void {
|
||||
// nothing
|
||||
}
|
||||
|
||||
del (key: Uint8Array): void {
|
||||
this.db.del(
|
||||
{},
|
||||
this._serializeKey(key)
|
||||
);
|
||||
}
|
||||
|
||||
get (key: Uint8Array): Uint8Array | null {
|
||||
try {
|
||||
return this._deserializeValue(
|
||||
this.db.get(
|
||||
{ buffer: true },
|
||||
this._serializeKey(key)
|
||||
) as Buffer
|
||||
);
|
||||
} catch (error) {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
put (key: Uint8Array, value: Uint8Array): void {
|
||||
this.db.put(
|
||||
{},
|
||||
this._serializeKey(key),
|
||||
this._serializeValue(value)
|
||||
);
|
||||
}
|
||||
|
||||
size (): number {
|
||||
return 0;
|
||||
}
|
||||
|
||||
private _deserializeValue (value: Buffer): Uint8Array | null {
|
||||
return value && value.length
|
||||
? bufferToU8a(value)
|
||||
// ? bufferToU8a(
|
||||
// snappy.uncompressSync(value)
|
||||
// )
|
||||
: null;
|
||||
}
|
||||
|
||||
private _serializeKey (key: Uint8Array): string {
|
||||
return u8aToHex(key);
|
||||
}
|
||||
|
||||
private _serializeValue (value: Uint8Array): Buffer {
|
||||
return u8aToBuffer(value);
|
||||
|
||||
// return snappy.compressSync(
|
||||
// u8aToBuffer(value)
|
||||
// );
|
||||
}
|
||||
}
|
||||
@@ -30,7 +30,7 @@
|
||||
},
|
||||
"homepage": "https://github.com/polkadot-js/common/tree/master/packages/keyring#readme",
|
||||
"dependencies": {
|
||||
"@babel/runtime": "^7.4.2",
|
||||
"@babel/runtime": "^7.4.3",
|
||||
"@polkadot/util": "^0.76.0-beta.6",
|
||||
"@polkadot/util-crypto": "^0.76.0-beta.6",
|
||||
"@types/bs58": "^4.0.0",
|
||||
|
||||
@@ -28,7 +28,7 @@
|
||||
},
|
||||
"homepage": "https://github.com/polkadot-js/common/tree/master/packages/trie-codec#readme",
|
||||
"dependencies": {
|
||||
"@babel/runtime": "^7.4.2",
|
||||
"@babel/runtime": "^7.4.3",
|
||||
"@polkadot/util": "^0.76.0-beta.6"
|
||||
}
|
||||
}
|
||||
|
||||
@@ -28,7 +28,7 @@
|
||||
},
|
||||
"homepage": "https://github.com/polkadot-js/common/tree/master/packages/trie-db#readme",
|
||||
"dependencies": {
|
||||
"@babel/runtime": "^7.4.2",
|
||||
"@babel/runtime": "^7.4.3",
|
||||
"@polkadot/db": "^0.76.0-beta.6",
|
||||
"@polkadot/trie-codec": "^0.76.0-beta.6",
|
||||
"@polkadot/trie-hash": "^0.76.0-beta.6",
|
||||
|
||||
@@ -28,7 +28,7 @@
|
||||
},
|
||||
"homepage": "https://github.com/polkadot-js/common/tree/master/packages/trie-hash#readme",
|
||||
"dependencies": {
|
||||
"@babel/runtime": "^7.4.2",
|
||||
"@babel/runtime": "^7.4.3",
|
||||
"@polkadot/util": "^0.76.0-beta.6"
|
||||
},
|
||||
"devDependencies": {
|
||||
|
||||
@@ -28,7 +28,7 @@
|
||||
},
|
||||
"homepage": "https://github.com/polkadot-js/common/tree/master/packages/util-crypto#readme",
|
||||
"dependencies": {
|
||||
"@babel/runtime": "^7.4.2",
|
||||
"@babel/runtime": "^7.4.3",
|
||||
"@polkadot/util": "^0.76.0-beta.6",
|
||||
"@polkadot/wasm-crypto": "^0.8.1",
|
||||
"@types/bip39": "^2.4.2",
|
||||
|
||||
@@ -30,7 +30,7 @@
|
||||
},
|
||||
"homepage": "https://github.com/polkadot-js/common/tree/master/packages/util-rlp#readme",
|
||||
"dependencies": {
|
||||
"@babel/runtime": "^7.4.2",
|
||||
"@babel/runtime": "^7.4.3",
|
||||
"@polkadot/util": "^0.76.0-beta.6"
|
||||
},
|
||||
"devDependencies": {
|
||||
|
||||
@@ -28,12 +28,12 @@
|
||||
},
|
||||
"homepage": "https://github.com/polkadot-js/common/tree/master/packages/util#readme",
|
||||
"dependencies": {
|
||||
"@babel/runtime": "^7.4.2",
|
||||
"@types/bn.js": "^4.11.4",
|
||||
"@babel/runtime": "^7.4.3",
|
||||
"@types/bn.js": "^4.11.5",
|
||||
"@types/deasync": "^0.1.0",
|
||||
"@types/ip-regex": "^3.0.0",
|
||||
"bn.js": "^4.11.8",
|
||||
"camelcase": "^5.2.0",
|
||||
"camelcase": "^5.3.0",
|
||||
"chalk": "^2.4.2",
|
||||
"ip-regex": "^4.0.0",
|
||||
"moment": "^2.24.0"
|
||||
|
||||
Reference in New Issue
Block a user