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
9c251ca9
Commit
9c251ca9
authored
Feb 28, 2020
by
pengjun
Committed by
vipwzw
Mar 02, 2020
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
#627 fix issuance table error; add fork
parent
bbb107d5
Hide whitespace changes
Inline
Side-by-side
Showing
9 changed files
with
67 additions
and
54 deletions
+67
-54
chain33.para.toml
chain33.para.toml
+2
-0
collateralize_test.go
plugin/dapp/collateralize/executor/collateralize_test.go
+21
-43
exec_local.go
plugin/dapp/collateralize/executor/exec_local.go
+13
-2
collateralize.go
plugin/dapp/collateralize/types/collateralize.go
+1
-0
types.go
plugin/dapp/collateralize/types/types.go
+5
-0
exec_local.go
plugin/dapp/issuance/executor/exec_local.go
+13
-2
issuance_test.go
plugin/dapp/issuance/executor/issuance_test.go
+7
-7
issuance.go
plugin/dapp/issuance/types/issuance.go
+1
-0
types.go
plugin/dapp/issuance/types/types.go
+4
-0
No files found.
chain33.para.toml
View file @
9c251ca9
...
@@ -312,9 +312,11 @@ Enable=0
...
@@ -312,9 +312,11 @@ Enable=0
[fork.sub.issuance]
[fork.sub.issuance]
Enable
=
0
Enable
=
0
ForkIssuanceTableUpdate
=
0
[fork.sub.collateralize]
[fork.sub.collateralize]
Enable
=
0
Enable
=
0
ForkCollateralizeTableUpdate
=
0
#对已有的平行链如果不是从0开始同步数据,需要设置这个kvmvccmavl的对应平行链高度的fork,如果从0开始同步,statehash会跟以前mavl的不同
#对已有的平行链如果不是从0开始同步数据,需要设置这个kvmvccmavl的对应平行链高度的fork,如果从0开始同步,statehash会跟以前mavl的不同
[fork.sub.store-kvmvccmavl]
[fork.sub.store-kvmvccmavl]
...
...
plugin/dapp/collateralize/executor/collateralize_test.go
View file @
9c251ca9
...
@@ -30,6 +30,7 @@ type execEnv struct {
...
@@ -30,6 +30,7 @@ type execEnv struct {
db
dbm
.
KV
db
dbm
.
KV
execAddr
string
execAddr
string
cfg
*
types
.
Chain33Config
cfg
*
types
.
Chain33Config
ldb
dbm
.
DB
}
}
var
(
var
(
...
@@ -76,8 +77,9 @@ func addrKeySet(value string, db dbm.KV) {
...
@@ -76,8 +77,9 @@ func addrKeySet(value string, db dbm.KV) {
func
initEnv
()
*
execEnv
{
func
initEnv
()
*
execEnv
{
cfg
:=
types
.
NewChain33Config
(
types
.
GetDefaultCfgstring
())
cfg
:=
types
.
NewChain33Config
(
types
.
GetDefaultCfgstring
())
cfg
.
SetTitleOnlyForTest
(
"chain33"
)
cfg
.
SetTitleOnlyForTest
(
"chain33"
)
cfg
.
RegisterDappFork
(
pkt
.
CollateralizeX
,
pkt
.
ForkCollateralizeTableUpdate
,
0
)
Init
(
pkt
.
CollateralizeX
,
cfg
,
nil
)
Init
(
pkt
.
CollateralizeX
,
cfg
,
nil
)
_
,
_
,
kvdb
:=
util
.
CreateTestDB
()
_
,
ldb
,
kvdb
:=
util
.
CreateTestDB
()
accountA
:=
types
.
Account
{
accountA
:=
types
.
Account
{
Balance
:
total
,
Balance
:
total
,
...
@@ -140,6 +142,7 @@ func initEnv() *execEnv {
...
@@ -140,6 +142,7 @@ func initEnv() *execEnv {
db
:
stateDB
,
db
:
stateDB
,
execAddr
:
execAddr
,
execAddr
:
execAddr
,
cfg
:
cfg
,
cfg
:
cfg
,
ldb
:
ldb
,
}
}
}
}
...
@@ -182,9 +185,7 @@ func TestCollateralize(t *testing.T) {
...
@@ -182,9 +185,7 @@ func TestCollateralize(t *testing.T) {
set
,
err
:=
exec
.
ExecLocal
(
createTx
,
receiptData
,
int
(
1
))
set
,
err
:=
exec
.
ExecLocal
(
createTx
,
receiptData
,
int
(
1
))
assert
.
Nil
(
t
,
err
)
assert
.
Nil
(
t
,
err
)
assert
.
NotNil
(
t
,
set
)
assert
.
NotNil
(
t
,
set
)
for
_
,
kv
:=
range
set
.
KV
{
util
.
SaveKVList
(
env
.
ldb
,
set
.
KV
)
env
.
kvdb
.
Set
(
kv
.
Key
,
kv
.
Value
)
}
// collateralize create
// collateralize create
p1
:=
&
pkt
.
CollateralizeCreateTx
{
p1
:=
&
pkt
.
CollateralizeCreateTx
{
...
@@ -211,9 +212,7 @@ func TestCollateralize(t *testing.T) {
...
@@ -211,9 +212,7 @@ func TestCollateralize(t *testing.T) {
set
,
err
=
exec
.
ExecLocal
(
createTx
,
receiptData
,
int
(
1
))
set
,
err
=
exec
.
ExecLocal
(
createTx
,
receiptData
,
int
(
1
))
assert
.
Nil
(
t
,
err
)
assert
.
Nil
(
t
,
err
)
assert
.
NotNil
(
t
,
set
)
assert
.
NotNil
(
t
,
set
)
for
_
,
kv
:=
range
set
.
KV
{
util
.
SaveKVList
(
env
.
ldb
,
set
.
KV
)
env
.
kvdb
.
Set
(
kv
.
Key
,
kv
.
Value
)
}
collateralizeID
:=
createTx
.
Hash
()
collateralizeID
:=
createTx
.
Hash
()
// query collateralize by id
// query collateralize by id
res
,
err
:=
exec
.
Query
(
"CollateralizeInfoByID"
,
types
.
Encode
(
&
pkt
.
ReqCollateralizeInfo
{
CollateralizeId
:
common
.
ToHex
(
collateralizeID
)}))
res
,
err
:=
exec
.
Query
(
"CollateralizeInfoByID"
,
types
.
Encode
(
&
pkt
.
ReqCollateralizeInfo
{
CollateralizeId
:
common
.
ToHex
(
collateralizeID
)}))
...
@@ -256,9 +255,7 @@ func TestCollateralize(t *testing.T) {
...
@@ -256,9 +255,7 @@ func TestCollateralize(t *testing.T) {
set
,
err
=
exec
.
ExecLocal
(
createTx
,
receiptData
,
int
(
1
))
set
,
err
=
exec
.
ExecLocal
(
createTx
,
receiptData
,
int
(
1
))
assert
.
Nil
(
t
,
err
)
assert
.
Nil
(
t
,
err
)
assert
.
NotNil
(
t
,
set
)
assert
.
NotNil
(
t
,
set
)
for
_
,
kv
:=
range
set
.
KV
{
util
.
SaveKVList
(
env
.
ldb
,
set
.
KV
)
env
.
kvdb
.
Set
(
kv
.
Key
,
kv
.
Value
)
}
// query collateralize by id
// query collateralize by id
res
,
err
=
exec
.
Query
(
"CollateralizePrice"
,
nil
)
res
,
err
=
exec
.
Query
(
"CollateralizePrice"
,
nil
)
assert
.
Nil
(
t
,
err
)
assert
.
Nil
(
t
,
err
)
...
@@ -291,9 +288,7 @@ func TestCollateralize(t *testing.T) {
...
@@ -291,9 +288,7 @@ func TestCollateralize(t *testing.T) {
set
,
err
=
exec
.
ExecLocal
(
createTx
,
receiptData
,
int
(
1
))
set
,
err
=
exec
.
ExecLocal
(
createTx
,
receiptData
,
int
(
1
))
assert
.
Nil
(
t
,
err
)
assert
.
Nil
(
t
,
err
)
assert
.
NotNil
(
t
,
set
)
assert
.
NotNil
(
t
,
set
)
for
_
,
kv
:=
range
set
.
KV
{
util
.
SaveKVList
(
env
.
ldb
,
set
.
KV
)
env
.
kvdb
.
Set
(
kv
.
Key
,
kv
.
Value
)
}
borrowID
:=
createTx
.
Hash
()
borrowID
:=
createTx
.
Hash
()
// query collateralize by id
// query collateralize by id
res
,
err
=
exec
.
Query
(
"CollateralizeRecordByID"
,
res
,
err
=
exec
.
Query
(
"CollateralizeRecordByID"
,
...
@@ -348,9 +343,7 @@ func TestCollateralize(t *testing.T) {
...
@@ -348,9 +343,7 @@ func TestCollateralize(t *testing.T) {
set
,
err
=
exec
.
ExecLocal
(
createTx
,
receiptData
,
int
(
1
))
set
,
err
=
exec
.
ExecLocal
(
createTx
,
receiptData
,
int
(
1
))
assert
.
Nil
(
t
,
err
)
assert
.
Nil
(
t
,
err
)
assert
.
NotNil
(
t
,
set
)
assert
.
NotNil
(
t
,
set
)
for
_
,
kv
:=
range
set
.
KV
{
util
.
SaveKVList
(
env
.
ldb
,
set
.
KV
)
env
.
kvdb
.
Set
(
kv
.
Key
,
kv
.
Value
)
}
// query collateralize by id
// query collateralize by id
res
,
err
=
exec
.
Query
(
"CollateralizeRecordByID"
,
res
,
err
=
exec
.
Query
(
"CollateralizeRecordByID"
,
types
.
Encode
(
&
pkt
.
ReqCollateralizeRecord
{
CollateralizeId
:
common
.
ToHex
(
collateralizeID
),
RecordId
:
common
.
ToHex
(
borrowID
)}))
types
.
Encode
(
&
pkt
.
ReqCollateralizeRecord
{
CollateralizeId
:
common
.
ToHex
(
collateralizeID
),
RecordId
:
common
.
ToHex
(
borrowID
)}))
...
@@ -394,9 +387,7 @@ func TestCollateralize(t *testing.T) {
...
@@ -394,9 +387,7 @@ func TestCollateralize(t *testing.T) {
set
,
err
=
exec
.
ExecLocal
(
createTx
,
receiptData
,
int
(
1
))
set
,
err
=
exec
.
ExecLocal
(
createTx
,
receiptData
,
int
(
1
))
assert
.
Nil
(
t
,
err
)
assert
.
Nil
(
t
,
err
)
assert
.
NotNil
(
t
,
set
)
assert
.
NotNil
(
t
,
set
)
for
_
,
kv
:=
range
set
.
KV
{
util
.
SaveKVList
(
env
.
ldb
,
set
.
KV
)
env
.
kvdb
.
Set
(
kv
.
Key
,
kv
.
Value
)
}
// query collateralize by status
// query collateralize by status
res
,
err
=
exec
.
Query
(
"CollateralizeRecordByStatus"
,
res
,
err
=
exec
.
Query
(
"CollateralizeRecordByStatus"
,
types
.
Encode
(
&
pkt
.
ReqCollateralizeRecordByStatus
{
CollateralizeId
:
common
.
ToHex
(
collateralizeID
),
Status
:
6
}))
types
.
Encode
(
&
pkt
.
ReqCollateralizeRecordByStatus
{
CollateralizeId
:
common
.
ToHex
(
collateralizeID
),
Status
:
6
}))
...
@@ -444,9 +435,7 @@ func TestCollateralize(t *testing.T) {
...
@@ -444,9 +435,7 @@ func TestCollateralize(t *testing.T) {
set
,
err
=
exec
.
ExecLocal
(
createTx
,
receiptData
,
int
(
1
))
set
,
err
=
exec
.
ExecLocal
(
createTx
,
receiptData
,
int
(
1
))
assert
.
Nil
(
t
,
err
)
assert
.
Nil
(
t
,
err
)
assert
.
NotNil
(
t
,
set
)
assert
.
NotNil
(
t
,
set
)
for
_
,
kv
:=
range
set
.
KV
{
util
.
SaveKVList
(
env
.
ldb
,
set
.
KV
)
env
.
kvdb
.
Set
(
kv
.
Key
,
kv
.
Value
)
}
p71
:=
&
pkt
.
CollateralizeBorrowTx
{
p71
:=
&
pkt
.
CollateralizeBorrowTx
{
CollateralizeID
:
common
.
ToHex
(
collateralizeID
),
CollateralizeID
:
common
.
ToHex
(
collateralizeID
),
...
@@ -474,9 +463,7 @@ func TestCollateralize(t *testing.T) {
...
@@ -474,9 +463,7 @@ func TestCollateralize(t *testing.T) {
set
,
err
=
exec
.
ExecLocal
(
createTx
,
receiptData
,
int
(
1
))
set
,
err
=
exec
.
ExecLocal
(
createTx
,
receiptData
,
int
(
1
))
assert
.
Nil
(
t
,
err
)
assert
.
Nil
(
t
,
err
)
assert
.
NotNil
(
t
,
set
)
assert
.
NotNil
(
t
,
set
)
for
_
,
kv
:=
range
set
.
KV
{
util
.
SaveKVList
(
env
.
ldb
,
set
.
KV
)
env
.
kvdb
.
Set
(
kv
.
Key
,
kv
.
Value
)
}
p8
:=
&
pkt
.
CollateralizeFeedTx
{}
p8
:=
&
pkt
.
CollateralizeFeedTx
{}
p8
.
Price
=
append
(
p8
.
Price
,
0.28
)
p8
.
Price
=
append
(
p8
.
Price
,
0.28
)
...
@@ -503,9 +490,7 @@ func TestCollateralize(t *testing.T) {
...
@@ -503,9 +490,7 @@ func TestCollateralize(t *testing.T) {
set
,
err
=
exec
.
ExecLocal
(
createTx
,
receiptData
,
int
(
1
))
set
,
err
=
exec
.
ExecLocal
(
createTx
,
receiptData
,
int
(
1
))
assert
.
Nil
(
t
,
err
)
assert
.
Nil
(
t
,
err
)
assert
.
NotNil
(
t
,
set
)
assert
.
NotNil
(
t
,
set
)
for
_
,
kv
:=
range
set
.
KV
{
util
.
SaveKVList
(
env
.
ldb
,
set
.
KV
)
env
.
kvdb
.
Set
(
kv
.
Key
,
kv
.
Value
)
}
// query collateralize by status
// query collateralize by status
res
,
err
=
exec
.
Query
(
"CollateralizeRecordByStatus"
,
res
,
err
=
exec
.
Query
(
"CollateralizeRecordByStatus"
,
types
.
Encode
(
&
pkt
.
ReqCollateralizeRecordByStatus
{
CollateralizeId
:
common
.
ToHex
(
collateralizeID
),
Status
:
2
}))
types
.
Encode
(
&
pkt
.
ReqCollateralizeRecordByStatus
{
CollateralizeId
:
common
.
ToHex
(
collateralizeID
),
Status
:
2
}))
...
@@ -540,9 +525,7 @@ func TestCollateralize(t *testing.T) {
...
@@ -540,9 +525,7 @@ func TestCollateralize(t *testing.T) {
set
,
err
=
exec
.
ExecLocal
(
createTx
,
receiptData
,
int
(
1
))
set
,
err
=
exec
.
ExecLocal
(
createTx
,
receiptData
,
int
(
1
))
assert
.
Nil
(
t
,
err
)
assert
.
Nil
(
t
,
err
)
assert
.
NotNil
(
t
,
set
)
assert
.
NotNil
(
t
,
set
)
for
_
,
kv
:=
range
set
.
KV
{
util
.
SaveKVList
(
env
.
ldb
,
set
.
KV
)
env
.
kvdb
.
Set
(
kv
.
Key
,
kv
.
Value
)
}
// query collateralize by status
// query collateralize by status
res
,
err
=
exec
.
Query
(
"CollateralizeRecordByStatus"
,
res
,
err
=
exec
.
Query
(
"CollateralizeRecordByStatus"
,
types
.
Encode
(
&
pkt
.
ReqCollateralizeRecordByStatus
{
CollateralizeId
:
common
.
ToHex
(
collateralizeID
),
Status
:
4
}))
types
.
Encode
(
&
pkt
.
ReqCollateralizeRecordByStatus
{
CollateralizeId
:
common
.
ToHex
(
collateralizeID
),
Status
:
4
}))
...
@@ -574,9 +557,7 @@ func TestCollateralize(t *testing.T) {
...
@@ -574,9 +557,7 @@ func TestCollateralize(t *testing.T) {
set
,
err
=
exec
.
ExecLocal
(
createTx
,
receiptData
,
int
(
1
))
set
,
err
=
exec
.
ExecLocal
(
createTx
,
receiptData
,
int
(
1
))
assert
.
Nil
(
t
,
err
)
assert
.
Nil
(
t
,
err
)
assert
.
NotNil
(
t
,
set
)
assert
.
NotNil
(
t
,
set
)
for
_
,
kv
:=
range
set
.
KV
{
util
.
SaveKVList
(
env
.
ldb
,
set
.
KV
)
env
.
kvdb
.
Set
(
kv
.
Key
,
kv
.
Value
)
}
// query collateralize by status
// query collateralize by status
res
,
err
=
exec
.
Query
(
"CollateralizeRecordByStatus"
,
res
,
err
=
exec
.
Query
(
"CollateralizeRecordByStatus"
,
types
.
Encode
(
&
pkt
.
ReqCollateralizeRecordByStatus
{
CollateralizeId
:
common
.
ToHex
(
collateralizeID
),
Status
:
3
}))
types
.
Encode
(
&
pkt
.
ReqCollateralizeRecordByStatus
{
CollateralizeId
:
common
.
ToHex
(
collateralizeID
),
Status
:
3
}))
...
@@ -585,6 +566,9 @@ func TestCollateralize(t *testing.T) {
...
@@ -585,6 +566,9 @@ func TestCollateralize(t *testing.T) {
res
,
err
=
exec
.
Query
(
"CollateralizeRecordByStatus"
,
res
,
err
=
exec
.
Query
(
"CollateralizeRecordByStatus"
,
types
.
Encode
(
&
pkt
.
ReqCollateralizeRecordByStatus
{
CollateralizeId
:
common
.
ToHex
(
collateralizeID
),
Status
:
4
}))
types
.
Encode
(
&
pkt
.
ReqCollateralizeRecordByStatus
{
CollateralizeId
:
common
.
ToHex
(
collateralizeID
),
Status
:
4
}))
assert
.
Nil
(
t
,
res
)
assert
.
Nil
(
t
,
res
)
res
,
err
=
exec
.
Query
(
"CollateralizeRecordByStatus"
,
types
.
Encode
(
&
pkt
.
ReqCollateralizeRecordByStatus
{
CollateralizeId
:
common
.
ToHex
(
collateralizeID
),
Status
:
1
}))
assert
.
Nil
(
t
,
res
)
// expire liquidate
// expire liquidate
p10
:=
&
pkt
.
CollateralizeBorrowTx
{
p10
:=
&
pkt
.
CollateralizeBorrowTx
{
...
@@ -613,9 +597,7 @@ func TestCollateralize(t *testing.T) {
...
@@ -613,9 +597,7 @@ func TestCollateralize(t *testing.T) {
set
,
err
=
exec
.
ExecLocal
(
createTx
,
receiptData
,
int
(
1
))
set
,
err
=
exec
.
ExecLocal
(
createTx
,
receiptData
,
int
(
1
))
assert
.
Nil
(
t
,
err
)
assert
.
Nil
(
t
,
err
)
assert
.
NotNil
(
t
,
set
)
assert
.
NotNil
(
t
,
set
)
for
_
,
kv
:=
range
set
.
KV
{
util
.
SaveKVList
(
env
.
ldb
,
set
.
KV
)
env
.
kvdb
.
Set
(
kv
.
Key
,
kv
.
Value
)
}
p11
:=
&
pkt
.
CollateralizeFeedTx
{}
p11
:=
&
pkt
.
CollateralizeFeedTx
{}
p11
.
Price
=
append
(
p11
.
Price
,
1
)
p11
.
Price
=
append
(
p11
.
Price
,
1
)
...
@@ -642,9 +624,7 @@ func TestCollateralize(t *testing.T) {
...
@@ -642,9 +624,7 @@ func TestCollateralize(t *testing.T) {
set
,
err
=
exec
.
ExecLocal
(
createTx
,
receiptData
,
int
(
1
))
set
,
err
=
exec
.
ExecLocal
(
createTx
,
receiptData
,
int
(
1
))
assert
.
Nil
(
t
,
err
)
assert
.
Nil
(
t
,
err
)
assert
.
NotNil
(
t
,
set
)
assert
.
NotNil
(
t
,
set
)
for
_
,
kv
:=
range
set
.
KV
{
util
.
SaveKVList
(
env
.
ldb
,
set
.
KV
)
env
.
kvdb
.
Set
(
kv
.
Key
,
kv
.
Value
)
}
// query collateralize by status
// query collateralize by status
res
,
err
=
exec
.
Query
(
"CollateralizeRecordByStatus"
,
res
,
err
=
exec
.
Query
(
"CollateralizeRecordByStatus"
,
types
.
Encode
(
&
pkt
.
ReqCollateralizeRecordByStatus
{
CollateralizeId
:
common
.
ToHex
(
collateralizeID
),
Status
:
5
}))
types
.
Encode
(
&
pkt
.
ReqCollateralizeRecordByStatus
{
CollateralizeId
:
common
.
ToHex
(
collateralizeID
),
Status
:
5
}))
...
@@ -678,9 +658,7 @@ func TestCollateralize(t *testing.T) {
...
@@ -678,9 +658,7 @@ func TestCollateralize(t *testing.T) {
set
,
err
=
exec
.
ExecLocal
(
createTx
,
receiptData
,
int
(
1
))
set
,
err
=
exec
.
ExecLocal
(
createTx
,
receiptData
,
int
(
1
))
assert
.
Nil
(
t
,
err
)
assert
.
Nil
(
t
,
err
)
assert
.
NotNil
(
t
,
set
)
assert
.
NotNil
(
t
,
set
)
for
_
,
kv
:=
range
set
.
KV
{
util
.
SaveKVList
(
env
.
ldb
,
set
.
KV
)
env
.
kvdb
.
Set
(
kv
.
Key
,
kv
.
Value
)
}
// query collateralize by status
// query collateralize by status
res
,
err
=
exec
.
Query
(
"CollateralizeByStatus"
,
types
.
Encode
(
&
pkt
.
ReqCollateralizeByStatus
{
Status
:
1
}))
res
,
err
=
exec
.
Query
(
"CollateralizeByStatus"
,
types
.
Encode
(
&
pkt
.
ReqCollateralizeByStatus
{
Status
:
1
}))
assert
.
Nil
(
t
,
err
)
assert
.
Nil
(
t
,
err
)
...
...
plugin/dapp/collateralize/executor/exec_local.go
View file @
9c251ca9
...
@@ -14,6 +14,13 @@ import (
...
@@ -14,6 +14,13 @@ import (
func
(
c
*
Collateralize
)
execLocal
(
tx
*
types
.
Transaction
,
receipt
*
types
.
ReceiptData
)
(
*
types
.
LocalDBSet
,
error
)
{
func
(
c
*
Collateralize
)
execLocal
(
tx
*
types
.
Transaction
,
receipt
*
types
.
ReceiptData
)
(
*
types
.
LocalDBSet
,
error
)
{
set
:=
&
types
.
LocalDBSet
{}
set
:=
&
types
.
LocalDBSet
{}
var
collTable
,
recordTable
*
table
.
Table
var
collTable
,
recordTable
*
table
.
Table
cfg
:=
c
.
GetAPI
()
.
GetConfig
()
if
cfg
.
IsDappFork
(
c
.
GetHeight
(),
pty
.
CollateralizeX
,
pty
.
ForkCollateralizeTableUpdate
)
{
recordTable
=
pty
.
NewRecordTable
(
c
.
GetLocalDB
())
collTable
=
pty
.
NewCollateralizeTable
(
c
.
GetLocalDB
())
}
for
_
,
item
:=
range
receipt
.
Logs
{
for
_
,
item
:=
range
receipt
.
Logs
{
if
item
.
Ty
>=
pty
.
TyLogCollateralizeCreate
&&
item
.
Ty
<=
pty
.
TyLogCollateralizeRetrieve
{
if
item
.
Ty
>=
pty
.
TyLogCollateralizeCreate
&&
item
.
Ty
<=
pty
.
TyLogCollateralizeRetrieve
{
var
collateralizeLog
pty
.
ReceiptCollateralize
var
collateralizeLog
pty
.
ReceiptCollateralize
...
@@ -23,14 +30,18 @@ func (c *Collateralize) execLocal(tx *types.Transaction, receipt *types.ReceiptD
...
@@ -23,14 +30,18 @@ func (c *Collateralize) execLocal(tx *types.Transaction, receipt *types.ReceiptD
}
}
if
item
.
Ty
==
pty
.
TyLogCollateralizeCreate
||
item
.
Ty
==
pty
.
TyLogCollateralizeRetrieve
{
if
item
.
Ty
==
pty
.
TyLogCollateralizeCreate
||
item
.
Ty
==
pty
.
TyLogCollateralizeRetrieve
{
collTable
=
pty
.
NewCollateralizeTable
(
c
.
GetLocalDB
())
if
!
cfg
.
IsDappFork
(
c
.
GetHeight
(),
pty
.
CollateralizeX
,
pty
.
ForkCollateralizeTableUpdate
)
{
collTable
=
pty
.
NewCollateralizeTable
(
c
.
GetLocalDB
())
}
err
=
collTable
.
Replace
(
&
pty
.
ReceiptCollateralize
{
CollateralizeId
:
collateralizeLog
.
CollateralizeId
,
Status
:
collateralizeLog
.
Status
,
err
=
collTable
.
Replace
(
&
pty
.
ReceiptCollateralize
{
CollateralizeId
:
collateralizeLog
.
CollateralizeId
,
Status
:
collateralizeLog
.
Status
,
AccountAddr
:
collateralizeLog
.
AccountAddr
})
AccountAddr
:
collateralizeLog
.
AccountAddr
})
if
err
!=
nil
{
if
err
!=
nil
{
return
nil
,
err
return
nil
,
err
}
}
}
else
{
}
else
{
recordTable
=
pty
.
NewRecordTable
(
c
.
GetLocalDB
())
if
!
cfg
.
IsDappFork
(
c
.
GetHeight
(),
pty
.
CollateralizeX
,
pty
.
ForkCollateralizeTableUpdate
)
{
recordTable
=
pty
.
NewRecordTable
(
c
.
GetLocalDB
())
}
err
=
recordTable
.
Replace
(
&
pty
.
ReceiptCollateralize
{
CollateralizeId
:
collateralizeLog
.
CollateralizeId
,
Status
:
collateralizeLog
.
Status
,
err
=
recordTable
.
Replace
(
&
pty
.
ReceiptCollateralize
{
CollateralizeId
:
collateralizeLog
.
CollateralizeId
,
Status
:
collateralizeLog
.
Status
,
RecordId
:
collateralizeLog
.
RecordId
,
AccountAddr
:
collateralizeLog
.
AccountAddr
})
RecordId
:
collateralizeLog
.
RecordId
,
AccountAddr
:
collateralizeLog
.
AccountAddr
})
if
err
!=
nil
{
if
err
!=
nil
{
...
...
plugin/dapp/collateralize/types/collateralize.go
View file @
9c251ca9
...
@@ -26,6 +26,7 @@ func init() {
...
@@ -26,6 +26,7 @@ func init() {
func
InitFork
(
cfg
*
types
.
Chain33Config
)
{
func
InitFork
(
cfg
*
types
.
Chain33Config
)
{
cfg
.
RegisterDappFork
(
CollateralizeX
,
"Enable"
,
0
)
cfg
.
RegisterDappFork
(
CollateralizeX
,
"Enable"
,
0
)
cfg
.
RegisterDappFork
(
CollateralizeX
,
ForkCollateralizeTableUpdate
,
0
)
}
}
func
InitExecutor
(
cfg
*
types
.
Chain33Config
)
{
func
InitExecutor
(
cfg
*
types
.
Chain33Config
)
{
...
...
plugin/dapp/collateralize/types/types.go
View file @
9c251ca9
...
@@ -51,3 +51,7 @@ const (
...
@@ -51,3 +51,7 @@ const (
CollateralizeUserStatusExpireLiquidate
CollateralizeUserStatusExpireLiquidate
CollateralizeUserStatusClose
CollateralizeUserStatusClose
)
)
var
(
ForkCollateralizeTableUpdate
=
"ForkCollateralizeTableUpdate"
)
\ No newline at end of file
plugin/dapp/issuance/executor/exec_local.go
View file @
9c251ca9
...
@@ -14,6 +14,13 @@ import (
...
@@ -14,6 +14,13 @@ import (
func
(
c
*
Issuance
)
execLocal
(
tx
*
types
.
Transaction
,
receipt
*
types
.
ReceiptData
)
(
*
types
.
LocalDBSet
,
error
)
{
func
(
c
*
Issuance
)
execLocal
(
tx
*
types
.
Transaction
,
receipt
*
types
.
ReceiptData
)
(
*
types
.
LocalDBSet
,
error
)
{
set
:=
&
types
.
LocalDBSet
{}
set
:=
&
types
.
LocalDBSet
{}
var
IDtable
,
recordTable
*
table
.
Table
var
IDtable
,
recordTable
*
table
.
Table
cfg
:=
c
.
GetAPI
()
.
GetConfig
()
if
cfg
.
IsDappFork
(
c
.
GetHeight
(),
pty
.
IssuanceX
,
pty
.
ForkIssuanceTableUpdate
)
{
recordTable
=
pty
.
NewRecordTable
(
c
.
GetLocalDB
())
IDtable
=
pty
.
NewIssuanceTable
(
c
.
GetLocalDB
())
}
for
_
,
item
:=
range
receipt
.
Logs
{
for
_
,
item
:=
range
receipt
.
Logs
{
if
item
.
Ty
>=
pty
.
TyLogIssuanceCreate
&&
item
.
Ty
<=
pty
.
TyLogIssuanceClose
{
if
item
.
Ty
>=
pty
.
TyLogIssuanceCreate
&&
item
.
Ty
<=
pty
.
TyLogIssuanceClose
{
var
issuanceLog
pty
.
ReceiptIssuance
var
issuanceLog
pty
.
ReceiptIssuance
...
@@ -23,13 +30,17 @@ func (c *Issuance) execLocal(tx *types.Transaction, receipt *types.ReceiptData)
...
@@ -23,13 +30,17 @@ func (c *Issuance) execLocal(tx *types.Transaction, receipt *types.ReceiptData)
}
}
if
item
.
Ty
==
pty
.
TyLogIssuanceCreate
||
item
.
Ty
==
pty
.
TyLogIssuanceClose
{
if
item
.
Ty
==
pty
.
TyLogIssuanceCreate
||
item
.
Ty
==
pty
.
TyLogIssuanceClose
{
IDtable
=
pty
.
NewIssuanceTable
(
c
.
GetLocalDB
())
if
!
cfg
.
IsDappFork
(
c
.
GetHeight
(),
pty
.
IssuanceX
,
pty
.
ForkIssuanceTableUpdate
)
{
IDtable
=
pty
.
NewIssuanceTable
(
c
.
GetLocalDB
())
}
err
=
IDtable
.
Replace
(
&
pty
.
ReceiptIssuanceID
{
IssuanceId
:
issuanceLog
.
IssuanceId
,
Status
:
issuanceLog
.
Status
})
err
=
IDtable
.
Replace
(
&
pty
.
ReceiptIssuanceID
{
IssuanceId
:
issuanceLog
.
IssuanceId
,
Status
:
issuanceLog
.
Status
})
if
err
!=
nil
{
if
err
!=
nil
{
return
nil
,
err
return
nil
,
err
}
}
}
else
{
}
else
{
recordTable
=
pty
.
NewRecordTable
(
c
.
GetLocalDB
())
if
!
cfg
.
IsDappFork
(
c
.
GetHeight
(),
pty
.
IssuanceX
,
pty
.
ForkIssuanceTableUpdate
)
{
recordTable
=
pty
.
NewRecordTable
(
c
.
GetLocalDB
())
}
err
=
recordTable
.
Replace
(
&
pty
.
ReceiptIssuance
{
IssuanceId
:
issuanceLog
.
IssuanceId
,
Status
:
issuanceLog
.
Status
,
err
=
recordTable
.
Replace
(
&
pty
.
ReceiptIssuance
{
IssuanceId
:
issuanceLog
.
IssuanceId
,
Status
:
issuanceLog
.
Status
,
DebtId
:
issuanceLog
.
DebtId
,
AccountAddr
:
issuanceLog
.
AccountAddr
})
DebtId
:
issuanceLog
.
DebtId
,
AccountAddr
:
issuanceLog
.
AccountAddr
})
if
err
!=
nil
{
if
err
!=
nil
{
...
...
plugin/dapp/issuance/executor/issuance_test.go
View file @
9c251ca9
...
@@ -64,6 +64,7 @@ func manageKeySet(key string, value string, db dbm.KV) {
...
@@ -64,6 +64,7 @@ func manageKeySet(key string, value string, db dbm.KV) {
func
initEnv
()
*
execEnv
{
func
initEnv
()
*
execEnv
{
cfg
:=
types
.
NewChain33Config
(
types
.
GetDefaultCfgstring
())
cfg
:=
types
.
NewChain33Config
(
types
.
GetDefaultCfgstring
())
cfg
.
SetTitleOnlyForTest
(
"chain33"
)
cfg
.
SetTitleOnlyForTest
(
"chain33"
)
cfg
.
RegisterDappFork
(
pkt
.
IssuanceX
,
pkt
.
ForkIssuanceTableUpdate
,
0
)
Init
(
pkt
.
IssuanceX
,
cfg
,
nil
)
Init
(
pkt
.
IssuanceX
,
cfg
,
nil
)
_
,
ldb
,
kvdb
:=
util
.
CreateTestDB
()
_
,
ldb
,
kvdb
:=
util
.
CreateTestDB
()
...
@@ -483,12 +484,12 @@ func TestIssuance(t *testing.T) {
...
@@ -483,12 +484,12 @@ func TestIssuance(t *testing.T) {
assert
.
NotNil
(
t
,
set
)
assert
.
NotNil
(
t
,
set
)
util
.
SaveKVList
(
env
.
ldb
,
set
.
KV
)
util
.
SaveKVList
(
env
.
ldb
,
set
.
KV
)
// query issuance by status
// query issuance by status
res
,
err
=
exec
.
Query
(
"IssuanceRecordsByStatus"
,
res
,
err
=
exec
.
Query
(
"IssuanceRecordsByStatus"
,
types
.
Encode
(
&
pkt
.
ReqIssuanceRecords
{
Status
:
3
}))
types
.
Encode
(
&
pkt
.
ReqIssuanceRecords
{
Status
:
3
}))
assert
.
Nil
(
t
,
err
)
assert
.
Nil
(
t
,
err
)
assert
.
NotNil
(
t
,
res
)
assert
.
NotNil
(
t
,
res
)
res
,
err
=
exec
.
Query
(
"IssuanceRecordsByStatus"
,
res
,
err
=
exec
.
Query
(
"IssuanceRecordsByStatus"
,
types
.
Encode
(
&
pkt
.
ReqIssuanceRecords
{
Status
:
4
}))
types
.
Encode
(
&
pkt
.
ReqIssuanceRecords
{
Status
:
4
}))
assert
.
Nil
(
t
,
res
)
res
,
err
=
exec
.
Query
(
"IssuanceRecordsByStatus"
,
types
.
Encode
(
&
pkt
.
ReqIssuanceRecords
{
Status
:
1
}))
assert
.
Nil
(
t
,
res
)
assert
.
Nil
(
t
,
res
)
// expire liquidate
// expire liquidate
...
@@ -545,8 +546,7 @@ func TestIssuance(t *testing.T) {
...
@@ -545,8 +546,7 @@ func TestIssuance(t *testing.T) {
assert
.
NotNil
(
t
,
set
)
assert
.
NotNil
(
t
,
set
)
util
.
SaveKVList
(
env
.
ldb
,
set
.
KV
)
util
.
SaveKVList
(
env
.
ldb
,
set
.
KV
)
// query issuance by status
// query issuance by status
res
,
err
=
exec
.
Query
(
"IssuanceRecordsByStatus"
,
res
,
err
=
exec
.
Query
(
"IssuanceRecordsByStatus"
,
types
.
Encode
(
&
pkt
.
ReqIssuanceRecords
{
Status
:
5
}))
types
.
Encode
(
&
pkt
.
ReqIssuanceRecords
{
Status
:
5
}))
assert
.
Nil
(
t
,
err
)
assert
.
Nil
(
t
,
err
)
assert
.
NotNil
(
t
,
res
)
assert
.
NotNil
(
t
,
res
)
...
@@ -584,7 +584,7 @@ func TestIssuance(t *testing.T) {
...
@@ -584,7 +584,7 @@ func TestIssuance(t *testing.T) {
// issuance create
// issuance create
p12
:=
&
pkt
.
IssuanceCreateTx
{
p12
:=
&
pkt
.
IssuanceCreateTx
{
TotalBalance
:
200
,
TotalBalance
:
200
,
DebtCeiling
:
2
00
,
DebtCeiling
:
1
00
,
LiquidationRatio
:
0.25
,
LiquidationRatio
:
0.25
,
Period
:
5
,
Period
:
5
,
}
}
...
...
plugin/dapp/issuance/types/issuance.go
View file @
9c251ca9
...
@@ -26,6 +26,7 @@ func init() {
...
@@ -26,6 +26,7 @@ func init() {
func
InitFork
(
cfg
*
types
.
Chain33Config
)
{
func
InitFork
(
cfg
*
types
.
Chain33Config
)
{
cfg
.
RegisterDappFork
(
IssuanceX
,
"Enable"
,
0
)
cfg
.
RegisterDappFork
(
IssuanceX
,
"Enable"
,
0
)
cfg
.
RegisterDappFork
(
IssuanceX
,
ForkIssuanceTableUpdate
,
0
)
}
}
func
InitExecutor
(
cfg
*
types
.
Chain33Config
)
{
func
InitExecutor
(
cfg
*
types
.
Chain33Config
)
{
...
...
plugin/dapp/issuance/types/types.go
View file @
9c251ca9
...
@@ -49,3 +49,7 @@ const (
...
@@ -49,3 +49,7 @@ const (
ManageKey
=
"issuance-manage"
ManageKey
=
"issuance-manage"
FundKey
=
"issuance-fund"
FundKey
=
"issuance-fund"
)
)
var
(
ForkIssuanceTableUpdate
=
"ForkIssuanceTableUpdate"
)
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