@ocap/indexdb-memory
Version:
OCAP indexdb adapter that uses memory as backend, just for test purpose
37 lines (29 loc) • 1.24 kB
JavaScript
/* eslint-disable newline-per-chained-call */
const { md5 } = require('@ocap/util/lib/md5');
const BaseIndexDB = require('./base');
const Table = require('../table/base');
const Transaction = require('../table/transaction');
const { name, version } = require('../../package.json');
class MemoryIndexDB extends BaseIndexDB {
constructor() {
super();
this.name = name;
this.version = version;
this.md5 = md5;
this.account = new Table('account', 'address');
this.asset = new Table('asset', 'address');
this.delegation = new Table('delegation', 'address');
this.tx = new Transaction('tx', 'hash');
this.factory = new Table('factory', 'address');
this.token = new Table('token', 'address');
this.stake = new Table('stake', 'address');
this.rollup = new Table('rollup', 'address');
this.rollupBlock = new Table('rollupBlock', 'hash');
this.rollupValidator = new Table('rollupValidator', 'address');
this.tokenDistribution = new Table('tokenDistribution', 'tokenAddress');
this.balance = new Table('balance', ['address', 'tokenAddress']);
this.tokenFactory = new Table('tokenFactory', 'address');
this.attachReadyListeners();
}
}
module.exports = MemoryIndexDB;