UNPKG

@ocap/indexdb-fs

Version:

OCAP indexdb adapter that uses file system as backend

36 lines (28 loc) 1.33 kB
const BaseIndexDB = require('@ocap/indexdb-memory/lib/db/base'); const { md5 } = require('@ocap/util/lib/md5'); const Table = require('./table/base'); const Transaction = require('./table/transaction'); const { name, version } = require('../package.json'); class FsIndexDB extends BaseIndexDB { constructor(dataDir) { super(); this.name = name; this.version = version; this.md5 = md5; this.account = new Table('account', dataDir, 'address'); this.asset = new Table('asset', dataDir, 'address'); this.factory = new Table('factory', dataDir, 'address'); this.delegation = new Table('delegation', dataDir, 'address'); this.tx = new Transaction('tx', dataDir, 'hash'); this.token = new Table('token', dataDir, 'address'); this.stake = new Table('stake', dataDir, 'address'); this.rollup = new Table('rollup', dataDir, 'address'); this.rollupBlock = new Table('rollupBlock', dataDir, 'hash'); this.rollupValidator = new Table('rollupValidator', dataDir, 'address'); this.tokenDistribution = new Table('tokenDistribution', dataDir, 'tokenAddress'); this.balance = new Table('balance', dataDir, ['address', 'tokenAddress']); this.tokenFactory = new Table('tokenFactory', dataDir, 'address'); this.attachReadyListeners(); } } module.exports = FsIndexDB;