package cron

import (
	"bwallet/service/coin_gas_service"
	"github.com/robfig/cron"
	"time"
)

func Setup() error {
	c := cron.New()
	c.AddFunc("* * * * * *", func() {
		gas_service := coin_gas_service.CoinGas{}
		gas_service.Etherscan()
	})

	c.AddFunc("* * * * * *", func() {
		gas_service := coin_gas_service.CoinGas{}
		gas_service.Btcscan()
	})

	c.Start()

	t1 := time.NewTimer(time.Second * 10)
	for {
		select {
		case <-t1.C:
			t1.Reset(time.Second * 10)
		}
	}

	return nil
}
