Commit 7275013e authored by harrylee's avatar harrylee Committed by vipwzw

update accountmanager

parent 814d6a11
package executor
import (
"github.com/33cn/chain33/account"
"github.com/33cn/chain33/client"
"github.com/33cn/chain33/common"
"github.com/33cn/chain33/common/address"
"github.com/33cn/chain33/common/crypto"
"github.com/33cn/chain33/common/db"
"github.com/33cn/chain33/queue"
"github.com/33cn/chain33/types"
"github.com/33cn/chain33/util"
"time"
et "github.com/33cn/plugin/plugin/dapp/accountmanager/types"
"github.com/stretchr/testify/assert"
"testing"
)
type execEnv struct {
blockTime int64
blockHeight int64
difficulty uint64
}
var (
PrivKeyA = "0x6da92a632ab7deb67d38c0f6560bcfed28167998f6496db64c258d5e8393a81b" // 1KSBd17H7ZK8iT37aJztFB22XGwsPTdwE4
PrivKeyB = "0x19c069234f9d3e61135fefbeb7791b149cdf6af536f26bebb310d4cd22c3fee4" // 1JRNjdEqp4LJ5fqycUBm9ayCKSeeskgMKR
PrivKeyC = "0x7a80a1f75d7360c6123c32a78ecf978c1ac55636f87892df38d8b85a9aeff115" // 1NLHPEcbTWWxxU3dGUZBhayjrCHD3psX7k
PrivKeyD = "0xcacb1f5d51700aea07fca2246ab43b0917d70405c65edea9b5063d72eb5c6b71" // 1MCftFynyvG2F4ED5mdHYgziDxx6vDrScs
Nodes = []string{
"1KSBd17H7ZK8iT37aJztFB22XGwsPTdwE4",
"1JRNjdEqp4LJ5fqycUBm9ayCKSeeskgMKR",
"1NLHPEcbTWWxxU3dGUZBhayjrCHD3psX7k",
"1MCftFynyvG2F4ED5mdHYgziDxx6vDrScs",
}
)
func TestAccountManager(t *testing.T) {
//环境准备
cfg := types.NewChain33Config(types.GetDefaultCfgstring())
cfg.SetTitleOnlyForTest("chain33")
Init(et.AccountmanagerX, cfg, nil)
total := 100 * types.Coin
accountA := types.Account{
Balance: total,
Frozen: 0,
Addr: Nodes[0],
}
accountB := types.Account{
Balance: total,
Frozen: 0,
Addr: Nodes[1],
}
accountC := types.Account{
Balance: total,
Frozen: 0,
Addr: Nodes[2],
}
accountD := types.Account{
Balance: total,
Frozen: 0,
Addr: Nodes[3],
}
_, stateDB, kvdb := util.CreateTestDB()
//defer util.CloseTestDB(dir, stateDB)
execAddr := address.ExecAddress(et.AccountmanagerX)
accA, _ := account.NewAccountDB(cfg, "coins", "bty", stateDB)
accA.SaveExecAccount(execAddr, &accountA)
accB, _ := account.NewAccountDB(cfg, "coins", "bty", stateDB)
accB.SaveExecAccount(execAddr, &accountB)
accC, _ := account.NewAccountDB(cfg, "coins", "bty", stateDB)
accC.SaveExecAccount(execAddr, &accountC)
accD, _ := account.NewAccountDB(cfg, "coins", "bty", stateDB)
accD.SaveExecAccount(execAddr, &accountD)
env := &execEnv{
time.Now().Unix(),
1,
1539918074,
}
// set config key
item := &types.ConfigItem{
Key: "mavl-manage-"+ConfNameActiveTime,
Value: &types.ConfigItem_Arr{
Arr: &types.ArrayConfig{Value: []string{"10"}},
},
}
stateDB.Set([]byte(item.Key), types.Encode(item))
item2 := &types.ConfigItem{
Key: "mavl-manage-"+ConfNameManagerAddr,
Value: &types.ConfigItem_Arr{
Arr: &types.ArrayConfig{Value: []string{string(Nodes[0])}},
},
}
stateDB.Set([]byte(item2.Key), types.Encode(item2))
item3 := &types.ConfigItem{
Key: "mavl-manage-"+ConfNameLockTime,
Value: &types.ConfigItem_Arr{
Arr: &types.ArrayConfig{Value: []string{"15"}},
},
}
stateDB.Set([]byte(item3.Key), types.Encode(item3))
//注册
tx1,err := CreateRegister(&et.Register{AccountID:"harrylee2015"},PrivKeyB)
if err !=nil {
t.Error(err)
}
Exec_Block(t,stateDB,kvdb,env,tx1)
tx2,err := CreateRegister(&et.Register{AccountID:"harrylee2015"},PrivKeyC)
err=Exec_Block(t,stateDB,kvdb,env,tx2)
assert.Equal(t,err,et.ErrAccountIDExist)
tx3,err := CreateRegister(&et.Register{AccountID:"harrylee2020"},PrivKeyC)
Exec_Block(t,stateDB,kvdb,env,tx3)
tx4,err:=CreateTransfer(&et.Transfer{FromAccountID:"harrylee2015",ToAccountID:"harrylee2020",Amount:1e8,Asset:&et.Asset{Execer:"coins",Symbol:"bty"}},PrivKeyB)
if err !=nil {
t.Error(err)
}
err=Exec_Block(t,stateDB,kvdb,env,tx4)
assert.Equal(t,err,nil)
}
func CreateRegister(register *et.Register, privKey string) (tx *types.Transaction, err error) {
ety := types.LoadExecutorType(et.AccountmanagerX)
tx, err = ety.Create(et.NameRegisterAction, register)
if err != nil {
return nil, err
}
cfg := types.NewChain33Config(types.GetDefaultCfgstring())
cfg.SetTitleOnlyForTest("chain33")
tx, err = types.FormatTx(cfg, et.AccountmanagerX, tx)
if err != nil {
return nil, err
}
tx, err = signTx(tx, privKey)
if err != nil {
return nil, err
}
return tx, nil
}
func CreateReset(reset *et.ResetKey, privKey string) (tx *types.Transaction, err error) {
ety := types.LoadExecutorType(et.AccountmanagerX)
tx, err = ety.Create(et.NameResetAction, reset)
if err != nil {
return nil, err
}
cfg := types.NewChain33Config(types.GetDefaultCfgstring())
cfg.SetTitleOnlyForTest("chain33")
tx, err = types.FormatTx(cfg, et.AccountmanagerX, tx)
if err != nil {
return nil, err
}
tx, err = signTx(tx, privKey)
if err != nil {
return nil, err
}
return tx, nil
}
func CreateTransfer(tranfer *et.Transfer, privKey string) (tx *types.Transaction, err error) {
ety := types.LoadExecutorType(et.AccountmanagerX)
tx, err = ety.Create(et.NameTransferAction, tranfer)
if err != nil {
return nil, err
}
cfg := types.NewChain33Config(types.GetDefaultCfgstring())
cfg.SetTitleOnlyForTest("chain33")
tx, err = types.FormatTx(cfg, et.AccountmanagerX, tx)
if err != nil {
return nil, err
}
tx, err = signTx(tx, privKey)
if err != nil {
return nil, err
}
return tx, nil
}
func CreateSupervise(supervise *et.Supervise, privKey string) (tx *types.Transaction, err error) {
ety := types.LoadExecutorType(et.AccountmanagerX)
tx, err = ety.Create(et.NameSuperviseAction, supervise)
if err != nil {
return nil, err
}
cfg := types.NewChain33Config(types.GetDefaultCfgstring())
cfg.SetTitleOnlyForTest("chain33")
tx, err = types.FormatTx(cfg, et.AccountmanagerX, tx)
if err != nil {
return nil, err
}
tx, err = signTx(tx, privKey)
if err != nil {
return nil, err
}
return tx, nil
}
func CreateApply(apply *et.Apply, privKey string) (tx *types.Transaction, err error) {
ety := types.LoadExecutorType(et.AccountmanagerX)
tx, err = ety.Create(et.NameSuperviseAction, apply)
if err != nil {
return nil, err
}
cfg := types.NewChain33Config(types.GetDefaultCfgstring())
cfg.SetTitleOnlyForTest("chain33")
tx, err = types.FormatTx(cfg, et.AccountmanagerX, tx)
if err != nil {
return nil, err
}
tx, err = signTx(tx, privKey)
if err != nil {
return nil, err
}
return tx, nil
}
//模拟区块中交易得执行过程
func Exec_Block(t *testing.T, stateDB db.DB, kvdb db.KVDB, env *execEnv, txs ...*types.Transaction) error {
cfg := types.NewChain33Config(types.GetDefaultCfgstring())
cfg.SetTitleOnlyForTest("chain33")
exec := newAccountmanager()
e := exec.(*accountmanager)
for index, tx := range txs {
err := e.CheckTx(tx, index)
if err != nil {
return err
}
}
q := queue.New("channel")
q.SetConfig(cfg)
api, _ := client.New(q.Client(), nil)
exec.SetAPI(api)
exec.SetStateDB(stateDB)
exec.SetLocalDB(kvdb)
env.blockHeight = env.blockHeight + 1
env.blockTime = env.blockTime + 1
env.difficulty = env.difficulty + 1
exec.SetEnv(env.blockHeight, env.blockTime, env.difficulty)
for index, tx := range txs {
receipt, err := exec.Exec(tx, index)
if err != nil {
return err
}
for _, kv := range receipt.KV {
stateDB.Set(kv.Key, kv.Value)
}
receiptData := &types.ReceiptData{Ty: receipt.Ty, Logs: receipt.Logs}
set, err := exec.ExecLocal(tx, receiptData, index)
if err != nil {
return err
}
for _, kv := range set.KV {
kvdb.Set(kv.Key, kv.Value)
}
//save to database
util.SaveKVList(stateDB, set.KV)
assert.Equal(t, types.ExecOk, int(receipt.Ty))
}
return nil
}
func Exec_QueryAccountByID(accountID string, stateDB db.KV, kvdb db.KVDB) (*et.Account, error) {
cfg := types.NewChain33Config(types.GetDefaultCfgstring())
cfg.SetTitleOnlyForTest("chain33")
exec := newAccountmanager()
q := queue.New("channel")
q.SetConfig(cfg)
api, _ := client.New(q.Client(), nil)
exec.SetAPI(api)
exec.SetStateDB(stateDB)
exec.SetLocalDB(kvdb)
msg, err := exec.Query(et.FuncNameQueryAccountByID, types.Encode(&et.QueryAccountByID{AccountID: accountID}))
if err != nil {
return nil, err
}
return msg.(*et.Account), err
}
func Exec_QueryAccountsByStatus(status int32, stateDB db.KV, kvdb db.KVDB) (*et.ReplyAccountList, error) {
cfg := types.NewChain33Config(types.GetDefaultCfgstring())
cfg.SetTitleOnlyForTest("chain33")
exec := newAccountmanager()
q := queue.New("channel")
q.SetConfig(cfg)
api, _ := client.New(q.Client(), nil)
exec.SetAPI(api)
exec.SetStateDB(stateDB)
exec.SetLocalDB(kvdb)
msg, err := exec.Query(et.FuncNameQueryAccountsByStatus, types.Encode(&et.QueryAccountsByStatus{Status:status}))
if err != nil {
return nil, err
}
return msg.(*et.ReplyAccountList), err
}
func Exec_QueryExpiredAccounts(status int32, stateDB db.KV, kvdb db.KVDB) (*et.ReplyAccountList, error) {
cfg := types.NewChain33Config(types.GetDefaultCfgstring())
cfg.SetTitleOnlyForTest("chain33")
exec := newAccountmanager()
q := queue.New("channel")
q.SetConfig(cfg)
api, _ := client.New(q.Client(), nil)
exec.SetAPI(api)
exec.SetStateDB(stateDB)
exec.SetLocalDB(kvdb)
msg, err := exec.Query(et.FuncNameQueryExpiredAccounts, types.Encode(&et.QueryExpiredAccounts{}))
if err != nil {
return nil, err
}
return msg.(*et.ReplyAccountList), err
}
func signTx(tx *types.Transaction, hexPrivKey string) (*types.Transaction, error) {
signType := types.SECP256K1
c, err := crypto.New(types.GetSignName("", signType))
if err != nil {
return tx, err
}
bytes, err := common.FromHex(hexPrivKey[:])
if err != nil {
return tx, err
}
privKey, err := c.PrivKeyFromBytes(bytes)
if err != nil {
return tx, err
}
tx.Sign(int32(signType), privKey)
return tx, nil
}
......@@ -5,9 +5,27 @@ import (
"github.com/33cn/chain33/account"
"github.com/33cn/chain33/client"
dbm "github.com/33cn/chain33/common/db"
tab "github.com/33cn/chain33/common/db/table"
"github.com/33cn/chain33/system/dapp"
"github.com/33cn/chain33/types"
et "github.com/33cn/plugin/plugin/dapp/accountmanager/types"
"strconv"
"time"
)
var (
//有效期
ConfNameActiveTime = et.AccountmanagerX + "-" + "activeTime"
//密钥重置锁定期
ConfNameLockTime = et.AccountmanagerX + "-" + "lockTime"
//管理员地址
ConfNameManagerAddr = et.AccountmanagerX + "-" + "managerAddr"
//默认有效期
DefaultActiveTime = int64(5 * 360 * 24 * 3600)
//默认密钥重置锁定期
DefaultLockTime = int64(15 * 24 * 3600)
DefaultManagerAddr = "12qyocayNF7Lv6C9qW4avxs2E7U41fKSfv"
)
// Action action struct
......@@ -23,7 +41,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,
......@@ -32,7 +50,7 @@ func NewAction(e accountmanager, tx *types.Transaction, index int) *Action {
//GetIndex get index
func (a *Action) GetIndex() int64 {
return (a.height*types.MaxTxsPerBlock + int64(a.index)) * 1e4
return a.blocktime*int64(types.MaxTxsPerBlock) + int64(a.index)
}
//GetKVSet get kv set
......@@ -43,19 +61,26 @@ func (a *Action) GetKVSet(account *et.Account) (kvset []*types.KeyValue) {
func (a *Action) Register(payload *et.Register) (*types.Receipt, error) {
var logs []*types.ReceiptLog
account, err := queryMarketDepth(a.localDB, payload.AccountID)
if err == nil && account != nil {
return nil, et.ErrAccountNameExist
account1, err := findAccountByID(a.localDB, payload.AccountID)
if err == nil && account1 != nil {
return nil, et.ErrAccountIDExist
}
//TODO 有效期后面统一配置目前暂定五年时间
re := &et.Receipt{
//默认有效期时五年
cfg := a.api.GetConfig()
defaultActiveTime := getConfValue(cfg, a.statedb, ConfNameActiveTime, DefaultActiveTime)
account := &et.Account{
AccountID: payload.AccountID,
Addr: a.fromaddr,
Index: a.GetIndex(),
PrevAddr: "",
Status: et.Normal,
CreateTime: a.blocktime,
ExpireTime: a.blocktime + 5*360*24*3600,
ExpireTime: a.blocktime + defaultActiveTime,
LockTime: 0,
Index: a.GetIndex(),
}
re := &et.AccountReceipt{
Account: account,
}
receiptlog := &types.ReceiptLog{Ty: et.TyRegisterLog, Log: types.Encode(re)}
logs = append(logs, receiptlog)
......@@ -64,41 +89,296 @@ func (a *Action) Register(payload *et.Register) (*types.Receipt, error) {
}
//为了避免别人恶意重置别人的帐号,这个操作仅有系统管理员有权限去操作
func (a *Action) ReSet(payload *et.Reset) (*types.Receipt, error) {
func (a *Action) Reset(payload *et.ResetKey) (*types.Receipt, error) {
var logs []*types.ReceiptLog
account, err := queryMarketDepth(a.localDB, payload.AccountID)
cfg := a.api.GetConfig()
managerAddr := getManagerAddr(cfg, a.statedb, ConfNameManagerAddr, DefaultManagerAddr)
if managerAddr != a.fromaddr {
return nil, et.ErrNotAdmin
}
account, err := findAccountByID(a.localDB, payload.AccountID)
if err != nil {
return nil, et.ErrAccountNameNotExist
return nil, et.ErrAccountIDNotExist
}
//TODO 重置公钥锁定期暂定15天,后面可以由管理员去配置
re := &et.Receipt{
AccountID: account.AccountID,
PrevAddr: account.Addr,
Addr: payload.Addr,
Index: account.Index,
Status: et.Locked,
CreateTime: account.CreateTime,
ExpireTime: account.ExpireTime,
LockTime: a.blocktime + 15*24*3600,
//重置公钥锁定期暂定15天,可以由管理员去配置
defaultLockTime := getConfValue(cfg, a.statedb, ConfNameLockTime, DefaultLockTime)
account.Status = et.Locked
account.LockTime = a.blocktime + defaultLockTime
account.PrevAddr = account.Addr
account.Addr = payload.Addr
re := &et.AccountReceipt{
Account: account,
}
receiptlog := &types.ReceiptLog{Ty: et.TyRegisterLog, Log: types.Encode(re)}
receiptlog := &types.ReceiptLog{Ty: et.TyResetLog, Log: types.Encode(re)}
logs = append(logs, receiptlog)
receipts := &types.Receipt{Ty: types.ExecOk, KV: nil, Logs: logs}
return receipts, nil
}
func(a *Action) Transfer(payload *et.Transfer)(*types.Receipt, error){
func (a *Action) Transfer(payload *et.Transfer) (*types.Receipt, error) {
var logs []*types.ReceiptLog
var kvs []*types.KeyValue
account1, err := findAccountByID(a.localDB, payload.FromAccountID)
if err != nil {
elog.Error("Transfer", "fromAccountID", payload.FromAccountID, "err", et.ErrAccountIDNotExist)
return nil, et.ErrAccountIDNotExist
}
if account1.Status != et.Normal || account1.Addr != a.fromaddr || account1.ExpireTime <= a.blocktime {
elog.Error("Transfer", "fromaddr", a.fromaddr, "err", et.ErrAccountIDNotPermiss)
return nil, et.ErrAccountIDNotPermiss
}
account2, err := findAccountByID(a.localDB, payload.ToAccountID)
if err != nil {
elog.Error("Transfer,check to accountID", "toAccountID", payload.ToAccountID, "err", et.ErrAccountIDNotExist)
return nil, et.ErrAccountIDNotExist
}
if account2.Status != et.Normal || account2.ExpireTime <= a.blocktime {
elog.Error("Transfer", "ToAccountID", account2.AccountID, "err", et.ErrAccountIDNotPermiss)
return nil, et.ErrAccountIDNotPermiss
}
cfg := a.api.GetConfig()
acc, err := account.NewAccountDB(cfg, payload.Asset.GetExecer(), payload.Asset.GetSymbol(), a.statedb)
assetDB, err := account.NewAccountDB(cfg, payload.Asset.GetExecer(), payload.Asset.GetSymbol(), a.statedb)
if err != nil {
return nil, err
}
fromAccount := assetDB.LoadExecAccount(a.fromaddr, a.execaddr)
if fromAccount.Balance < payload.Amount {
elog.Error("Transfer, check balance", "addr", a.fromaddr, "avail", fromAccount.Balance, "need", payload.Amount)
return nil, et.ErrAssetBalance
}
receipt, err := assetDB.ExecTransfer(account1.Addr, account2.Addr, a.execaddr, payload.Amount)
if err != nil {
return nil, err
}
logs = append(logs, receipt.Logs...)
kvs = append(kvs, receipt.KV...)
re := &et.TransferReceipt{
FromAccount: account1,
ToAccount: account2,
BlockTime: a.blocktime,
}
receiptlog := &types.ReceiptLog{Ty: et.TyTransferLog, Log: types.Encode(re)}
logs = append(logs, receiptlog)
receipts := &types.Receipt{Ty: types.ExecOk, KV: kvs, Logs: logs}
return receipts, nil
}
func (a *Action) Supervise(payload *et.Supervise) (*types.Receipt, error) {
//鉴权,看一下地址是否时管理员地址
cfg := a.api.GetConfig()
managerAddr := getManagerAddr(cfg, a.statedb, ConfNameManagerAddr, DefaultManagerAddr)
if managerAddr != a.fromaddr {
return nil, et.ErrNotAdmin
}
var logs []*types.ReceiptLog
var kvs []*types.KeyValue
var re et.SuperviseReceipt
for _, ID := range payload.AccountIDs {
account, err := findAccountByID(a.localDB, ID)
if err != nil {
elog.Error("Supervise", "AccountID", ID, "err", et.ErrAccountIDNotExist)
return nil, et.ErrAccountIDNotExist
}
switch re.Op {
case et.Freeze:
account.Status = et.Frozen
case et.UnFreeze:
account.Status = et.Normal
case et.AddExpire:
cfg := a.api.GetConfig()
defaultActiveTime := getConfValue(cfg, a.statedb, ConfNameActiveTime, DefaultActiveTime)
account.Status = et.Normal
account.ExpireTime = a.blocktime + defaultActiveTime
}
re.Accounts = append(re.Accounts, account)
}
re.Op = payload.Op
re.BlockTime = a.blocktime
receiptlog := &types.ReceiptLog{Ty: et.TySuperviseLog, Log: types.Encode(&re)}
logs = append(logs, receiptlog)
receipts := &types.Receipt{Ty: types.ExecOk, KV: kvs, Logs: logs}
return receipts, nil
}
func (a *Action) Apply(payload *et.Apply) (*types.Receipt, error) {
var logs []*types.ReceiptLog
account, err := findAccountByID(a.localDB, payload.AccountID)
if err != nil {
elog.Error("Apply", "AccountID", payload.AccountID, "err", et.ErrAccountIDNotExist)
return nil, et.ErrAccountIDNotExist
}
switch payload.Op {
case et.RevokeReset:
if account.Status != et.Locked || account.PrevAddr != a.fromaddr {
elog.Error("Apply", "fromaddr", a.fromaddr, "err", et.ErrAccountIDNotPermiss)
return nil, et.ErrAccountIDNotPermiss
}
account.LockTime = 0
account.Status = et.Normal
account.Addr = a.fromaddr
case et.EnforceReset:
if account.Status != et.Locked || account.Addr != a.fromaddr {
elog.Error("Apply", "fromaddr", a.fromaddr, "err", et.ErrAccountIDNotPermiss)
return nil, et.ErrAccountIDNotPermiss
}
account.LockTime = 0
account.Status = et.Normal
//TODO 资产转移,放在转transfer中执行
}
re := &et.AccountReceipt{
Account: account,
}
receiptlog := &types.ReceiptLog{Ty: et.TyApplyLog, Log: types.Encode(re)}
logs = append(logs, receiptlog)
receipts := &types.Receipt{Ty: types.ExecOk, KV: nil, Logs: logs}
return receipts, nil
}
func queryMarketDepth(localdb dbm.KV, accountName string) (*et.Account, error) {
func getConfValue(cfg *types.Chain33Config, db dbm.KV, key string, defaultValue int64) int64 {
var item types.ConfigItem
value, err := getManageKey(cfg, key, db)
if err != nil {
return defaultValue
}
if value != nil {
err = types.Decode(value, &item)
if err != nil {
elog.Debug("accountmanager getConfValue", "decode db key:", key, "err", err.Error())
return defaultValue
}
}
values := item.GetArr().GetValue()
if len(values) == 0 {
elog.Debug("accountmanager getConfValue", "can't get value from values arr. key:", key)
return defaultValue
}
//取数组最后一位,作为最新配置项的值
v, err := strconv.ParseInt(values[len(values)-1], 10, 64)
if err != nil {
elog.Debug("accountmanager getConfValue", "Type conversion error:", err.Error())
return defaultValue
}
return v
}
func getManagerAddr(cfg *types.Chain33Config, db dbm.KV, key, defaultValue string) string {
var item types.ConfigItem
value, err := getManageKey(cfg, key, db)
if err != nil {
return defaultValue
}
if value != nil {
err = types.Decode(value, &item)
if err != nil {
elog.Debug("accountmanager getConfValue", "decode db key:", key, "err", err.Error())
return defaultValue
}
}
values := item.GetArr().GetValue()
if len(values) == 0 {
elog.Debug("accountmanager getConfValue", "can't get value from values arr. key:", key)
return defaultValue
}
return values[len(values)-1]
}
func getManageKey(cfg *types.Chain33Config, key string, db dbm.KV) ([]byte, error) {
manageKey := types.ManageKey(key)
value, err := db.Get([]byte(manageKey))
if err != nil {
if cfg.IsPara() { //平行链只有一种存储方式
elog.Debug("accountmanager getManage", "can't get value from db,key:", key, "err", err.Error())
return nil, err
}
elog.Debug("accountmanager getManageKey", "get db key", "not found")
return getConfigKey(key, db)
}
return value, nil
}
func getConfigKey(key string, db dbm.KV) ([]byte, error) {
configKey := types.ConfigKey(key)
value, err := db.Get([]byte(configKey))
if err != nil {
elog.Debug("accountmanager getConfigKey", "can't get value from db,key:", key, "err", err.Error())
return nil, err
}
return value, nil
}
func findAccountListByIndex(localdb dbm.KV, direction int32, primaryKey string) (*et.ReplyAccountList, error) {
table := NewAccountTable(localdb)
first := []byte(fmt.Sprintf("%016d", time.Now().Unix()*int64(types.MaxTxsPerBlock)))
var rows []*tab.Row
var err error
if primaryKey == "" { //第一次查询,默认展示最新得成交记录
rows, err = table.ListIndex("index", nil, first, et.Count, direction)
} else {
rows, err = table.ListIndex("index", nil, []byte(primaryKey), et.Count, direction)
}
if err != nil {
elog.Error("findAccountListByIndex.", "index", first, "err", err.Error())
return nil, err
}
var reply et.ReplyAccountList
for _, row := range rows {
account := row.Data.(*et.Account)
//状态变成逾期状态
account.Status = et.Expired
reply.Accounts = append(reply.Accounts, account)
}
//设置主键索引
if len(rows) == int(et.Count) {
reply.PrimaryKey = string(rows[len(rows)-1].Primary)
}
return &reply, nil
}
func findAccountByID(localdb dbm.KV, accountID string) (*et.Account, error) {
table := NewAccountTable(localdb)
primaryKey := []byte(fmt.Sprintf("%s", accountName))
row, err := table.GetData(primaryKey)
prefix := []byte(fmt.Sprintf("%s", accountID))
//第一次查询,默认展示最新得成交记录
rows, err := table.ListIndex("accountID", prefix, nil, 1, et.ListDESC)
if err != nil {
elog.Error("findAccountByID.", "prefix", prefix, "err", err.Error())
return nil, err
}
return row.Data.(*et.Account), nil
for _, row := range rows {
account := row.Data.(*et.Account)
return account, nil
}
return nil, types.ErrNotFound
}
func findAccountListByStatus(localdb dbm.KV, status, direction int32, primaryKey string) (*et.ReplyAccountList, error) {
if status == et.Expired {
return findAccountListByIndex(localdb, direction, primaryKey)
}
table := NewAccountTable(localdb)
prefix := []byte(fmt.Sprintf("%d", status))
var rows []*tab.Row
var err error
if primaryKey == "" { //第一次查询,默认展示最新得成交记录
rows, err = table.ListIndex("status", prefix, nil, et.Count, direction)
} else {
rows, err = table.ListIndex("status", prefix, []byte(primaryKey), et.Count, direction)
}
if err != nil {
elog.Error("findAccountListByStatus.", "status", prefix, "err", err.Error())
return nil, err
}
var reply et.ReplyAccountList
for _, row := range rows {
account := row.Data.(*et.Account)
reply.Accounts = append(reply.Accounts, account)
}
//设置主键索引
if len(rows) == int(et.Count) {
reply.PrimaryKey = string(rows[len(rows)-1].Primary)
}
return &reply, nil
}
......@@ -51,6 +51,11 @@ func (a *accountmanager) GetDriverName() string {
return driverName
}
//ExecutorOrder Exec 的时候 同时执行 ExecLocal
func (e *accountmanager) ExecutorOrder() int64 {
return drivers.ExecLocalSameTime
}
// CheckTx 实现自定义检验交易接口,供框架调用
func (a *accountmanager) CheckTx(tx *types.Transaction, index int) error {
// implement code
......
......@@ -11,32 +11,25 @@ import (
*/
func (a *accountmanager) Exec_Register(payload *aty.Register, tx *types.Transaction, index int) (*types.Receipt, error) {
var receipt *types.Receipt
//implement code
return receipt, nil
action := NewAction(a, tx, index)
return action.Register(payload)
}
func (a *accountmanager) Exec_Reset(payload *aty.Reset, tx *types.Transaction, index int) (*types.Receipt, error) {
var receipt *types.Receipt
//implement code
return receipt, nil
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) {
var receipt *types.Receipt
//implement code
return receipt, nil
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) {
var receipt *types.Receipt
//implement code
return receipt, nil
action := NewAction(a, tx, index)
return action.Supervise(payload)
}
func (a *accountmanager) ExecApply(payload *aty.Apply, tx *types.Transaction, index int) (*types.Receipt, error) {
var receipt *types.Receipt
//implement code
return receipt, nil
func (a *accountmanager) Exec_Apply(payload *aty.Apply, tx *types.Transaction, index int) (*types.Receipt, error) {
return nil, types.ErrActionNotSupport
}
......@@ -2,7 +2,7 @@ package executor
import (
"github.com/33cn/chain33/types"
accountmanagertypes "github.com/33cn/plugin/plugin/dapp/accountmanager/types"
et "github.com/33cn/plugin/plugin/dapp/accountmanager/types"
)
/*
......@@ -10,38 +10,127 @@ import (
* 非关键数据,本地存储(localDB), 用于辅助查询,效率高
*/
func (a *accountmanager) ExecLocal_Register(payload *accountmanagertypes.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{}
//implement code
if receiptData.Ty == types.ExecOk {
for _, log := range receiptData.Logs {
switch log.Ty {
case et.TyRegisterLog:
receipt := &et.AccountReceipt{}
if err := types.Decode(log.Log, receipt); err != nil {
return nil, err
}
accountTable := NewAccountTable(a.GetLocalDB())
err := accountTable.Add(receipt.Account)
if err != nil {
return nil, err
}
kvs, err := accountTable.Save()
if err != nil {
return nil, err
}
dbSet.KV = append(dbSet.KV, kvs...)
}
}
}
return a.addAutoRollBack(tx, dbSet.KV), nil
}
func (a *accountmanager) ExecLocal_Reset(payload *accountmanagertypes.Reset, 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{}
//implement code
if receiptData.Ty == types.ExecOk {
for _, log := range receiptData.Logs {
switch log.Ty {
case et.TyResetLog:
receipt := &et.AccountReceipt{}
if err := types.Decode(log.Log, receipt); err != nil {
return nil, err
}
accountTable := NewAccountTable(a.GetLocalDB())
err := accountTable.Replace(receipt.Account)
if err != nil {
return nil, err
}
kvs, err := accountTable.Save()
if err != nil {
return nil, err
}
dbSet.KV = append(dbSet.KV, kvs...)
}
}
}
return a.addAutoRollBack(tx, dbSet.KV), nil
}
func (a *accountmanager) ExecLocal_Apply(payload *accountmanagertypes.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{}
//implement code
if receiptData.Ty == types.ExecOk {
for _, log := range receiptData.Logs {
switch log.Ty {
case et.TyApplyLog:
receipt := &et.AccountReceipt{}
if err := types.Decode(log.Log, receipt); err != nil {
return nil, err
}
accountTable := NewAccountTable(a.GetLocalDB())
err := accountTable.Replace(receipt.Account)
if err != nil {
return nil, err
}
kvs, err := accountTable.Save()
if err != nil {
return nil, err
}
dbSet.KV = append(dbSet.KV, kvs...)
}
}
}
return a.addAutoRollBack(tx, dbSet.KV), nil
}
func (a *accountmanager) ExecLocal_Transfer(payload *accountmanagertypes.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{}
//implement code
if receiptData.Ty == types.ExecOk {
for _, log := range receiptData.Logs {
switch log.Ty {
case et.TyResetLog:
//账户信息不变更,不需要处理
}
}
}
return a.addAutoRollBack(tx, dbSet.KV), nil
}
func (a *accountmanager) ExecLocal_Supervise(payload *accountmanagertypes.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{}
//implement code
if receiptData.Ty == types.ExecOk {
for _, log := range receiptData.Logs {
switch log.Ty {
case et.TySuperviseLog:
receipt := &et.SuperviseReceipt{}
if err := types.Decode(log.Log, receipt); err != nil {
return nil, err
}
accountTable := NewAccountTable(a.GetLocalDB())
for _, account := range receipt.Accounts {
err := accountTable.Replace(account)
if err != nil {
return nil, err
}
}
kvs, err := accountTable.Save()
if err != nil {
return nil, err
}
dbSet.KV = append(dbSet.KV, kvs...)
}
}
}
return a.addAutoRollBack(tx, dbSet.KV), nil
}
//设置自动回滚
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
......
package executor
import (
"github.com/33cn/chain33/types"
et "github.com/33cn/plugin/plugin/dapp/accountmanager/types"
)
//根据ID查询账户信息
func (s *accountmanager) Query_QueryAccountByID(in *et.QueryAccountByID) (types.Message, error) {
return findAccountByID(s.GetLocalDB(), in.AccountID)
}
//根据状态查询账户列表|| 账户状态 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 (s *accountmanager) Query_QueryExpiredAccounts(in *et.QueryExpiredAccounts) (types.Message, error) {
return findAccountListByIndex(s.GetLocalDB(), in.Direction, in.PrimaryKey)
}
......@@ -24,13 +24,13 @@ const (
var opt_account = &table.Option{
Prefix: KeyPrefixLocalDB,
Name: "account",
Primary: "accountName",
Index: []string{"status"},
Primary: "index",
Index: []string{"status", "accountID"},
}
//状态数据库中存储具体账户信息
func calcAccountKey(accountName string) []byte {
key := fmt.Sprintf("%s"+"accountName:%s", KeyPrefixStateDB, accountName)
func calcAccountKey(accountID string) []byte {
key := fmt.Sprintf("%s"+"accountID:%s", KeyPrefixStateDB, accountID)
return []byte(key)
}
......@@ -73,6 +73,8 @@ func (m *AccountRow) Get(key string) ([]byte, error) {
return []byte(fmt.Sprintf("%s", m.AccountID)), nil
} else if key == "status" {
return []byte(fmt.Sprintf("%d", m.Status)), nil
} else if key == "index" {
return []byte(fmt.Sprintf("%014d", m.GetIndex())), nil
}
return nil, types.ErrNotFound
}
......@@ -5,6 +5,6 @@ import (
"testing"
)
func Test(t *testing.T){
t.Log(fmt.Sprintf("%-s","aaaa100000b"))
func Test(t *testing.T) {
t.Log(fmt.Sprintf("%-s", "aaaa100000b"))
}
......@@ -9,7 +9,7 @@ message AccountmanagerAction {
//注册
Register register = 1;
//重置公钥
Reset reset = 2;
ResetKey resetKey = 2;
//转账
Transfer transfer = 3;
//监管操作
......@@ -28,7 +28,8 @@ message Register {
}
//重置公钥
message Reset {
message ResetKey {
string accountID = 1;
string addr = 2;
}
......@@ -36,7 +37,7 @@ message Reset {
//用户申请服务
message Apply {
string accountID = 1;
//操作, 0,账户注册,1,账户公钥重置 2,账户延期申请 3,账户注销
//操作, 1 撤销账户公钥重置, 2 锁定期结束后,执行重置公钥操作
int32 op = 2;
}
......@@ -63,11 +64,11 @@ message Transfer {
message Supervise {
//账户名单
repeated string accountIDs = 1;
//操作, 1为冻结,2为解冻
//操作, 1为冻结,2为解冻,3增加有效期
int32 op = 2;
}
message Account{
message account{
//账户名称
string accountID = 1;
//地址
......@@ -86,23 +87,47 @@ message Account{
int64 index = 8;
}
message Receipt{
//账户名称
message AccountReceipt{
account account = 1;
}
message ReplyAccountList {
repeated account accounts = 1;
string primaryKey = 2;
}
message TransferReceipt{
account FromAccount = 1;
account ToAccount = 2;
int64 blockTime = 3;
}
//回执日志
message SuperviseReceipt{
repeated account accounts = 1;
int32 op = 2;
int64 blockTime = 3;
}
message QueryExpiredAccounts{
string primaryKey = 1;
//单页返回多少条记录,默认返回10条
// 0降序,1升序,默认降序
int32 direction = 2;
}
message QueryAccountsByStatus{
//账户状态 1 正常, 2表示冻结, 3表示锁定
int32 status = 1;
// 主键索引
string primaryKey = 3;
// 0降序,1升序,默认降序
int32 direction = 5;
}
message QueryAccountByID {
string accountID = 1;
//地址
string addr = 2;
//上一次公钥地址
string prevAddr = 3;
//账户状态 1 正常, 2表示冻结, 3表示锁定 4,过期注销
int32 status = 4;
//注册时间
int64 createTime = 5;
//失效时间
int64 expireTime = 6;
//锁定时间
int64 lockTime = 7;
//索引
int64 index = 8;
}
service accountmanager {
......
......@@ -3,6 +3,7 @@ package types
import (
log "github.com/33cn/chain33/common/log/log15"
"github.com/33cn/chain33/types"
"reflect"
)
/*
......@@ -21,30 +22,59 @@ const (
TyApplyAction
NameRegisterAction = "Register"
NameResetAction = "Reset"
NameResetAction = "ResetKey"
NameTransferAction = "Transfer"
NameSuperviseAction = "Supervise"
NameApplyAction = "Apply"
FuncNameQueryAccountByID = "QueryAccountByID"
FuncNameQueryAccountsByStatus = "QueryAccountsByStatus"
FuncNameQueryExpiredAccounts = "QueryExpiredAccounts"
)
// log类型id值
const (
TyUnknownLog = iota + 100
TyRegisterLog
TyApplyLog
TyResetLog
TyTransferLog
TySuperviseLog
TyApplyLog
)
//状态
const (
UnknownStatus = iota
UnknownStatus = int32(iota)
Normal
Frozen
Locked
Expired
)
//supervior op
const (
UnknownSupervisorOp = int32(iota)
Freeze
UnFreeze
AddExpire
)
//apply op
const (
UnknownApplyOp = int32(iota)
RevokeReset
EnforceReset
)
const (
ListDESC = int32(0)
ListASC = int32(1)
ListSeek = int32(2)
)
const (
//单次list还回条数
Count = int32(10)
)
var (
//AccountmanagerX 执行器名称定义
AccountmanagerX = "accountmanager"
......@@ -58,7 +88,11 @@ var (
}
//定义log的id和具体log类型及名称,填入具体自定义log类型
logMap = map[int64]*types.LogInfo{
//LogID: {Ty: reflect.TypeOf(LogStruct), Name: LogName},
TyRegisterLog: {Ty: reflect.TypeOf(AccountReceipt{}), Name: "TyRegisterLog"},
TyResetLog: {Ty: reflect.TypeOf(TransferReceipt{}), Name: "TyResetLog"},
TyTransferLog: {Ty: reflect.TypeOf(AccountReceipt{}), Name: "TyTransferLog"},
TySuperviseLog: {Ty: reflect.TypeOf(SuperviseReceipt{}), Name: "TySuperviseLog"},
TyApplyLog: {Ty: reflect.TypeOf(AccountReceipt{}), Name: "TyApplyLog"},
}
tlog = log.New("module", "accountmanager.types")
)
......
......@@ -11,13 +11,19 @@ It has these top-level messages:
Accountmanager
AccountmanagerAction
Register
Reset
ResetKey
Apply
Asset
Transfer
Supervise
Account
Receipt
AccountReceipt
ReplyAccountList
TransferReceipt
SuperviseReceipt
QueryExpiredAccounts
QueryAccountsByStatus
QueryAccountByID
*/
package types
......@@ -52,7 +58,7 @@ func (*Accountmanager) Descriptor() ([]byte, []int) { return fileDescriptor0, []
type AccountmanagerAction struct {
// Types that are valid to be assigned to Value:
// *AccountmanagerAction_Register
// *AccountmanagerAction_Reset_
// *AccountmanagerAction_ResetKey
// *AccountmanagerAction_Transfer
// *AccountmanagerAction_Supervise
// *AccountmanagerAction_Apply
......@@ -72,8 +78,8 @@ type isAccountmanagerAction_Value interface {
type AccountmanagerAction_Register struct {
Register *Register `protobuf:"bytes,1,opt,name=register,oneof"`
}
type AccountmanagerAction_Reset_ struct {
Reset_ *Reset `protobuf:"bytes,2,opt,name=reset,oneof"`
type AccountmanagerAction_ResetKey struct {
ResetKey *ResetKey `protobuf:"bytes,2,opt,name=resetKey,oneof"`
}
type AccountmanagerAction_Transfer struct {
Transfer *Transfer `protobuf:"bytes,3,opt,name=transfer,oneof"`
......@@ -86,7 +92,7 @@ type AccountmanagerAction_Apply struct {
}
func (*AccountmanagerAction_Register) isAccountmanagerAction_Value() {}
func (*AccountmanagerAction_Reset_) isAccountmanagerAction_Value() {}
func (*AccountmanagerAction_ResetKey) isAccountmanagerAction_Value() {}
func (*AccountmanagerAction_Transfer) isAccountmanagerAction_Value() {}
func (*AccountmanagerAction_Supervise) isAccountmanagerAction_Value() {}
func (*AccountmanagerAction_Apply) isAccountmanagerAction_Value() {}
......@@ -105,9 +111,9 @@ func (m *AccountmanagerAction) GetRegister() *Register {
return nil
}
func (m *AccountmanagerAction) GetReset_() *Reset {
if x, ok := m.GetValue().(*AccountmanagerAction_Reset_); ok {
return x.Reset_
func (m *AccountmanagerAction) GetResetKey() *ResetKey {
if x, ok := m.GetValue().(*AccountmanagerAction_ResetKey); ok {
return x.ResetKey
}
return nil
}
......@@ -144,7 +150,7 @@ func (m *AccountmanagerAction) GetTy() int32 {
func (*AccountmanagerAction) XXX_OneofFuncs() (func(msg proto.Message, b *proto.Buffer) error, func(msg proto.Message, tag, wire int, b *proto.Buffer) (bool, error), func(msg proto.Message) (n int), []interface{}) {
return _AccountmanagerAction_OneofMarshaler, _AccountmanagerAction_OneofUnmarshaler, _AccountmanagerAction_OneofSizer, []interface{}{
(*AccountmanagerAction_Register)(nil),
(*AccountmanagerAction_Reset_)(nil),
(*AccountmanagerAction_ResetKey)(nil),
(*AccountmanagerAction_Transfer)(nil),
(*AccountmanagerAction_Supervise)(nil),
(*AccountmanagerAction_Apply)(nil),
......@@ -160,9 +166,9 @@ func _AccountmanagerAction_OneofMarshaler(msg proto.Message, b *proto.Buffer) er
if err := b.EncodeMessage(x.Register); err != nil {
return err
}
case *AccountmanagerAction_Reset_:
case *AccountmanagerAction_ResetKey:
b.EncodeVarint(2<<3 | proto.WireBytes)
if err := b.EncodeMessage(x.Reset_); err != nil {
if err := b.EncodeMessage(x.ResetKey); err != nil {
return err
}
case *AccountmanagerAction_Transfer:
......@@ -198,13 +204,13 @@ func _AccountmanagerAction_OneofUnmarshaler(msg proto.Message, tag, wire int, b
err := b.DecodeMessage(msg)
m.Value = &AccountmanagerAction_Register{msg}
return true, err
case 2: // value.reset
case 2: // value.resetKey
if wire != proto.WireBytes {
return true, proto.ErrInternalBadWireType
}
msg := new(Reset)
msg := new(ResetKey)
err := b.DecodeMessage(msg)
m.Value = &AccountmanagerAction_Reset_{msg}
m.Value = &AccountmanagerAction_ResetKey{msg}
return true, err
case 3: // value.transfer
if wire != proto.WireBytes {
......@@ -244,8 +250,8 @@ func _AccountmanagerAction_OneofSizer(msg proto.Message) (n int) {
n += proto.SizeVarint(1<<3 | proto.WireBytes)
n += proto.SizeVarint(uint64(s))
n += s
case *AccountmanagerAction_Reset_:
s := proto.Size(x.Reset_)
case *AccountmanagerAction_ResetKey:
s := proto.Size(x.ResetKey)
n += proto.SizeVarint(2<<3 | proto.WireBytes)
n += proto.SizeVarint(uint64(s))
n += s
......@@ -289,24 +295,24 @@ func (m *Register) GetAccountID() string {
}
// 重置公钥
type Reset struct {
type ResetKey struct {
AccountID string `protobuf:"bytes,1,opt,name=accountID" json:"accountID,omitempty"`
Addr string `protobuf:"bytes,2,opt,name=addr" json:"addr,omitempty"`
}
func (m *Reset) Reset() { *m = Reset{} }
func (m *Reset) String() string { return proto.CompactTextString(m) }
func (*Reset) ProtoMessage() {}
func (*Reset) Descriptor() ([]byte, []int) { return fileDescriptor0, []int{3} }
func (m *ResetKey) Reset() { *m = ResetKey{} }
func (m *ResetKey) String() string { return proto.CompactTextString(m) }
func (*ResetKey) ProtoMessage() {}
func (*ResetKey) Descriptor() ([]byte, []int) { return fileDescriptor0, []int{3} }
func (m *Reset) GetAccountID() string {
func (m *ResetKey) GetAccountID() string {
if m != nil {
return m.AccountID
}
return ""
}
func (m *Reset) GetAddr() string {
func (m *ResetKey) GetAddr() string {
if m != nil {
return m.Addr
}
......@@ -316,7 +322,7 @@ func (m *Reset) GetAddr() string {
// 用户申请服务
type Apply struct {
AccountID string `protobuf:"bytes,1,opt,name=accountID" json:"accountID,omitempty"`
// 操作, 0,账户注册,1,账户公钥重置 2,账户延期申请 3,账户注销
// 操作, 1 撤销账户公钥重置, 2 锁定期结束后,执行重置公钥操作
Op int32 `protobuf:"varint,2,opt,name=op" json:"op,omitempty"`
}
......@@ -413,7 +419,7 @@ func (m *Transfer) GetAmount() int64 {
type Supervise struct {
// 账户名单
AccountIDs []string `protobuf:"bytes,1,rep,name=accountIDs" json:"accountIDs,omitempty"`
// 操作, 1为冻结,2为解冻
// 操作, 1为冻结,2为解冻,3增加有效期
Op int32 `protobuf:"varint,2,opt,name=op" json:"op,omitempty"`
}
......@@ -516,97 +522,205 @@ func (m *Account) GetIndex() int64 {
return 0
}
type Receipt struct {
// 账户名称
AccountID string `protobuf:"bytes,1,opt,name=accountID" json:"accountID,omitempty"`
// 地址
Addr string `protobuf:"bytes,2,opt,name=addr" json:"addr,omitempty"`
// 上一次公钥地址
PrevAddr string `protobuf:"bytes,3,opt,name=prevAddr" json:"prevAddr,omitempty"`
// 账户状态 1 正常, 2表示冻结, 3表示锁定 4,过期注销
Status int32 `protobuf:"varint,4,opt,name=status" json:"status,omitempty"`
// 注册时间
CreateTime int64 `protobuf:"varint,5,opt,name=createTime" json:"createTime,omitempty"`
// 失效时间
ExpireTime int64 `protobuf:"varint,6,opt,name=expireTime" json:"expireTime,omitempty"`
// 锁定时间
LockTime int64 `protobuf:"varint,7,opt,name=lockTime" json:"lockTime,omitempty"`
// 索引
Index int64 `protobuf:"varint,8,opt,name=index" json:"index,omitempty"`
type AccountReceipt struct {
Account *Account `protobuf:"bytes,1,opt,name=account" json:"account,omitempty"`
}
func (m *Receipt) Reset() { *m = Receipt{} }
func (m *Receipt) String() string { return proto.CompactTextString(m) }
func (*Receipt) ProtoMessage() {}
func (*Receipt) Descriptor() ([]byte, []int) { return fileDescriptor0, []int{9} }
func (m *AccountReceipt) Reset() { *m = AccountReceipt{} }
func (m *AccountReceipt) String() string { return proto.CompactTextString(m) }
func (*AccountReceipt) ProtoMessage() {}
func (*AccountReceipt) Descriptor() ([]byte, []int) { return fileDescriptor0, []int{9} }
func (m *Receipt) GetAccountID() string {
func (m *AccountReceipt) GetAccount() *Account {
if m != nil {
return m.AccountID
return m.Account
}
return ""
return nil
}
func (m *Receipt) GetAddr() string {
type ReplyAccountList struct {
Accounts []*Account `protobuf:"bytes,1,rep,name=accounts" json:"accounts,omitempty"`
PrimaryKey string `protobuf:"bytes,2,opt,name=primaryKey" json:"primaryKey,omitempty"`
}
func (m *ReplyAccountList) Reset() { *m = ReplyAccountList{} }
func (m *ReplyAccountList) String() string { return proto.CompactTextString(m) }
func (*ReplyAccountList) ProtoMessage() {}
func (*ReplyAccountList) Descriptor() ([]byte, []int) { return fileDescriptor0, []int{10} }
func (m *ReplyAccountList) GetAccounts() []*Account {
if m != nil {
return m.Addr
return m.Accounts
}
return ""
return nil
}
func (m *Receipt) GetPrevAddr() string {
func (m *ReplyAccountList) GetPrimaryKey() string {
if m != nil {
return m.PrevAddr
return m.PrimaryKey
}
return ""
}
func (m *Receipt) GetStatus() int32 {
type TransferReceipt struct {
FromAccount *Account `protobuf:"bytes,1,opt,name=FromAccount" json:"FromAccount,omitempty"`
ToAccount *Account `protobuf:"bytes,2,opt,name=ToAccount" json:"ToAccount,omitempty"`
BlockTime int64 `protobuf:"varint,3,opt,name=blockTime" json:"blockTime,omitempty"`
}
func (m *TransferReceipt) Reset() { *m = TransferReceipt{} }
func (m *TransferReceipt) String() string { return proto.CompactTextString(m) }
func (*TransferReceipt) ProtoMessage() {}
func (*TransferReceipt) Descriptor() ([]byte, []int) { return fileDescriptor0, []int{11} }
func (m *TransferReceipt) GetFromAccount() *Account {
if m != nil {
return m.Status
return m.FromAccount
}
return nil
}
func (m *TransferReceipt) GetToAccount() *Account {
if m != nil {
return m.ToAccount
}
return nil
}
func (m *TransferReceipt) GetBlockTime() int64 {
if m != nil {
return m.BlockTime
}
return 0
}
// 回执日志
type SuperviseReceipt struct {
Accounts []*Account `protobuf:"bytes,1,rep,name=accounts" json:"accounts,omitempty"`
Op int32 `protobuf:"varint,2,opt,name=op" json:"op,omitempty"`
BlockTime int64 `protobuf:"varint,3,opt,name=blockTime" json:"blockTime,omitempty"`
}
func (m *SuperviseReceipt) Reset() { *m = SuperviseReceipt{} }
func (m *SuperviseReceipt) String() string { return proto.CompactTextString(m) }
func (*SuperviseReceipt) ProtoMessage() {}
func (*SuperviseReceipt) Descriptor() ([]byte, []int) { return fileDescriptor0, []int{12} }
func (m *SuperviseReceipt) GetAccounts() []*Account {
if m != nil {
return m.Accounts
}
return nil
}
func (m *SuperviseReceipt) GetOp() int32 {
if m != nil {
return m.Op
}
return 0
}
func (m *Receipt) GetCreateTime() int64 {
func (m *SuperviseReceipt) GetBlockTime() int64 {
if m != nil {
return m.CreateTime
return m.BlockTime
}
return 0
}
func (m *Receipt) GetExpireTime() int64 {
type QueryExpiredAccounts struct {
PrimaryKey string `protobuf:"bytes,1,opt,name=primaryKey" json:"primaryKey,omitempty"`
// 单页返回多少条记录,默认返回10条
// 0降序,1升序,默认降序
Direction int32 `protobuf:"varint,2,opt,name=direction" json:"direction,omitempty"`
}
func (m *QueryExpiredAccounts) Reset() { *m = QueryExpiredAccounts{} }
func (m *QueryExpiredAccounts) String() string { return proto.CompactTextString(m) }
func (*QueryExpiredAccounts) ProtoMessage() {}
func (*QueryExpiredAccounts) Descriptor() ([]byte, []int) { return fileDescriptor0, []int{13} }
func (m *QueryExpiredAccounts) GetPrimaryKey() string {
if m != nil {
return m.ExpireTime
return m.PrimaryKey
}
return ""
}
func (m *QueryExpiredAccounts) GetDirection() int32 {
if m != nil {
return m.Direction
}
return 0
}
func (m *Receipt) GetLockTime() int64 {
type QueryAccountsByStatus struct {
// 账户状态 1 正常, 2表示冻结, 3表示锁定
Status int32 `protobuf:"varint,1,opt,name=status" json:"status,omitempty"`
// 主键索引
PrimaryKey string `protobuf:"bytes,3,opt,name=primaryKey" json:"primaryKey,omitempty"`
// 0降序,1升序,默认降序
Direction int32 `protobuf:"varint,5,opt,name=direction" json:"direction,omitempty"`
}
func (m *QueryAccountsByStatus) Reset() { *m = QueryAccountsByStatus{} }
func (m *QueryAccountsByStatus) String() string { return proto.CompactTextString(m) }
func (*QueryAccountsByStatus) ProtoMessage() {}
func (*QueryAccountsByStatus) Descriptor() ([]byte, []int) { return fileDescriptor0, []int{14} }
func (m *QueryAccountsByStatus) GetStatus() int32 {
if m != nil {
return m.LockTime
return m.Status
}
return 0
}
func (m *Receipt) GetIndex() int64 {
func (m *QueryAccountsByStatus) GetPrimaryKey() string {
if m != nil {
return m.Index
return m.PrimaryKey
}
return ""
}
func (m *QueryAccountsByStatus) GetDirection() int32 {
if m != nil {
return m.Direction
}
return 0
}
type QueryAccountByID struct {
AccountID string `protobuf:"bytes,1,opt,name=accountID" json:"accountID,omitempty"`
}
func (m *QueryAccountByID) Reset() { *m = QueryAccountByID{} }
func (m *QueryAccountByID) String() string { return proto.CompactTextString(m) }
func (*QueryAccountByID) ProtoMessage() {}
func (*QueryAccountByID) Descriptor() ([]byte, []int) { return fileDescriptor0, []int{15} }
func (m *QueryAccountByID) GetAccountID() string {
if m != nil {
return m.AccountID
}
return ""
}
func init() {
proto.RegisterType((*Accountmanager)(nil), "types.Accountmanager")
proto.RegisterType((*AccountmanagerAction)(nil), "types.AccountmanagerAction")
proto.RegisterType((*Register)(nil), "types.Register")
proto.RegisterType((*Reset)(nil), "types.Reset")
proto.RegisterType((*ResetKey)(nil), "types.ResetKey")
proto.RegisterType((*Apply)(nil), "types.Apply")
proto.RegisterType((*Asset)(nil), "types.asset")
proto.RegisterType((*Transfer)(nil), "types.Transfer")
proto.RegisterType((*Supervise)(nil), "types.Supervise")
proto.RegisterType((*Account)(nil), "types.Account")
proto.RegisterType((*Receipt)(nil), "types.Receipt")
proto.RegisterType((*Account)(nil), "types.account")
proto.RegisterType((*AccountReceipt)(nil), "types.AccountReceipt")
proto.RegisterType((*ReplyAccountList)(nil), "types.ReplyAccountList")
proto.RegisterType((*TransferReceipt)(nil), "types.TransferReceipt")
proto.RegisterType((*SuperviseReceipt)(nil), "types.SuperviseReceipt")
proto.RegisterType((*QueryExpiredAccounts)(nil), "types.QueryExpiredAccounts")
proto.RegisterType((*QueryAccountsByStatus)(nil), "types.QueryAccountsByStatus")
proto.RegisterType((*QueryAccountByID)(nil), "types.QueryAccountByID")
}
// Reference imports to suppress errors if they are not otherwise used.
......@@ -650,35 +764,46 @@ var _Accountmanager_serviceDesc = grpc.ServiceDesc{
func init() { proto.RegisterFile("accountmanager.proto", fileDescriptor0) }
var fileDescriptor0 = []byte{
// 476 bytes of a gzipped FileDescriptorProto
0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xdc, 0x54, 0xd1, 0x8a, 0xd3, 0x40,
0x14, 0x6d, 0xd2, 0x9d, 0xb6, 0xb9, 0xab, 0xb5, 0x0c, 0x45, 0x82, 0x88, 0x94, 0xb0, 0x0f, 0x7d,
0xb1, 0xc8, 0x8a, 0x88, 0xf8, 0x14, 0xf1, 0xa1, 0xbe, 0x8e, 0xfb, 0x03, 0xb3, 0xe9, 0xdd, 0x25,
0xd8, 0x64, 0x86, 0x99, 0x69, 0x69, 0xbe, 0x41, 0xf0, 0x1f, 0xfd, 0x13, 0x99, 0x9b, 0x49, 0xda,
0x20, 0x28, 0xbe, 0xfa, 0x96, 0x7b, 0xce, 0xc9, 0xbd, 0xe7, 0x9e, 0x1b, 0x02, 0x4b, 0x59, 0x14,
0xea, 0x50, 0xbb, 0x4a, 0xd6, 0xf2, 0x11, 0xcd, 0x46, 0x1b, 0xe5, 0x14, 0x67, 0xae, 0xd1, 0x68,
0xb3, 0x05, 0xcc, 0xf3, 0x01, 0x9d, 0x7d, 0x8f, 0x61, 0x39, 0x84, 0xf2, 0xc2, 0x95, 0xaa, 0xe6,
0xaf, 0x61, 0x66, 0xf0, 0xb1, 0xb4, 0x0e, 0x4d, 0x1a, 0xad, 0xa2, 0xf5, 0xf5, 0xed, 0xb3, 0x0d,
0x35, 0xd9, 0x88, 0x00, 0x6f, 0x47, 0xa2, 0x97, 0xf0, 0x1b, 0x60, 0x06, 0x2d, 0xba, 0x34, 0x26,
0xed, 0x93, 0x5e, 0x6b, 0xd1, 0x6d, 0x47, 0xa2, 0x25, 0x7d, 0x53, 0x67, 0x64, 0x6d, 0x1f, 0xd0,
0xa4, 0xe3, 0x41, 0xd3, 0xbb, 0x00, 0xfb, 0xa6, 0x9d, 0x84, 0xbf, 0x81, 0xc4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xd9, 0xa6, 0xd1, 0x6a, 0xbc, 0x4e, 0xc4, 0x05, 0xf2, 0x5b,
0x0c, 0x3f, 0x23, 0x98, 0x86, 0x11, 0xff, 0x9e, 0x3d, 0x7f, 0x01, 0x33, 0x6d, 0xf0, 0x98, 0x7b,
0xbc, 0x75, 0xdc, 0xd7, 0x94, 0x9f, 0x93, 0xee, 0x60, 0xc9, 0x2e, 0x13, 0xa1, 0xf2, 0x0e, 0x0b,
0x83, 0xd2, 0xe1, 0x5d, 0x59, 0x21, 0x7d, 0x58, 0x63, 0x71, 0x81, 0x78, 0x1e, 0x4f, 0xba, 0x34,
0x2d, 0x3f, 0x69, 0xf9, 0x33, 0xe2, 0x67, 0xee, 0x55, 0xf1, 0x8d, 0xd8, 0x29, 0xb1, 0x7d, 0xcd,
0x97, 0xc0, 0xca, 0x7a, 0x87, 0xa7, 0x74, 0x46, 0x44, 0x5b, 0xd0, 0x8e, 0x02, 0x0b, 0x2c, 0xf5,
0x7f, 0xbb, 0xe3, 0xed, 0x02, 0xe6, 0xc3, 0x3f, 0xd5, 0xfd, 0x84, 0x7e, 0x55, 0x6f, 0x7f, 0x05,
0x00, 0x00, 0xff, 0xff, 0x6e, 0x2a, 0x31, 0x91, 0xc2, 0x04, 0x00, 0x00,
// 647 bytes of a gzipped FileDescriptorProto
0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x94, 0x55, 0x4d, 0x6f, 0xd3, 0x40,
0x10, 0xad, 0xe3, 0x3a, 0x8d, 0xa7, 0x90, 0x46, 0xab, 0x80, 0x2c, 0x84, 0x50, 0xb4, 0xea, 0x21,
0x42, 0x50, 0x55, 0x45, 0x08, 0x09, 0xb8, 0xb8, 0x2a, 0xa8, 0x15, 0x5c, 0xd8, 0xe6, 0x8c, 0xe4,
0x3a, 0xd3, 0xca, 0x22, 0x8e, 0x57, 0xbb, 0x9b, 0xaa, 0xfe, 0x13, 0x70, 0xe1, 0x0f, 0xf2, 0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84, 0x51, 0xb7, 0xdc, 0x71, 0x7d, 0x76, 0x72, 0xf7, 0x65, 0x3a, 0x1a, 0xc1,
0x70, 0xfd, 0x27, 0x73, 0xd1, 0x37, 0x7f, 0x99, 0x37, 0x7f, 0x03, 0x00, 0x00, 0xff, 0xff, 0x77,
0x0c, 0x4d, 0x85, 0x7d, 0x06, 0x00, 0x00,
}
......@@ -4,7 +4,9 @@ import "fmt"
// some errors definition
var (
ErrAccountNameExist = fmt.Errorf("%s", "The account name has been registered!")
ErrAccountNameNotExist = fmt.Errorf("%s", "The account name is not exist")
ErrAccountIDExist = fmt.Errorf("%s", "The account ID has been registered!")
ErrAccountIDNotExist = fmt.Errorf("%s", "The account ID is not exist")
ErrAccountIDNotPermiss = fmt.Errorf("%s", "You don't have permission to do that!")
ErrAssetBalance = fmt.Errorf("%s", "Insufficient balance!")
ErrNotAdmin = fmt.Errorf("%s", "No adiministrator privileges!")
)
package init
import (
_ "github.com/33cn/plugin/plugin/dapp/accountmanager" //auto gen
_ "github.com/33cn/plugin/plugin/dapp/autonomy" //auto gen
_ "github.com/33cn/plugin/plugin/dapp/blackwhite" //auto gen
_ "github.com/33cn/plugin/plugin/dapp/cert" //auto gen
......
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