Commit 6afcd5b4 authored by kingwang's avatar kingwang Committed by 33cn

fix linter

parent aeb74e5d
...@@ -27,6 +27,7 @@ import ( ...@@ -27,6 +27,7 @@ import (
"time" "time"
"github.com/33cn/chain33/common" "github.com/33cn/chain33/common"
"github.com/33cn/chain33/common/db"
log "github.com/33cn/chain33/common/log/log15" log "github.com/33cn/chain33/common/log/log15"
drivers "github.com/33cn/chain33/system/dapp" drivers "github.com/33cn/chain33/system/dapp"
"github.com/33cn/chain33/types" "github.com/33cn/chain33/types"
...@@ -289,10 +290,21 @@ func (p *privacy) CheckTx(tx *types.Transaction, index int) error { ...@@ -289,10 +290,21 @@ func (p *privacy) CheckTx(tx *types.Transaction, index int) error {
return nil return nil
} }
func batchGet(stateDB db.KV, keyImages [][]byte) (values [][]byte, err error) {
for i := 0; i < len(keyImages); i++ {
v, err := stateDB.Get(keyImages[i])
if err != nil {
return nil, err
}
values = append(values, v)
}
return values, nil
}
//通过keyImage确认是否存在双花,有效即不存在双花,返回true,反之则返回false //通过keyImage确认是否存在双花,有效即不存在双花,返回true,反之则返回false
func (p *privacy) checkUTXOValid(keyImages [][]byte) (bool, int32) { func (p *privacy) checkUTXOValid(keyImages [][]byte) (bool, int32) {
stateDB := p.GetStateDB() stateDB := p.GetStateDB()
values, err := stateDB.BatchGet(keyImages) values, err := batchGet(stateDB, keyImages)
if err != nil { if err != nil {
privacylog.Error("exec module", "checkUTXOValid failed to get value from statDB") privacylog.Error("exec module", "checkUTXOValid failed to get value from statDB")
return false, invalidIndex return false, invalidIndex
...@@ -312,7 +324,7 @@ func (p *privacy) checkUTXOValid(keyImages [][]byte) (bool, int32) { ...@@ -312,7 +324,7 @@ func (p *privacy) checkUTXOValid(keyImages [][]byte) (bool, int32) {
} }
func (p *privacy) checkPubKeyValid(keys [][]byte, pubkeys [][]byte) (bool, int32) { func (p *privacy) checkPubKeyValid(keys [][]byte, pubkeys [][]byte) (bool, int32) {
values, err := p.GetStateDB().BatchGet(keys) values, err := batchGet(p.GetStateDB(), keys)
if err != nil { if err != nil {
privacylog.Error("exec module", "checkPubKeyValid failed to get value from statDB with err", err) privacylog.Error("exec module", "checkPubKeyValid failed to get value from statDB with err", err)
return false, invalidIndex return false, invalidIndex
......
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