The Blockchain Indexer service, in the indexing mode, is primarily responsible to index all t he blockchain information, based on the scheduled jobs by the Blockchain Coordinator. In the data service mode, it serves user request queries made via the RESTful API or WebSocke t-based RPC calls. It can run both the indexer and data service modes simultaneously, and is enabled by default.
This microservice encapsulates most of the business logic for the Lisk Service API. By default,
it only implements the business logic for all the available commands from the Lisk SDK.
The applyTransaction and revertTransaction hooks implement the indexing logic and are speci
fic to each available command. The applyTransaction is triggered when processing an included
transaction within a new block while (usually) indexing the chain_newBlock event. The revert
Transaction hook is triggered when processing an included transaction within a deleted block w
hile processing the chain_deleteBlock event. All the implemented hooks are grouped [here](./s
hared/indexer/transactionProcessor). Command specific hooks are always implemented within a sin
gle file and are grouped by the module. When interested in extending Lisk Service and implement
ing hooks for your custom modules, please check the Extending Indexer sec
tion below.
Note that this installation instruction is required only for development activities. For a re gular Lisk Service user the official [documentation](https://lisk.com/documentation/lisk-servic e/) is sufficient to run an instance. The global readme file present in the root directory desc ribes running all the microservices at once.
Please refer to the README in the project root directory.
Clone the Lisk Service Repository:
git clone https://github.com/LiskHQ/lisk-service.git # clone repository
cd lisk-service/services/blockchain-indexer # move into blockchain-indexer microservice directo
ry
npm ci # install required Node.js dependencies
To configure the different microservices, there are several environment variables the user can define to customize the configurations.
A list of the most commonly used environment variables is presented below:
SERVICE_BROKER: URL of the microservice message broker (Redis).SERVICE_INDEXER_MYSQL: Connection string of the MySQL instance that the microservice connec
ts to.SERVICE_MESSAGE_QUEUE_REDIS: URL of the job queue to process the scheduled indexing jobs by
the Blockchain Coordinator (Redis).SERVICE_INDEXER_REDIS_VOLATILE: URL of the volatile cache storage (Redis).ENABLE_DATA_RETRIEVAL_MODE: Boolean flag to enable the Data Service mode.ENABLE_INDEXING_MODE: Boolean flag to enable the Data Indexing mode.ENABLE_PERSIST_EVENTS: Boolean flag to permanently maintain the events in the MySQL databas
e.cd lisk-service/services/blockchain-indexer # move into the root directory of the blockchain-in
dexer microservice
npm start # start the microservice with running nodes locally
Use the framework/bin/moleculer_client.js and framework/bin/moleculer_subscribe.js clients
to test particular service endpoints.
If you want to run a production variant of the service, use Docker or PM2. This will automa
tically recover the process when it fails.
Press Ctrl+C in the terminal to stop the process.
The applyTransaction and revertTransaction hooks are arranged per command in a file and are
grouped by the module that they belong to.
Existing hooks are located in the [shared/indexer/transactionProcessor](./shared/indexer/transa
ctionProcessor) directory.
When implementing the custom hooks please adhere to the following:
index.js under the above directory.
MODULE_NAME variable. The value must match the module name as registered withi
n the application.COMMAND_NAME variable. The value must match the command name as registered wit
hin the application.applyTransaction and revertTransaction hooks.https://github.com/LiskHQ/lisk-service/graphs/contributors
Copyright 2016-2023 Lisk Foundation
Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.
Content type
Image
Digest
sha256:8ac3c335c…
Size
83.1 MB
Last updated
over 2 years ago
docker pull lisk/service_blockchain_indexer