Commit eec918e2 authored by caopingcp's avatar caopingcp

remove PrefixCount in lottery

parent c247815a
...@@ -5,6 +5,7 @@ ...@@ -5,6 +5,7 @@
package executor package executor
import ( import (
"fmt"
"sort" "sort"
log "github.com/33cn/chain33/common/log/log15" log "github.com/33cn/chain33/common/log/log15"
...@@ -61,25 +62,31 @@ func (lott *Lottery) GetDriverName() string { ...@@ -61,25 +62,31 @@ func (lott *Lottery) GetDriverName() string {
return pty.LotteryX return pty.LotteryX
} }
func (lott *Lottery) findLotteryBuyRecords(key []byte) (*pty.LotteryBuyRecords, error) { func (lott *Lottery) findLotteryBuyRecords(prefix []byte) (*pty.LotteryBuyRecords, error) {
count := 0
count := lott.GetLocalDB().PrefixCount(key) var key []byte
llog.Error("findLotteryBuyRecords", "count", count)
values, err := lott.GetLocalDB().List(key, nil, int32(count), 0)
if err != nil {
return nil, err
}
var records pty.LotteryBuyRecords var records pty.LotteryBuyRecords
for _, value := range values { for {
var record pty.LotteryBuyRecord values, err := lott.GetLocalDB().List(prefix, key, DefultCount, 0)
err := types.Decode(value, &record)
if err != nil { if err != nil {
continue return nil, err
}
for _, value := range values {
var record pty.LotteryBuyRecord
err := types.Decode(value, &record)
if err != nil {
continue
}
records.Records = append(records.Records, &record)
}
count += len(values)
if len(values) < int(DefultCount) {
break
} }
records.Records = append(records.Records, &record) key = []byte(fmt.Sprintf("%s:%18d", prefix, records.Records[count-1].Index))
} }
llog.Info("findLotteryBuyRecords", "count", count)
return &records, nil return &records, nil
} }
......
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