Constructor
(abstract) new Indexer(module, options)
Create an indexer.
Extends:
- EventEmitter
Parameters:
Name | Type | Description |
---|---|---|
module |
String | |
options |
Object |
- Source:
Extends
- EventEmitter
Methods
(async, private) _addBlock(meta, block, view) → {Promise}
Add a block's transactions without a lock.
Parameters:
Name | Type | Description |
---|---|---|
meta |
BlockMeta | |
block |
Block | |
view |
CoinView |
- Source:
Returns:
- Type
- Promise
(async, private) _removeBlock(meta, block, view) → {Promise}
Unconfirm a block's transactions.
Parameters:
Name | Type | Description |
---|---|---|
meta |
BlockMeta | |
block |
Block | |
view |
CoinView |
- Source:
Returns:
- Type
- Promise
(async) _rollback(height) → {Promise}
Rollback to a given chain height.
Parameters:
Name | Type | Description |
---|---|---|
height |
Number |
- Source:
Returns:
- Type
- Promise
(async, private) _rollforward() → {Promise}
Scan blockchain to the best chain height.
- Source:
Returns:
- Type
- Promise
(async) _setTip(tip) → {Promise}
Update the current height to tip.
Parameters:
Name | Type | Description |
---|---|---|
tip |
BlockMeta |
- Source:
Returns:
- Type
- Promise
(async, private) _syncBlock(meta, block, view) → {Promise}
Sync with the chain with a block.
Parameters:
Name | Type | Description |
---|---|---|
meta |
BlockMeta | |
block |
Block | |
view |
CoinView |
- Source:
Returns:
- Type
- Promise
(async, private) _syncChain() → {Promise}
Sync with the chain.
- Source:
Returns:
- Type
- Promise
(private) bind()
Bind to chain events and save listeners for removal on close
- Source:
(async) close() → {Promise}
Close the indexer, wait for the database to close, unbind all events.
- Source:
Returns:
- Type
- Promise
(async) commit() → {Promise}
Commit the current batch.
- Source:
Returns:
- Type
- Promise
del(key)
Delete key from the current batch.
Parameters:
Name | Type | Description |
---|---|---|
key |
String |
- Source:
(async) ensure() → {Promise}
Ensure prefix directory (prefix/index).
- Source:
Returns:
- Type
- Promise
(async) getBlockMeta(hash) → {Promise}
Get a index block meta.
Parameters:
Name | Type | Description |
---|---|---|
hash |
Hash |
- Source:
Returns:
- Type
- Promise
(async, private) getEntry() → {Promise}
Get a chain entry for the main chain only.
- Source:
Returns:
- Type
- Promise
(async) indexBlock(meta, block, view) → {Promise}
Process block indexing Indexers will implement this method to process the block for indexing
Parameters:
Name | Type | Description |
---|---|---|
meta |
BlockMeta | |
block |
Block | |
view |
CoinView |
- Source:
Returns:
- Type
- Promise
(private) isSlow() → {Boolean}
Test whether the indexer has reached its slow height.
- Source:
Returns:
- Type
- Boolean
(private) logStatus(start, block, meta, reverse)
Log the current indexer status.
Parameters:
Name | Type | Description |
---|---|---|
start |
Array | |
block |
Block | |
meta |
BlockMeta | |
reverse |
Boolean |
- Source:
(async) open() → {Promise}
Open the indexer, open the database, initialize height, and bind to events.
- Source:
Returns:
- Type
- Promise
(async) pruneBlock(meta, block, view) → {Promise}
Prune block indexing Indexers will implement this method to prune indexing for the block
Parameters:
Name | Type | Description |
---|---|---|
meta |
BlockMeta | |
block |
Block | |
view |
CoinView |
- Source:
Returns:
- Type
- Promise
put(key, value)
Put key and value to the current batch.
Parameters:
Name | Type | Description |
---|---|---|
key |
String | |
value |
Buffer |
- Source:
(async, private) saveGenesis() → {Promise}
A special case for indexing the genesis block. The genesis block coins are not spendable, however indexers can still index the block for historical and informational purposes.
- Source:
Returns:
- Type
- Promise
start() → {Batch}
Start a new batch write.
- Source:
Returns:
- Type
- Batch
(async) sync(meta, block, view) → {Promise}
Sync with the chain.
Parameters:
Name | Type | Description |
---|---|---|
meta |
BlockMeta | |
block |
Block | |
view |
CoinView |
- Source:
Returns:
- Type
- Promise
(async) unindexBlock(meta, block, view) → {Promise}
Undo block indexing Indexers will implement this method to undo indexing for the block
Parameters:
Name | Type | Description |
---|---|---|
meta |
BlockMeta | |
block |
Block | |
view |
CoinView |
- Source:
Returns:
- Type
- Promise
(async) verifyNetwork() → {Promise}
Verify network of index.
- Source:
Returns:
- Type
- Promise