Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
P
plugin
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
JIRA
JIRA
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
link33
plugin
Commits
5f25bf14
Commit
5f25bf14
authored
Mar 26, 2020
by
harrylee
Committed by
vipwzw
Apr 04, 2020
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
make linter
parent
4bb88ab6
Show whitespace changes
Inline
Side-by-side
Showing
9 changed files
with
43 additions
and
47 deletions
+43
-47
account_test.go
plugin/dapp/accountmanager/executor/account_test.go
+1
-1
accountdb.go
plugin/dapp/accountmanager/executor/accountdb.go
+9
-9
accountmanager.go
plugin/dapp/accountmanager/executor/accountmanager.go
+8
-11
exec.go
plugin/dapp/accountmanager/executor/exec.go
+5
-5
exec_del_local.go
plugin/dapp/accountmanager/executor/exec_del_local.go
+1
-1
exec_local.go
plugin/dapp/accountmanager/executor/exec_local.go
+6
-6
query.go
plugin/dapp/accountmanager/executor/query.go
+10
-10
tables.go
plugin/dapp/accountmanager/executor/tables.go
+2
-2
accountmanager.go
plugin/dapp/accountmanager/types/accountmanager.go
+1
-2
No files found.
plugin/dapp/accountmanager/executor/account_test.go
View file @
5f25bf14
...
@@ -313,7 +313,7 @@ func Exec_Block(t *testing.T, stateDB db.DB, kvdb db.KVDB, env *execEnv, txs ...
...
@@ -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
:=
types
.
NewChain33Config
(
types
.
GetDefaultCfgstring
())
cfg
.
SetTitleOnlyForTest
(
"chain33"
)
cfg
.
SetTitleOnlyForTest
(
"chain33"
)
exec
:=
newAccountmanager
()
exec
:=
newAccountmanager
()
e
:=
exec
.
(
*
a
ccountmanager
)
e
:=
exec
.
(
*
A
ccountmanager
)
q
:=
queue
.
New
(
"channel"
)
q
:=
queue
.
New
(
"channel"
)
q
.
SetConfig
(
cfg
)
q
.
SetConfig
(
cfg
)
api
,
_
:=
client
.
New
(
q
.
Client
(),
nil
)
api
,
_
:=
client
.
New
(
q
.
Client
(),
nil
)
...
...
plugin/dapp/accountmanager/executor/accountdb.go
View file @
5f25bf14
...
@@ -15,17 +15,17 @@ import (
...
@@ -15,17 +15,17 @@ import (
)
)
var
(
var
(
//有效期
//
ConfNameActiveTime
有效期
ConfNameActiveTime
=
et
.
AccountmanagerX
+
"-"
+
"activeTime"
ConfNameActiveTime
=
et
.
AccountmanagerX
+
"-"
+
"activeTime"
//密钥重置锁定期
//
ConfNameLockTime
密钥重置锁定期
ConfNameLockTime
=
et
.
AccountmanagerX
+
"-"
+
"lockTime"
ConfNameLockTime
=
et
.
AccountmanagerX
+
"-"
+
"lockTime"
//管理员地址
//
ConfNameManagerAddr
管理员地址
ConfNameManagerAddr
=
et
.
AccountmanagerX
+
"-"
+
"managerAddr"
ConfNameManagerAddr
=
et
.
AccountmanagerX
+
"-"
+
"managerAddr"
//默认有效期
//
DefaultActiveTime
默认有效期
DefaultActiveTime
=
int64
(
5
*
360
*
24
*
3600
)
DefaultActiveTime
=
int64
(
5
*
360
*
24
*
3600
)
//默认密钥重置锁定期
//
DefaultLockTime
默认密钥重置锁定期
DefaultLockTime
=
int64
(
15
*
24
*
3600
)
DefaultLockTime
=
int64
(
15
*
24
*
3600
)
//默认管理员地址
//
DefaultManagerAddr
默认管理员地址
DefaultManagerAddr
=
"12qyocayNF7Lv6C9qW4avxs2E7U41fKSfv"
DefaultManagerAddr
=
"12qyocayNF7Lv6C9qW4avxs2E7U41fKSfv"
)
)
...
@@ -42,7 +42,7 @@ type Action struct {
...
@@ -42,7 +42,7 @@ type Action struct {
api
client
.
QueueProtocolAPI
api
client
.
QueueProtocolAPI
}
}
func
NewAction
(
e
*
a
ccountmanager
,
tx
*
types
.
Transaction
,
index
int
)
*
Action
{
func
NewAction
(
e
*
A
ccountmanager
,
tx
*
types
.
Transaction
,
index
int
)
*
Action
{
hash
:=
tx
.
Hash
()
hash
:=
tx
.
Hash
()
fromaddr
:=
tx
.
From
()
fromaddr
:=
tx
.
From
()
return
&
Action
{
e
.
GetStateDB
(),
hash
,
fromaddr
,
return
&
Action
{
e
.
GetStateDB
(),
hash
,
fromaddr
,
...
@@ -407,7 +407,7 @@ func findAccountListByIndex(localdb dbm.KV, expireTime int64, primaryKey string)
...
@@ -407,7 +407,7 @@ func findAccountListByIndex(localdb dbm.KV, expireTime int64, primaryKey string)
func
findAccountByID
(
localdb
dbm
.
KV
,
accountID
string
)
(
*
et
.
Account
,
error
)
{
func
findAccountByID
(
localdb
dbm
.
KV
,
accountID
string
)
(
*
et
.
Account
,
error
)
{
table
:=
NewAccountTable
(
localdb
)
table
:=
NewAccountTable
(
localdb
)
prefix
:=
[]
byte
(
fmt
.
Sprintf
(
"%s"
,
accountID
)
)
prefix
:=
[]
byte
(
accountID
)
//第一次查询,默认展示最新得成交记录
//第一次查询,默认展示最新得成交记录
rows
,
err
:=
table
.
ListIndex
(
"accountID"
,
prefix
,
nil
,
1
,
et
.
ListDESC
)
rows
,
err
:=
table
.
ListIndex
(
"accountID"
,
prefix
,
nil
,
1
,
et
.
ListDESC
)
if
err
!=
nil
{
if
err
!=
nil
{
...
@@ -423,7 +423,7 @@ func findAccountByID(localdb dbm.KV, accountID string) (*et.Account, error) {
...
@@ -423,7 +423,7 @@ func findAccountByID(localdb dbm.KV, accountID string) (*et.Account, error) {
func
findAccountByAddr
(
localdb
dbm
.
KV
,
addr
string
)
(
*
et
.
Account
,
error
)
{
func
findAccountByAddr
(
localdb
dbm
.
KV
,
addr
string
)
(
*
et
.
Account
,
error
)
{
table
:=
NewAccountTable
(
localdb
)
table
:=
NewAccountTable
(
localdb
)
prefix
:=
[]
byte
(
fmt
.
Sprintf
(
"%s"
,
addr
)
)
prefix
:=
[]
byte
(
addr
)
//第一次查询,默认展示最新得成交记录
//第一次查询,默认展示最新得成交记录
rows
,
err
:=
table
.
ListIndex
(
"addr"
,
prefix
,
nil
,
1
,
et
.
ListDESC
)
rows
,
err
:=
table
.
ListIndex
(
"addr"
,
prefix
,
nil
,
1
,
et
.
ListDESC
)
if
err
!=
nil
{
if
err
!=
nil
{
...
...
plugin/dapp/accountmanager/executor/accountmanager.go
View file @
5f25bf14
...
@@ -28,15 +28,15 @@ func Init(name string, cfg *types.Chain33Config, sub []byte) {
...
@@ -28,15 +28,15 @@ func Init(name string, cfg *types.Chain33Config, sub []byte) {
// InitExecType Init Exec Type
// InitExecType Init Exec Type
func
InitExecType
()
{
func
InitExecType
()
{
ety
:=
types
.
LoadExecutorType
(
driverName
)
ety
:=
types
.
LoadExecutorType
(
driverName
)
ety
.
InitFuncList
(
types
.
ListMethod
(
&
a
ccountmanager
{}))
ety
.
InitFuncList
(
types
.
ListMethod
(
&
A
ccountmanager
{}))
}
}
type
a
ccountmanager
struct
{
type
A
ccountmanager
struct
{
drivers
.
DriverBase
drivers
.
DriverBase
}
}
func
newAccountmanager
()
drivers
.
Driver
{
func
newAccountmanager
()
drivers
.
Driver
{
t
:=
&
a
ccountmanager
{}
t
:=
&
A
ccountmanager
{}
t
.
SetChild
(
t
)
t
.
SetChild
(
t
)
t
.
SetExecutorType
(
types
.
LoadExecutorType
(
driverName
))
t
.
SetExecutorType
(
types
.
LoadExecutorType
(
driverName
))
return
t
return
t
...
@@ -47,17 +47,17 @@ func GetName() string {
...
@@ -47,17 +47,17 @@ func GetName() string {
return
newAccountmanager
()
.
GetName
()
return
newAccountmanager
()
.
GetName
()
}
}
func
(
a
*
a
ccountmanager
)
GetDriverName
()
string
{
func
(
a
*
A
ccountmanager
)
GetDriverName
()
string
{
return
driverName
return
driverName
}
}
//ExecutorOrder Exec 的时候 同时执行 ExecLocal
//ExecutorOrder Exec 的时候 同时执行 ExecLocal
func
(
e
*
a
ccountmanager
)
ExecutorOrder
()
int64
{
func
(
a
*
A
ccountmanager
)
ExecutorOrder
()
int64
{
return
drivers
.
ExecLocalSameTime
return
drivers
.
ExecLocalSameTime
}
}
// CheckTx 实现自定义检验交易接口,供框架调用
// CheckTx 实现自定义检验交易接口,供框架调用
func
(
a
*
a
ccountmanager
)
CheckTx
(
tx
*
types
.
Transaction
,
index
int
)
error
{
func
(
a
*
A
ccountmanager
)
CheckTx
(
tx
*
types
.
Transaction
,
index
int
)
error
{
//发送交易的时候就检查payload,做严格的参数检查
//发送交易的时候就检查payload,做严格的参数检查
var
ama
et
.
AccountmanagerAction
var
ama
et
.
AccountmanagerAction
types
.
Decode
(
tx
.
GetPayload
(),
&
ama
)
types
.
Decode
(
tx
.
GetPayload
(),
&
ama
)
...
@@ -79,10 +79,7 @@ func (a *accountmanager) CheckTx(tx *types.Transaction, index int) error {
...
@@ -79,10 +79,7 @@ func (a *accountmanager) CheckTx(tx *types.Transaction, index int) error {
return
nil
return
nil
}
}
func
(
a
*
a
ccountmanager
)
CheckAccountIDIsExist
(
accountID
string
)
bool
{
func
(
a
*
A
ccountmanager
)
CheckAccountIDIsExist
(
accountID
string
)
bool
{
_
,
err
:=
findAccountByID
(
a
.
GetLocalDB
(),
accountID
)
_
,
err
:=
findAccountByID
(
a
.
GetLocalDB
(),
accountID
)
if
err
==
types
.
ErrNotFound
{
return
err
!=
types
.
ErrNotFound
return
false
}
return
true
}
}
plugin/dapp/accountmanager/executor/exec.go
View file @
5f25bf14
...
@@ -10,27 +10,27 @@ import (
...
@@ -10,27 +10,27 @@ import (
* 关键数据上链(statedb)并生成交易回执(log)
* 关键数据上链(statedb)并生成交易回执(log)
*/
*/
func
(
a
*
a
ccountmanager
)
Exec_Register
(
payload
*
aty
.
Register
,
tx
*
types
.
Transaction
,
index
int
)
(
*
types
.
Receipt
,
error
)
{
func
(
a
*
A
ccountmanager
)
Exec_Register
(
payload
*
aty
.
Register
,
tx
*
types
.
Transaction
,
index
int
)
(
*
types
.
Receipt
,
error
)
{
action
:=
NewAction
(
a
,
tx
,
index
)
action
:=
NewAction
(
a
,
tx
,
index
)
return
action
.
Register
(
payload
)
return
action
.
Register
(
payload
)
}
}
func
(
a
*
a
ccountmanager
)
Exec_ResetKey
(
payload
*
aty
.
ResetKey
,
tx
*
types
.
Transaction
,
index
int
)
(
*
types
.
Receipt
,
error
)
{
func
(
a
*
A
ccountmanager
)
Exec_ResetKey
(
payload
*
aty
.
ResetKey
,
tx
*
types
.
Transaction
,
index
int
)
(
*
types
.
Receipt
,
error
)
{
action
:=
NewAction
(
a
,
tx
,
index
)
action
:=
NewAction
(
a
,
tx
,
index
)
return
action
.
Reset
(
payload
)
return
action
.
Reset
(
payload
)
}
}
func
(
a
*
a
ccountmanager
)
Exec_Transfer
(
payload
*
aty
.
Transfer
,
tx
*
types
.
Transaction
,
index
int
)
(
*
types
.
Receipt
,
error
)
{
func
(
a
*
A
ccountmanager
)
Exec_Transfer
(
payload
*
aty
.
Transfer
,
tx
*
types
.
Transaction
,
index
int
)
(
*
types
.
Receipt
,
error
)
{
action
:=
NewAction
(
a
,
tx
,
index
)
action
:=
NewAction
(
a
,
tx
,
index
)
return
action
.
Transfer
(
payload
)
return
action
.
Transfer
(
payload
)
}
}
func
(
a
*
a
ccountmanager
)
Exec_Supervise
(
payload
*
aty
.
Supervise
,
tx
*
types
.
Transaction
,
index
int
)
(
*
types
.
Receipt
,
error
)
{
func
(
a
*
A
ccountmanager
)
Exec_Supervise
(
payload
*
aty
.
Supervise
,
tx
*
types
.
Transaction
,
index
int
)
(
*
types
.
Receipt
,
error
)
{
action
:=
NewAction
(
a
,
tx
,
index
)
action
:=
NewAction
(
a
,
tx
,
index
)
return
action
.
Supervise
(
payload
)
return
action
.
Supervise
(
payload
)
}
}
func
(
a
*
a
ccountmanager
)
Exec_Apply
(
payload
*
aty
.
Apply
,
tx
*
types
.
Transaction
,
index
int
)
(
*
types
.
Receipt
,
error
)
{
func
(
a
*
A
ccountmanager
)
Exec_Apply
(
payload
*
aty
.
Apply
,
tx
*
types
.
Transaction
,
index
int
)
(
*
types
.
Receipt
,
error
)
{
action
:=
NewAction
(
a
,
tx
,
index
)
action
:=
NewAction
(
a
,
tx
,
index
)
return
action
.
Apply
(
payload
)
return
action
.
Apply
(
payload
)
}
}
plugin/dapp/accountmanager/executor/exec_del_local.go
View file @
5f25bf14
...
@@ -9,7 +9,7 @@ import (
...
@@ -9,7 +9,7 @@ import (
*/
*/
// ExecDelLocal 回退自动删除,重写基类
// ExecDelLocal 回退自动删除,重写基类
func
(
a
*
a
ccountmanager
)
ExecDelLocal
(
tx
*
types
.
Transaction
,
receipt
*
types
.
ReceiptData
,
index
int
)
(
*
types
.
LocalDBSet
,
error
)
{
func
(
a
*
A
ccountmanager
)
ExecDelLocal
(
tx
*
types
.
Transaction
,
receipt
*
types
.
ReceiptData
,
index
int
)
(
*
types
.
LocalDBSet
,
error
)
{
kvs
,
err
:=
a
.
DelRollbackKV
(
tx
,
tx
.
Execer
)
kvs
,
err
:=
a
.
DelRollbackKV
(
tx
,
tx
.
Execer
)
if
err
!=
nil
{
if
err
!=
nil
{
return
nil
,
err
return
nil
,
err
...
...
plugin/dapp/accountmanager/executor/exec_local.go
View file @
5f25bf14
...
@@ -10,7 +10,7 @@ import (
...
@@ -10,7 +10,7 @@ import (
* 非关键数据,本地存储(localDB), 用于辅助查询,效率高
* 非关键数据,本地存储(localDB), 用于辅助查询,效率高
*/
*/
func
(
a
*
a
ccountmanager
)
ExecLocal_Register
(
payload
*
et
.
Register
,
tx
*
types
.
Transaction
,
receiptData
*
types
.
ReceiptData
,
index
int
)
(
*
types
.
LocalDBSet
,
error
)
{
func
(
a
*
A
ccountmanager
)
ExecLocal_Register
(
payload
*
et
.
Register
,
tx
*
types
.
Transaction
,
receiptData
*
types
.
ReceiptData
,
index
int
)
(
*
types
.
LocalDBSet
,
error
)
{
dbSet
:=
&
types
.
LocalDBSet
{}
dbSet
:=
&
types
.
LocalDBSet
{}
if
receiptData
.
Ty
==
types
.
ExecOk
{
if
receiptData
.
Ty
==
types
.
ExecOk
{
for
_
,
log
:=
range
receiptData
.
Logs
{
for
_
,
log
:=
range
receiptData
.
Logs
{
...
@@ -36,7 +36,7 @@ func (a *accountmanager) ExecLocal_Register(payload *et.Register, tx *types.Tran
...
@@ -36,7 +36,7 @@ func (a *accountmanager) ExecLocal_Register(payload *et.Register, tx *types.Tran
}
}
return
a
.
addAutoRollBack
(
tx
,
dbSet
.
KV
),
nil
return
a
.
addAutoRollBack
(
tx
,
dbSet
.
KV
),
nil
}
}
func
(
a
*
a
ccountmanager
)
ExecLocal_ResetKey
(
payload
*
et
.
ResetKey
,
tx
*
types
.
Transaction
,
receiptData
*
types
.
ReceiptData
,
index
int
)
(
*
types
.
LocalDBSet
,
error
)
{
func
(
a
*
A
ccountmanager
)
ExecLocal_ResetKey
(
payload
*
et
.
ResetKey
,
tx
*
types
.
Transaction
,
receiptData
*
types
.
ReceiptData
,
index
int
)
(
*
types
.
LocalDBSet
,
error
)
{
dbSet
:=
&
types
.
LocalDBSet
{}
dbSet
:=
&
types
.
LocalDBSet
{}
if
receiptData
.
Ty
==
types
.
ExecOk
{
if
receiptData
.
Ty
==
types
.
ExecOk
{
for
_
,
log
:=
range
receiptData
.
Logs
{
for
_
,
log
:=
range
receiptData
.
Logs
{
...
@@ -62,7 +62,7 @@ func (a *accountmanager) ExecLocal_ResetKey(payload *et.ResetKey, tx *types.Tran
...
@@ -62,7 +62,7 @@ func (a *accountmanager) ExecLocal_ResetKey(payload *et.ResetKey, tx *types.Tran
return
a
.
addAutoRollBack
(
tx
,
dbSet
.
KV
),
nil
return
a
.
addAutoRollBack
(
tx
,
dbSet
.
KV
),
nil
}
}
func
(
a
*
a
ccountmanager
)
ExecLocal_Apply
(
payload
*
et
.
Apply
,
tx
*
types
.
Transaction
,
receiptData
*
types
.
ReceiptData
,
index
int
)
(
*
types
.
LocalDBSet
,
error
)
{
func
(
a
*
A
ccountmanager
)
ExecLocal_Apply
(
payload
*
et
.
Apply
,
tx
*
types
.
Transaction
,
receiptData
*
types
.
ReceiptData
,
index
int
)
(
*
types
.
LocalDBSet
,
error
)
{
dbSet
:=
&
types
.
LocalDBSet
{}
dbSet
:=
&
types
.
LocalDBSet
{}
if
receiptData
.
Ty
==
types
.
ExecOk
{
if
receiptData
.
Ty
==
types
.
ExecOk
{
for
_
,
log
:=
range
receiptData
.
Logs
{
for
_
,
log
:=
range
receiptData
.
Logs
{
...
@@ -88,7 +88,7 @@ func (a *accountmanager) ExecLocal_Apply(payload *et.Apply, tx *types.Transactio
...
@@ -88,7 +88,7 @@ func (a *accountmanager) ExecLocal_Apply(payload *et.Apply, tx *types.Transactio
return
a
.
addAutoRollBack
(
tx
,
dbSet
.
KV
),
nil
return
a
.
addAutoRollBack
(
tx
,
dbSet
.
KV
),
nil
}
}
func
(
a
*
a
ccountmanager
)
ExecLocal_Transfer
(
payload
*
et
.
Transfer
,
tx
*
types
.
Transaction
,
receiptData
*
types
.
ReceiptData
,
index
int
)
(
*
types
.
LocalDBSet
,
error
)
{
func
(
a
*
A
ccountmanager
)
ExecLocal_Transfer
(
payload
*
et
.
Transfer
,
tx
*
types
.
Transaction
,
receiptData
*
types
.
ReceiptData
,
index
int
)
(
*
types
.
LocalDBSet
,
error
)
{
dbSet
:=
&
types
.
LocalDBSet
{}
dbSet
:=
&
types
.
LocalDBSet
{}
if
receiptData
.
Ty
==
types
.
ExecOk
{
if
receiptData
.
Ty
==
types
.
ExecOk
{
for
_
,
log
:=
range
receiptData
.
Logs
{
for
_
,
log
:=
range
receiptData
.
Logs
{
...
@@ -114,7 +114,7 @@ func (a *accountmanager) ExecLocal_Transfer(payload *et.Transfer, tx *types.Tran
...
@@ -114,7 +114,7 @@ func (a *accountmanager) ExecLocal_Transfer(payload *et.Transfer, tx *types.Tran
return
a
.
addAutoRollBack
(
tx
,
dbSet
.
KV
),
nil
return
a
.
addAutoRollBack
(
tx
,
dbSet
.
KV
),
nil
}
}
func
(
a
*
a
ccountmanager
)
ExecLocal_Supervise
(
payload
*
et
.
Supervise
,
tx
*
types
.
Transaction
,
receiptData
*
types
.
ReceiptData
,
index
int
)
(
*
types
.
LocalDBSet
,
error
)
{
func
(
a
*
A
ccountmanager
)
ExecLocal_Supervise
(
payload
*
et
.
Supervise
,
tx
*
types
.
Transaction
,
receiptData
*
types
.
ReceiptData
,
index
int
)
(
*
types
.
LocalDBSet
,
error
)
{
dbSet
:=
&
types
.
LocalDBSet
{}
dbSet
:=
&
types
.
LocalDBSet
{}
if
receiptData
.
Ty
==
types
.
ExecOk
{
if
receiptData
.
Ty
==
types
.
ExecOk
{
for
_
,
log
:=
range
receiptData
.
Logs
{
for
_
,
log
:=
range
receiptData
.
Logs
{
...
@@ -165,7 +165,7 @@ func (a *accountmanager) ExecLocal_Supervise(payload *et.Supervise, tx *types.Tr
...
@@ -165,7 +165,7 @@ func (a *accountmanager) ExecLocal_Supervise(payload *et.Supervise, tx *types.Tr
}
}
//设置自动回滚
//设置自动回滚
func
(
a
*
a
ccountmanager
)
addAutoRollBack
(
tx
*
types
.
Transaction
,
kv
[]
*
types
.
KeyValue
)
*
types
.
LocalDBSet
{
func
(
a
*
A
ccountmanager
)
addAutoRollBack
(
tx
*
types
.
Transaction
,
kv
[]
*
types
.
KeyValue
)
*
types
.
LocalDBSet
{
dbSet
:=
&
types
.
LocalDBSet
{}
dbSet
:=
&
types
.
LocalDBSet
{}
dbSet
.
KV
=
a
.
AddRollbackKV
(
tx
,
tx
.
Execer
,
kv
)
dbSet
.
KV
=
a
.
AddRollbackKV
(
tx
,
tx
.
Execer
,
kv
)
return
dbSet
return
dbSet
...
...
plugin/dapp/accountmanager/executor/query.go
View file @
5f25bf14
...
@@ -6,26 +6,26 @@ import (
...
@@ -6,26 +6,26 @@ import (
)
)
//根据ID查询账户信息
//根据ID查询账户信息
func
(
s
*
a
ccountmanager
)
Query_QueryAccountByID
(
in
*
et
.
QueryAccountByID
)
(
types
.
Message
,
error
)
{
func
(
a
*
A
ccountmanager
)
Query_QueryAccountByID
(
in
*
et
.
QueryAccountByID
)
(
types
.
Message
,
error
)
{
return
findAccountByID
(
s
.
GetLocalDB
(),
in
.
AccountID
)
return
findAccountByID
(
a
.
GetLocalDB
(),
in
.
AccountID
)
}
}
//根据ID查询账户信息
//根据ID查询账户信息
func
(
s
*
a
ccountmanager
)
Query_QueryAccountByAddr
(
in
*
et
.
QueryAccountByAddr
)
(
types
.
Message
,
error
)
{
func
(
a
*
A
ccountmanager
)
Query_QueryAccountByAddr
(
in
*
et
.
QueryAccountByAddr
)
(
types
.
Message
,
error
)
{
return
findAccountByAddr
(
s
.
GetLocalDB
(),
in
.
Addr
)
return
findAccountByAddr
(
a
.
GetLocalDB
(),
in
.
Addr
)
}
}
//根据状态查询账户列表|| 账户状态 1 正常, 2表示冻结, 3表示锁定 4,过期注销
//根据状态查询账户列表|| 账户状态 1 正常, 2表示冻结, 3表示锁定 4,过期注销
func
(
s
*
a
ccountmanager
)
Query_QueryAccountsByStatus
(
in
*
et
.
QueryAccountsByStatus
)
(
types
.
Message
,
error
)
{
func
(
a
*
A
ccountmanager
)
Query_QueryAccountsByStatus
(
in
*
et
.
QueryAccountsByStatus
)
(
types
.
Message
,
error
)
{
return
findAccountListByStatus
(
s
.
GetLocalDB
(),
in
.
Status
,
in
.
Direction
,
in
.
PrimaryKey
)
return
findAccountListByStatus
(
a
.
GetLocalDB
(),
in
.
Status
,
in
.
Direction
,
in
.
PrimaryKey
)
}
}
//查询逾期注销的账户列表
//查询逾期注销的账户列表
func
(
s
*
a
ccountmanager
)
Query_QueryExpiredAccounts
(
in
*
et
.
QueryExpiredAccounts
)
(
types
.
Message
,
error
)
{
func
(
a
*
A
ccountmanager
)
Query_QueryExpiredAccounts
(
in
*
et
.
QueryExpiredAccounts
)
(
types
.
Message
,
error
)
{
return
findAccountListByIndex
(
s
.
GetLocalDB
(),
in
.
ExpiredTime
,
in
.
PrimaryKey
)
return
findAccountListByIndex
(
a
.
GetLocalDB
(),
in
.
ExpiredTime
,
in
.
PrimaryKey
)
}
}
//根据ID查询账户余额
//根据ID查询账户余额
func
(
s
*
a
ccountmanager
)
Query_QueryBalanceByID
(
in
*
et
.
QueryBalanceByID
)
(
types
.
Message
,
error
)
{
func
(
a
*
A
ccountmanager
)
Query_QueryBalanceByID
(
in
*
et
.
QueryBalanceByID
)
(
types
.
Message
,
error
)
{
return
queryBalanceByID
(
s
.
GetStateDB
(),
s
.
GetLocalDB
(),
s
.
GetAPI
()
.
GetConfig
(),
s
.
GetName
(),
in
)
return
queryBalanceByID
(
a
.
GetStateDB
(),
a
.
GetLocalDB
(),
a
.
GetAPI
()
.
GetConfig
(),
a
.
GetName
(),
in
)
}
}
plugin/dapp/accountmanager/executor/tables.go
View file @
5f25bf14
...
@@ -71,13 +71,13 @@ func (m *AccountRow) SetPayload(data types.Message) error {
...
@@ -71,13 +71,13 @@ func (m *AccountRow) SetPayload(data types.Message) error {
//Get 按照indexName 查询 indexValue
//Get 按照indexName 查询 indexValue
func
(
m
*
AccountRow
)
Get
(
key
string
)
([]
byte
,
error
)
{
func
(
m
*
AccountRow
)
Get
(
key
string
)
([]
byte
,
error
)
{
if
key
==
"accountID"
{
if
key
==
"accountID"
{
return
[]
byte
(
fmt
.
Sprintf
(
"%s"
,
m
.
AccountID
)
),
nil
return
[]
byte
(
m
.
AccountID
),
nil
}
else
if
key
==
"status"
{
}
else
if
key
==
"status"
{
return
[]
byte
(
fmt
.
Sprintf
(
"%d"
,
m
.
Status
)),
nil
return
[]
byte
(
fmt
.
Sprintf
(
"%d"
,
m
.
Status
)),
nil
}
else
if
key
==
"index"
{
}
else
if
key
==
"index"
{
return
[]
byte
(
fmt
.
Sprintf
(
"%015d"
,
m
.
GetIndex
())),
nil
return
[]
byte
(
fmt
.
Sprintf
(
"%015d"
,
m
.
GetIndex
())),
nil
}
else
if
key
==
"addr"
{
}
else
if
key
==
"addr"
{
return
[]
byte
(
fmt
.
Sprintf
(
"%s"
,
m
.
GetAddr
()
)),
nil
return
[]
byte
(
m
.
GetAddr
(
)),
nil
}
}
return
nil
,
types
.
ErrNotFound
return
nil
,
types
.
ErrNotFound
}
}
plugin/dapp/accountmanager/types/accountmanager.go
View file @
5f25bf14
...
@@ -3,7 +3,6 @@ package types
...
@@ -3,7 +3,6 @@ package types
import
(
import
(
"reflect"
"reflect"
log
"github.com/33cn/chain33/common/log/log15"
"github.com/33cn/chain33/types"
"github.com/33cn/chain33/types"
)
)
...
@@ -97,7 +96,7 @@ var (
...
@@ -97,7 +96,7 @@ var (
TySuperviseLog
:
{
Ty
:
reflect
.
TypeOf
(
SuperviseReceipt
{}),
Name
:
"TySuperviseLog"
},
TySuperviseLog
:
{
Ty
:
reflect
.
TypeOf
(
SuperviseReceipt
{}),
Name
:
"TySuperviseLog"
},
TyApplyLog
:
{
Ty
:
reflect
.
TypeOf
(
AccountReceipt
{}),
Name
:
"TyApplyLog"
},
TyApplyLog
:
{
Ty
:
reflect
.
TypeOf
(
AccountReceipt
{}),
Name
:
"TyApplyLog"
},
}
}
tlog
=
log
.
New
(
"module"
,
"accountmanager.types"
)
//
tlog = log.New("module", "accountmanager.types")
)
)
// init defines a register function
// init defines a register function
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment