Commit d61ed2a0 authored by szh's avatar szh

update

parent 34b561cd
...@@ -23,9 +23,9 @@ type ReqTicketInfo struct { ...@@ -23,9 +23,9 @@ type ReqTicketInfo struct {
} }
// ExistByAddr checks if an addr exists based on addr // ExistByAddr checks if an addr exists based on addr
func ExistByAddrHeight(addr string,height int64) (bool, error) { func ExistByAddrHeight(addr string, height int64) (bool, error) {
var txs RaspMinerTxs var txs RaspMinerTxs
err := db.Select("miner").Where("miner = ? and height = ?", addr,height).First(&txs).Error err := db.Select("miner").Where("miner = ? and height = ?", addr, height).First(&txs).Error
if err != nil && err != gorm.ErrRecordNotFound { if err != nil && err != gorm.ErrRecordNotFound {
return false, err return false, err
} }
...@@ -40,7 +40,7 @@ func ExistByAddrHeight(addr string,height int64) (bool, error) { ...@@ -40,7 +40,7 @@ func ExistByAddrHeight(addr string,height int64) (bool, error) {
// GetAddrTotal gets the total number of addr based on the constraints // GetAddrTotal gets the total number of addr based on the constraints
func GetMinerTxsTotal(addr string) (int64, error) { func GetMinerTxsTotal(addr string) (int64, error) {
var count int64 var count int64
if err := db.Model(&RaspMinerTxs{}).Where("return_addr = ? ",addr).Count(&count).Error; err != nil { if err := db.Model(&RaspMinerTxs{}).Where("return_addr = ? ", addr).Count(&count).Error; err != nil {
return 0, err return 0, err
} }
...@@ -53,8 +53,8 @@ func GetMinerTxs(req *ReqTicketInfo) ([]*RaspMinerTxs, error) { ...@@ -53,8 +53,8 @@ func GetMinerTxs(req *ReqTicketInfo) ([]*RaspMinerTxs, error) {
if req.Order == "" { if req.Order == "" {
req.Order = "desc" req.Order = "desc"
} }
maps := map[string]interface{}{"return_addr":req.Addr} maps := map[string]interface{}{"return_addr": req.Addr}
err := db.Where(maps).Order("time "+req.Order).Offset((req.Page-1)*req.Pagesize).Limit(req.Pagesize).Find(&txs).Error err := db.Where(maps).Order("height " + req.Order).Offset((req.Page - 1) * req.Pagesize).Limit(req.Pagesize).Find(&txs).Error
if err != nil && err != gorm.ErrRecordNotFound { if err != nil && err != gorm.ErrRecordNotFound {
return nil, err return nil, err
} }
...@@ -69,7 +69,7 @@ func AddMinerTxs(data map[string]interface{}) error { ...@@ -69,7 +69,7 @@ func AddMinerTxs(data map[string]interface{}) error {
ReturnAddr: data["return_addr"].(string), ReturnAddr: data["return_addr"].(string),
Amount: data["amount"].(int64), Amount: data["amount"].(int64),
Height: data["height"].(int64), Height: data["height"].(int64),
Hash:data["hash"].(string), Hash: data["hash"].(string),
Time: data["time"].(int64), Time: data["time"].(int64),
} }
if err := db.Create(&tx).Error; err != nil { if err := db.Create(&tx).Error; err != nil {
...@@ -78,4 +78,3 @@ func AddMinerTxs(data map[string]interface{}) error { ...@@ -78,4 +78,3 @@ func AddMinerTxs(data map[string]interface{}) error {
return nil return nil
} }
...@@ -185,14 +185,14 @@ func (p *Pai) GetTicketInfo(req *models.ReqTicketInfo) (*MinedInfo, error) { ...@@ -185,14 +185,14 @@ func (p *Pai) GetTicketInfo(req *models.ReqTicketInfo) (*MinedInfo, error) {
for _, v := range txs { for _, v := range txs {
var t MinedTxInfo var t MinedTxInfo
t.Height = v.Height t.Height = v.Height
t.Amount = v.Amount t.Amount = v.Amount / 1e8
t.BlockTime = v.Time t.BlockTime = v.Time
t.Hash = v.Hash t.Hash = v.Hash
txsList = append(txsList, &t) txsList = append(txsList, &t)
} }
// info.MinedTotal = count // info.MinedTotal = count
} }
info.MinedAmount = stat.MinedAmount info.MinedAmount = stat.MinedAmount / 1e8
info.MinedTicketCount = stat.MinedTicketCount info.MinedTicketCount = stat.MinedTicketCount
info.MiningTicketCount = stat.MiningTicketCount info.MiningTicketCount = stat.MiningTicketCount
info.MinerStartTime = stat.MinerStartTime info.MinerStartTime = stat.MinerStartTime
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment