Obtain and analyze the block transactions of the specified blockchain nodes, etc., and provide an interface for querying and analyzing data
Create a file .env
(same execution path as the executable file), the following is the default configuration, fill in whatever fields need to be modified
CHAIN_URL =http://localhost:8545
SERVER_ADDR =:3000
INTERVAL =1s
THREAD =8
MYSQL_DSN =root:123456@tcp(127.0.0.1:3306)/scan
- CHAIN_URL: Specifies the chain api address blockchain data to be analyzed
- SERVER_ADDR: Open query service interface address, after running, query and analyze data through this address
- INTERVAL: The pause time (in seconds) when there is an error in the analysis or when there is no new block to analyze
- THREAD: Number of parsing coroutines in parallel
- MYSQL_DSN: The connection address of the database (mysql or mariadb database)
The node parameters to start must contain at least:
- Enable http (ws) service:
--http
(--ws
) - Open query api (minimum eth and debug):
--http.api debug,eth
(--ws.api debug,eth
) - Select full data mode for synchronization:
--syncmode full
- Select archive mode for garbage collection:
--gcmode archive
- Keep all transactions:
--txlookuplimit 0
Example:
geth --rinkeby --http --http.api debug,eth --syncmode full --txlookuplimit 0 --gcmode archive
- Configure the predefined blockchain network information (if required), compile the program
- Install and configure mysql or mariadb database
- Run the blockchain service node (if needed)
- Create a configuration file (if needed)
- Clear the database when the chain resets or switches
- To run the program, the configuration file needs to be in the same execution path as the program