This is a Go application that monitors the block height difference between a node and a set of RPC endpoints. Alerts are sent to a Telegram bot when certain thresholds are exceeded.
- Docker
- Docker Compose
-
Clone the repository:
git clone https://github.com/your-repo/go-blockchain-monitoring.git cd go-blockchain-monitoring
-
Create a
.env
file in the project root directory and add the necessary environment variables:RPC_URLS=http://rpc1,http://rpc2 NODE_URL=http://node LEVEL_1=5 LEVEL_2=10 LEVEL_3=15 BOT_TOKEN=your_telegram_bot_token CHAT_ID=your_telegram_chat_id
Replace
your_telegram_bot_token
andyour_telegram_chat_id
with your actual Telegram bot token and chat ID. Adjust the other environment variables as needed. -
Create an empty
previous_state.yml
file in the project root directory:touch previous_state.yml
-
Build the Docker image:
docker build -t go-blockchain-monitoring .
-
Run the Docker container:
docker run --env-file .env -v $(pwd)/previous_state.yml:/root/previous_state.yml go-blockchain-monitoring
-
Ensure you have the
docker-compose.yml
file in the project root directory. -
Build and start the application using Docker Compose:
docker-compose up --build
This command will build the Docker image and start the container.
-
To stop the application:
docker-compose down
main.go
: Main application file.Dockerfile
: Dockerfile for building the application image.docker-compose.yml
: Docker Compose configuration file..env
: Environment variables file (you need to create this).previous_state.yml
: File to persist the previous state (you need to create this).
If you find any issues or have suggestions for improvements, feel free to open an issue or submit a pull request.