Commit 5f25bf14 authored by harrylee's avatar harrylee Committed by vipwzw

make linter

parent 4bb88ab6
......@@ -313,7 +313,7 @@ func Exec_Block(t *testing.T, stateDB db.DB, kvdb db.KVDB, env *execEnv, txs ...
cfg := types.NewChain33Config(types.GetDefaultCfgstring())
cfg.SetTitleOnlyForTest("chain33")
exec := newAccountmanager()
e := exec.(*accountmanager)
e := exec.(*Accountmanager)
q := queue.New("channel")
q.SetConfig(cfg)
api, _ := client.New(q.Client(), nil)
......
......@@ -15,17 +15,17 @@ import (
)
var (
//有效期
// ConfNameActiveTime 有效期
ConfNameActiveTime = et.AccountmanagerX + "-" + "activeTime"
//密钥重置锁定期
// ConfNameLockTime 密钥重置锁定期
ConfNameLockTime = et.AccountmanagerX + "-" + "lockTime"
//管理员地址
// ConfNameManagerAddr 管理员地址
ConfNameManagerAddr = et.AccountmanagerX + "-" + "managerAddr"
//默认有效期
// DefaultActiveTime 默认有效期
DefaultActiveTime = int64(5 * 360 * 24 * 3600)
//默认密钥重置锁定期
// DefaultLockTime 默认密钥重置锁定期
DefaultLockTime = int64(15 * 24 * 3600)
//默认管理员地址
// DefaultManagerAddr 默认管理员地址
DefaultManagerAddr = "12qyocayNF7Lv6C9qW4avxs2E7U41fKSfv"
)
......@@ -42,7 +42,7 @@ type Action struct {
api client.QueueProtocolAPI
}
func NewAction(e *accountmanager, tx *types.Transaction, index int) *Action {
func NewAction(e *Accountmanager, tx *types.Transaction, index int) *Action {
hash := tx.Hash()
fromaddr := tx.From()
return &Action{e.GetStateDB(), hash, fromaddr,
......@@ -407,7 +407,7 @@ func findAccountListByIndex(localdb dbm.KV, expireTime int64, primaryKey string)
func findAccountByID(localdb dbm.KV, accountID string) (*et.Account, error) {
table := NewAccountTable(localdb)
prefix := []byte(fmt.Sprintf("%s", accountID))
prefix := []byte(accountID)
//第一次查询,默认展示最新得成交记录
rows, err := table.ListIndex("accountID", prefix, nil, 1, et.ListDESC)
if err != nil {
......@@ -423,7 +423,7 @@ func findAccountByID(localdb dbm.KV, accountID string) (*et.Account, error) {
func findAccountByAddr(localdb dbm.KV, addr string) (*et.Account, error) {
table := NewAccountTable(localdb)
prefix := []byte(fmt.Sprintf("%s", addr))
prefix := []byte(addr)
//第一次查询,默认展示最新得成交记录
rows, err := table.ListIndex("addr", prefix, nil, 1, et.ListDESC)
if err != nil {
......
......@@ -28,15 +28,15 @@ func Init(name string, cfg *types.Chain33Config, sub []byte) {
// InitExecType Init Exec Type
func InitExecType() {
ety := types.LoadExecutorType(driverName)
ety.InitFuncList(types.ListMethod(&accountmanager{}))
ety.InitFuncList(types.ListMethod(&Accountmanager{}))
}
type accountmanager struct {
type Accountmanager struct {
drivers.DriverBase
}
func newAccountmanager() drivers.Driver {
t := &accountmanager{}
t := &Accountmanager{}
t.SetChild(t)
t.SetExecutorType(types.LoadExecutorType(driverName))
return t
......@@ -47,17 +47,17 @@ func GetName() string {
return newAccountmanager().GetName()
}
func (a *accountmanager) GetDriverName() string {
func (a *Accountmanager) GetDriverName() string {
return driverName
}
//ExecutorOrder Exec 的时候 同时执行 ExecLocal
func (e *accountmanager) ExecutorOrder() int64 {
func (a *Accountmanager) ExecutorOrder() int64 {
return drivers.ExecLocalSameTime
}
// CheckTx 实现自定义检验交易接口,供框架调用
func (a *accountmanager) CheckTx(tx *types.Transaction, index int) error {
func (a *Accountmanager) CheckTx(tx *types.Transaction, index int) error {
//发送交易的时候就检查payload,做严格的参数检查
var ama et.AccountmanagerAction
types.Decode(tx.GetPayload(), &ama)
......@@ -79,10 +79,7 @@ func (a *accountmanager) CheckTx(tx *types.Transaction, index int) error {
return nil
}
func (a *accountmanager) CheckAccountIDIsExist(accountID string) bool {
func (a *Accountmanager) CheckAccountIDIsExist(accountID string) bool {
_, err := findAccountByID(a.GetLocalDB(), accountID)
if err == types.ErrNotFound {
return false
}
return true
return err != types.ErrNotFound
}
......@@ -10,27 +10,27 @@ import (
* 关键数据上链(statedb)并生成交易回执(log)
*/
func (a *accountmanager) Exec_Register(payload *aty.Register, tx *types.Transaction, index int) (*types.Receipt, error) {
func (a *Accountmanager) Exec_Register(payload *aty.Register, tx *types.Transaction, index int) (*types.Receipt, error) {
action := NewAction(a, tx, index)
return action.Register(payload)
}
func (a *accountmanager) Exec_ResetKey(payload *aty.ResetKey, tx *types.Transaction, index int) (*types.Receipt, error) {
func (a *Accountmanager) Exec_ResetKey(payload *aty.ResetKey, tx *types.Transaction, index int) (*types.Receipt, error) {
action := NewAction(a, tx, index)
return action.Reset(payload)
}
func (a *accountmanager) Exec_Transfer(payload *aty.Transfer, tx *types.Transaction, index int) (*types.Receipt, error) {
func (a *Accountmanager) Exec_Transfer(payload *aty.Transfer, tx *types.Transaction, index int) (*types.Receipt, error) {
action := NewAction(a, tx, index)
return action.Transfer(payload)
}
func (a *accountmanager) Exec_Supervise(payload *aty.Supervise, tx *types.Transaction, index int) (*types.Receipt, error) {
func (a *Accountmanager) Exec_Supervise(payload *aty.Supervise, tx *types.Transaction, index int) (*types.Receipt, error) {
action := NewAction(a, tx, index)
return action.Supervise(payload)
}
func (a *accountmanager) Exec_Apply(payload *aty.Apply, tx *types.Transaction, index int) (*types.Receipt, error) {
func (a *Accountmanager) Exec_Apply(payload *aty.Apply, tx *types.Transaction, index int) (*types.Receipt, error) {
action := NewAction(a, tx, index)
return action.Apply(payload)
}
......@@ -9,7 +9,7 @@ import (
*/
// ExecDelLocal 回退自动删除,重写基类
func (a *accountmanager) ExecDelLocal(tx *types.Transaction, receipt *types.ReceiptData, index int) (*types.LocalDBSet, error) {
func (a *Accountmanager) ExecDelLocal(tx *types.Transaction, receipt *types.ReceiptData, index int) (*types.LocalDBSet, error) {
kvs, err := a.DelRollbackKV(tx, tx.Execer)
if err != nil {
return nil, err
......
......@@ -10,7 +10,7 @@ import (
* 非关键数据,本地存储(localDB), 用于辅助查询,效率高
*/
func (a *accountmanager) ExecLocal_Register(payload *et.Register, tx *types.Transaction, receiptData *types.ReceiptData, index int) (*types.LocalDBSet, error) {
func (a *Accountmanager) ExecLocal_Register(payload *et.Register, tx *types.Transaction, receiptData *types.ReceiptData, index int) (*types.LocalDBSet, error) {
dbSet := &types.LocalDBSet{}
if receiptData.Ty == types.ExecOk {
for _, log := range receiptData.Logs {
......@@ -36,7 +36,7 @@ func (a *accountmanager) ExecLocal_Register(payload *et.Register, tx *types.Tran
}
return a.addAutoRollBack(tx, dbSet.KV), nil
}
func (a *accountmanager) ExecLocal_ResetKey(payload *et.ResetKey, tx *types.Transaction, receiptData *types.ReceiptData, index int) (*types.LocalDBSet, error) {
func (a *Accountmanager) ExecLocal_ResetKey(payload *et.ResetKey, tx *types.Transaction, receiptData *types.ReceiptData, index int) (*types.LocalDBSet, error) {
dbSet := &types.LocalDBSet{}
if receiptData.Ty == types.ExecOk {
for _, log := range receiptData.Logs {
......@@ -62,7 +62,7 @@ func (a *accountmanager) ExecLocal_ResetKey(payload *et.ResetKey, tx *types.Tran
return a.addAutoRollBack(tx, dbSet.KV), nil
}
func (a *accountmanager) ExecLocal_Apply(payload *et.Apply, tx *types.Transaction, receiptData *types.ReceiptData, index int) (*types.LocalDBSet, error) {
func (a *Accountmanager) ExecLocal_Apply(payload *et.Apply, tx *types.Transaction, receiptData *types.ReceiptData, index int) (*types.LocalDBSet, error) {
dbSet := &types.LocalDBSet{}
if receiptData.Ty == types.ExecOk {
for _, log := range receiptData.Logs {
......@@ -88,7 +88,7 @@ func (a *accountmanager) ExecLocal_Apply(payload *et.Apply, tx *types.Transactio
return a.addAutoRollBack(tx, dbSet.KV), nil
}
func (a *accountmanager) ExecLocal_Transfer(payload *et.Transfer, tx *types.Transaction, receiptData *types.ReceiptData, index int) (*types.LocalDBSet, error) {
func (a *Accountmanager) ExecLocal_Transfer(payload *et.Transfer, tx *types.Transaction, receiptData *types.ReceiptData, index int) (*types.LocalDBSet, error) {
dbSet := &types.LocalDBSet{}
if receiptData.Ty == types.ExecOk {
for _, log := range receiptData.Logs {
......@@ -114,7 +114,7 @@ func (a *accountmanager) ExecLocal_Transfer(payload *et.Transfer, tx *types.Tran
return a.addAutoRollBack(tx, dbSet.KV), nil
}
func (a *accountmanager) ExecLocal_Supervise(payload *et.Supervise, tx *types.Transaction, receiptData *types.ReceiptData, index int) (*types.LocalDBSet, error) {
func (a *Accountmanager) ExecLocal_Supervise(payload *et.Supervise, tx *types.Transaction, receiptData *types.ReceiptData, index int) (*types.LocalDBSet, error) {
dbSet := &types.LocalDBSet{}
if receiptData.Ty == types.ExecOk {
for _, log := range receiptData.Logs {
......@@ -165,7 +165,7 @@ func (a *accountmanager) ExecLocal_Supervise(payload *et.Supervise, tx *types.Tr
}
//设置自动回滚
func (a *accountmanager) addAutoRollBack(tx *types.Transaction, kv []*types.KeyValue) *types.LocalDBSet {
func (a *Accountmanager) addAutoRollBack(tx *types.Transaction, kv []*types.KeyValue) *types.LocalDBSet {
dbSet := &types.LocalDBSet{}
dbSet.KV = a.AddRollbackKV(tx, tx.Execer, kv)
return dbSet
......
......@@ -6,26 +6,26 @@ import (
)
//根据ID查询账户信息
func (s *accountmanager) Query_QueryAccountByID(in *et.QueryAccountByID) (types.Message, error) {
return findAccountByID(s.GetLocalDB(), in.AccountID)
func (a *Accountmanager) Query_QueryAccountByID(in *et.QueryAccountByID) (types.Message, error) {
return findAccountByID(a.GetLocalDB(), in.AccountID)
}
//根据ID查询账户信息
func (s *accountmanager) Query_QueryAccountByAddr(in *et.QueryAccountByAddr) (types.Message, error) {
return findAccountByAddr(s.GetLocalDB(), in.Addr)
func (a *Accountmanager) Query_QueryAccountByAddr(in *et.QueryAccountByAddr) (types.Message, error) {
return findAccountByAddr(a.GetLocalDB(), in.Addr)
}
//根据状态查询账户列表|| 账户状态 1 正常, 2表示冻结, 3表示锁定 4,过期注销
func (s *accountmanager) Query_QueryAccountsByStatus(in *et.QueryAccountsByStatus) (types.Message, error) {
return findAccountListByStatus(s.GetLocalDB(), in.Status, in.Direction, in.PrimaryKey)
func (a *Accountmanager) Query_QueryAccountsByStatus(in *et.QueryAccountsByStatus) (types.Message, error) {
return findAccountListByStatus(a.GetLocalDB(), in.Status, in.Direction, in.PrimaryKey)
}
//查询逾期注销的账户列表
func (s *accountmanager) Query_QueryExpiredAccounts(in *et.QueryExpiredAccounts) (types.Message, error) {
return findAccountListByIndex(s.GetLocalDB(), in.ExpiredTime, in.PrimaryKey)
func (a *Accountmanager) Query_QueryExpiredAccounts(in *et.QueryExpiredAccounts) (types.Message, error) {
return findAccountListByIndex(a.GetLocalDB(), in.ExpiredTime, in.PrimaryKey)
}
//根据ID查询账户余额
func (s *accountmanager) Query_QueryBalanceByID(in *et.QueryBalanceByID) (types.Message, error) {
return queryBalanceByID(s.GetStateDB(), s.GetLocalDB(), s.GetAPI().GetConfig(), s.GetName(), in)
func (a *Accountmanager) Query_QueryBalanceByID(in *et.QueryBalanceByID) (types.Message, error) {
return queryBalanceByID(a.GetStateDB(), a.GetLocalDB(), a.GetAPI().GetConfig(), a.GetName(), in)
}
......@@ -71,13 +71,13 @@ func (m *AccountRow) SetPayload(data types.Message) error {
//Get 按照indexName 查询 indexValue
func (m *AccountRow) Get(key string) ([]byte, error) {
if key == "accountID" {
return []byte(fmt.Sprintf("%s", m.AccountID)), nil
return []byte(m.AccountID), nil
} else if key == "status" {
return []byte(fmt.Sprintf("%d", m.Status)), nil
} else if key == "index" {
return []byte(fmt.Sprintf("%015d", m.GetIndex())), nil
} else if key == "addr" {
return []byte(fmt.Sprintf("%s", m.GetAddr())), nil
return []byte(m.GetAddr()), nil
}
return nil, types.ErrNotFound
}
......@@ -3,7 +3,6 @@ package types
import (
"reflect"
log "github.com/33cn/chain33/common/log/log15"
"github.com/33cn/chain33/types"
)
......@@ -97,7 +96,7 @@ var (
TySuperviseLog: {Ty: reflect.TypeOf(SuperviseReceipt{}), Name: "TySuperviseLog"},
TyApplyLog: {Ty: reflect.TypeOf(AccountReceipt{}), Name: "TyApplyLog"},
}
tlog = log.New("module", "accountmanager.types")
//tlog = log.New("module", "accountmanager.types")
)
// init defines a register function
......
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