module indexer introduces a extensible architecture for indexing the chain. It provides a base class which handles syncing with the chain, handling re-orgs, interruptions, dynamic toggling, etc. TXIndexer and AddrIndexer are provided for indexing transactions and addresses, using the same flags as before i.e --index-tx and --index-address. Indexes are stored in a different database and can be maintained independently of the chain.
32 lines
516 B
JavaScript
32 lines
516 B
JavaScript
/*!
|
|
* layout.js - indexer layout for bcoin
|
|
* Copyright (c) 2018, the bcoin developers (MIT License).
|
|
* https://github.com/bcoin-org/bcoin
|
|
*/
|
|
|
|
'use strict';
|
|
|
|
const bdb = require('bdb');
|
|
|
|
/*
|
|
* Index Database Layout:
|
|
* To be extended by indexer implementations
|
|
* V -> db version
|
|
* O -> flags
|
|
* h[height] -> recent block hash
|
|
* R -> chain sync state
|
|
*/
|
|
|
|
const layout = {
|
|
V: bdb.key('V'),
|
|
O: bdb.key('O'),
|
|
h: bdb.key('h', ['uint32']),
|
|
R: bdb.key('R')
|
|
};
|
|
|
|
/*
|
|
* Expose
|
|
*/
|
|
|
|
module.exports = layout;
|