#!/bin/bash

# Holder Scanner 快速启动脚本
# Quick start script for Holder Scanner

echo "=== Holder Scanner 启动脚本 ==="
echo ""

# 加载 .env 文件
if [ -f .env ]; then
    echo "📄 正在加载 .env 配置..."
    export $(grep -v '^#' .env | xargs)
    echo "✓ 配置已加载"
else
    echo "⚠️  .env 文件未找到，使用默认配置"
fi

# 显示当前配置
echo ""
echo "📊 当前配置:"
echo "  数据库: $DB_TYPE://$DB_USER@$DB_HOST:$DB_PORT/$DB_NAME"
echo "  Chain ID: ${CHAIN_ID:-421614}"
echo "  部署区块号:"
echo "    • YT Vaults: ${YT_VAULTS_DEPLOY_BLOCK:-227339300}"
echo "    • ytLP: ${YTLP_DEPLOY_BLOCK:-227230270}"
echo "    • Lending: ${LENDING_DEPLOY_BLOCK:-227746053}"
echo ""

# 编译并运行
echo "📦 正在编译 Scanner..."
go build -o bin/holder-scanner cmd/scanner/main.go

if [ $? -eq 0 ]; then
    echo "✓ 编译成功"
    echo ""
    echo "🚀 正在启动 Scanner..."
    echo "━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━"
    ./bin/holder-scanner
else
    echo "❌ 编译失败"
    exit 1
fi
