package stat_service

import (
	"chain33-pai/models"
	"time"
)

type RaspMinerStat struct {
	Addr string `json:"addr"`
	MinedAmount int64 `json:"mined_amount"`
	Height int64 `json:"height"`
	Time int64 `json:"time"`
}

func (s *RaspMinerStat) GetMinerStat(addr string) (*models.RaspMinerStat,error) {
	return  models.GetAddr(addr)
}

func (s *RaspMinerStat) SetMineTime(addr string,flag string) error {
	_,err := models.GetAddr(addr)
	if err != nil {
		return err
	}
	m := map[string]interface{}{}
	if flag == "start" {
		m["miner_start_time"] = time.Now().Unix()
	}
	if flag == "end" {
		m["miner_end_time"] = time.Now().Unix()
	}

	return models.EditAddr(addr,m)
}

