package main

import (
	_ "github.com/go-sql-driver/mysql"
	"github.com/go-xorm/xorm"
	"os"
	"syncscan-go/collector"
	"syncscan-go/er"
	ethclient "syncscan-go/eth"
	models_table "syncscan-go/models/table"
)

func main() {

	db, err := xorm.NewEngine("mysql", "syncscan_db:ICjryB3GkHB@tcp(175.126.146.155:3306)/syncscan_db?charset=utf8mb4&parseTime=true&loc=Local")
	er.Check(err)
	er.Check(db.Ping())

	db.SetLogger(xorm.NewSimpleLogger(os.Stdout))
	db.ShowSQL(true)

	db.Sync(new(models_table.EthLastSync))
	db.Sync(new(models_table.EthTxMethod))
	db.Sync(new(models_table.EthBlock))
	db.Sync(new(models_table.EthUncleBlock))
	db.Sync(new(models_table.EthContract))
	db.Sync(new(models_table.EthToken))
	db.Sync(new(models_table.EthTransInter))
	db.Sync(new(models_table.EthTokenHolder))
	db.Sync(new(models_table.EthTranxn))

	ethclient, err := ethclient.New("https://mainnet.infura.io/v3/8efdf62c742545d5836d741c9d4b5300")
	er.Check(err)
	c := collector.New(db, ethclient, 100)
	c.Run()
}
