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
1a2863b7
Commit
1a2863b7
authored
Nov 29, 2019
by
pengjun
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
#627 add preIndex & preStatus to collateralize create
parent
b975d224
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
25 additions
and
18 deletions
+25
-18
collateralizedb.go
plugin/dapp/collateralize/executor/collateralizedb.go
+12
-6
exec_del_local.go
plugin/dapp/collateralize/executor/exec_del_local.go
+6
-7
exec_local.go
plugin/dapp/collateralize/executor/exec_local.go
+6
-5
collateralize.proto
plugin/dapp/collateralize/proto/collateralize.proto
+1
-0
collateralize.pb.go
plugin/dapp/collateralize/types/collateralize.pb.go
+0
-0
No files found.
plugin/dapp/collateralize/executor/collateralizedb.go
View file @
1a2863b7
...
...
@@ -121,9 +121,11 @@ func (action *Action) GetCreateReceiptLog(collateralize *pty.Collateralize) *typ
c
:=
&
pty
.
ReceiptCollateralize
{}
c
.
CollateralizeId
=
collateralize
.
CollateralizeId
c
.
PreStatus
=
collateralize
.
PreStatus
c
.
Status
=
collateralize
.
Status
c
.
CreateAddr
=
action
.
fromaddr
c
.
Index
=
collateralize
.
Index
c
.
PreIndex
=
collateralize
.
PreIndex
log
.
Log
=
types
.
Encode
(
c
)
...
...
@@ -205,14 +207,14 @@ func (action *Action) GetFeedReceiptLog(collateralize *pty.Collateralize, record
}
// GetCloseReceiptLog generate logs for Collateralize close action
func
(
action
*
Action
)
Get
Clos
eReceiptLog
(
collateralize
*
pty
.
Collateralize
)
*
types
.
ReceiptLog
{
func
(
action
*
Action
)
Get
Retriev
eReceiptLog
(
collateralize
*
pty
.
Collateralize
)
*
types
.
ReceiptLog
{
log
:=
&
types
.
ReceiptLog
{}
log
.
Ty
=
pty
.
TyLogCollateralizeRetrieve
c
:=
&
pty
.
ReceiptCollateralize
{}
c
.
CollateralizeId
=
collateralize
.
CollateralizeId
c
.
Status
=
collateralize
.
Status
c
.
PreStatus
=
pty
.
CollateralizeStatusCreated
c
.
PreStatus
=
collateralize
.
PreStatus
c
.
CreateAddr
=
action
.
fromaddr
c
.
PreIndex
=
collateralize
.
PreIndex
c
.
Index
=
collateralize
.
Index
...
...
@@ -462,6 +464,9 @@ func (action *Action) CollateralizeCreate(create *pty.CollateralizeCreate) (*typ
coll
.
Collateralize
=
*
collateralize
coll
.
TotalBalance
+=
create
.
TotalBalance
coll
.
Balance
+=
create
.
TotalBalance
coll
.
PreIndex
=
coll
.
Index
coll
.
PreStatus
=
coll
.
Status
coll
.
Index
=
action
.
GetIndex
()
}
clog
.
Debug
(
"CollateralizeCreate created"
,
"CollateralizeID"
,
collateralizeID
,
"TotalBalance"
,
create
.
TotalBalance
)
...
...
@@ -1146,7 +1151,7 @@ func (action *Action) CollateralizeRetrieve(retrieve *pty.CollateralizeRetrieve)
// 收回金额不能大于待放出金额
if
retrieve
.
Balance
>
collateralize
.
Balance
{
clog
.
Error
(
"CollateralizeRetrieve"
,
"CollateralizeId"
,
retrieve
.
CollateralizeId
,
"error"
,
"balance error"
,
"retrieve balance"
,
retrieve
.
Balance
,
"available balance"
,
collateralize
.
Balance
)
return
nil
,
pty
.
ErrPermissionDeny
return
nil
,
types
.
ErrAmount
}
// 解冻ccny
...
...
@@ -1163,15 +1168,16 @@ func (action *Action) CollateralizeRetrieve(retrieve *pty.CollateralizeRetrieve)
coll
:=
&
CollateralizeDB
{
*
collateralize
}
coll
.
TotalBalance
-=
retrieve
.
Balance
coll
.
Balance
-=
retrieve
.
Balance
coll
.
PreStatus
=
coll
.
Status
if
coll
.
TotalBalance
==
0
{
coll
.
PreIndex
=
coll
.
Index
coll
.
Index
=
action
.
GetIndex
()
coll
.
Status
=
pty
.
CollateralizeStatusClose
}
coll
.
PreIndex
=
coll
.
Index
coll
.
Index
=
action
.
GetIndex
()
coll
.
Save
(
action
.
db
)
kv
=
append
(
kv
,
coll
.
GetKVSet
()
...
)
receiptLog
:=
action
.
Get
Clos
eReceiptLog
(
&
coll
.
Collateralize
)
receiptLog
:=
action
.
Get
Retriev
eReceiptLog
(
&
coll
.
Collateralize
)
logs
=
append
(
logs
,
receiptLog
)
return
&
types
.
Receipt
{
Ty
:
types
.
ExecOk
,
KV
:
kv
,
Logs
:
logs
},
nil
...
...
plugin/dapp/collateralize/executor/exec_del_local.go
View file @
1a2863b7
...
...
@@ -24,6 +24,8 @@ func (c *Collateralize) execDelLocal(tx *types.Transaction, receiptData *types.R
case
pty
.
TyLogCollateralizeCreate
:
set
.
KV
=
append
(
set
.
KV
,
c
.
deleteCollateralizeStatus
(
collateralizeLog
.
Status
,
collateralizeLog
.
Index
)
...
)
set
.
KV
=
append
(
set
.
KV
,
c
.
deleteCollateralizeAddr
(
collateralizeLog
.
CreateAddr
,
collateralizeLog
.
Index
)
...
)
set
.
KV
=
append
(
set
.
KV
,
c
.
addCollateralizeStatus
(
collateralizeLog
.
PreStatus
,
collateralizeLog
.
CollateralizeId
,
collateralizeLog
.
PreIndex
)
...
)
set
.
KV
=
append
(
set
.
KV
,
c
.
addCollateralizeAddr
(
collateralizeLog
.
CreateAddr
,
collateralizeLog
.
CollateralizeId
,
collateralizeLog
.
PreStatus
,
collateralizeLog
.
PreIndex
)
...
)
break
case
pty
.
TyLogCollateralizeBorrow
:
set
.
KV
=
append
(
set
.
KV
,
c
.
deleteCollateralizeRecordStatus
(
collateralizeLog
.
Status
,
collateralizeLog
.
Index
)
...
)
...
...
@@ -58,13 +60,10 @@ func (c *Collateralize) execDelLocal(tx *types.Transaction, receiptData *types.R
//}
break
case
pty
.
TyLogCollateralizeRetrieve
:
if
collateralizeLog
.
Status
==
pty
.
CollateralizeStatusClose
{
set
.
KV
=
append
(
set
.
KV
,
c
.
deleteCollateralizeStatus
(
collateralizeLog
.
Status
,
collateralizeLog
.
Index
)
...
)
set
.
KV
=
append
(
set
.
KV
,
c
.
addCollateralizeStatus
(
pty
.
CollateralizeStatusCreated
,
collateralizeLog
.
CollateralizeId
,
collateralizeLog
.
PreIndex
)
...
)
//set.KV = append(set.KV, c.addCollateralizeAddr(collateralizeLog.CreateAddr, collateralizeLog.CollateralizeId,
// collateralizeLog.PreStatus, collateralizeLog.PreIndex)...)
}
set
.
KV
=
append
(
set
.
KV
,
c
.
deleteCollateralizeStatus
(
collateralizeLog
.
Status
,
collateralizeLog
.
Index
)
...
)
set
.
KV
=
append
(
set
.
KV
,
c
.
deleteCollateralizeAddr
(
collateralizeLog
.
CreateAddr
,
collateralizeLog
.
Index
)
...
)
set
.
KV
=
append
(
set
.
KV
,
c
.
addCollateralizeStatus
(
collateralizeLog
.
PreStatus
,
collateralizeLog
.
CollateralizeId
,
collateralizeLog
.
PreIndex
)
...
)
set
.
KV
=
append
(
set
.
KV
,
c
.
addCollateralizeAddr
(
collateralizeLog
.
CreateAddr
,
collateralizeLog
.
CollateralizeId
,
collateralizeLog
.
PreStatus
,
collateralizeLog
.
PreIndex
)
...
)
break
}
}
...
...
plugin/dapp/collateralize/executor/exec_local.go
View file @
1a2863b7
...
...
@@ -23,6 +23,8 @@ func (c *Collateralize) execLocal(tx *types.Transaction, receipt *types.ReceiptD
switch
item
.
Ty
{
case
pty
.
TyLogCollateralizeCreate
:
set
.
KV
=
append
(
set
.
KV
,
c
.
deleteCollateralizeStatus
(
collateralizeLog
.
PreStatus
,
collateralizeLog
.
PreIndex
)
...
)
set
.
KV
=
append
(
set
.
KV
,
c
.
deleteCollateralizeAddr
(
collateralizeLog
.
CreateAddr
,
collateralizeLog
.
PreIndex
)
...
)
set
.
KV
=
append
(
set
.
KV
,
c
.
addCollateralizeStatus
(
collateralizeLog
.
Status
,
collateralizeLog
.
CollateralizeId
,
collateralizeLog
.
Index
)
...
)
set
.
KV
=
append
(
set
.
KV
,
c
.
addCollateralizeAddr
(
collateralizeLog
.
CreateAddr
,
collateralizeLog
.
CollateralizeId
,
collateralizeLog
.
Status
,
collateralizeLog
.
Index
)
...
)
break
...
...
@@ -60,11 +62,10 @@ func (c *Collateralize) execLocal(tx *types.Transaction, receipt *types.ReceiptD
//}
break
case
pty
.
TyLogCollateralizeRetrieve
:
if
collateralizeLog
.
Status
==
pty
.
CollateralizeStatusClose
{
set
.
KV
=
append
(
set
.
KV
,
c
.
addCollateralizeStatus
(
collateralizeLog
.
Status
,
collateralizeLog
.
CollateralizeId
,
collateralizeLog
.
Index
)
...
)
set
.
KV
=
append
(
set
.
KV
,
c
.
deleteCollateralizeStatus
(
collateralizeLog
.
PreStatus
,
collateralizeLog
.
PreIndex
)
...
)
//set.KV = append(set.KV, c.deleteCollateralizeAddr(collateralizeLog.CreateAddr, collateralizeLog.PreIndex)...)
}
set
.
KV
=
append
(
set
.
KV
,
c
.
deleteCollateralizeStatus
(
collateralizeLog
.
PreStatus
,
collateralizeLog
.
PreIndex
)
...
)
set
.
KV
=
append
(
set
.
KV
,
c
.
deleteCollateralizeAddr
(
collateralizeLog
.
CreateAddr
,
collateralizeLog
.
PreIndex
)
...
)
set
.
KV
=
append
(
set
.
KV
,
c
.
addCollateralizeStatus
(
collateralizeLog
.
Status
,
collateralizeLog
.
CollateralizeId
,
collateralizeLog
.
Index
)
...
)
set
.
KV
=
append
(
set
.
KV
,
c
.
addCollateralizeAddr
(
collateralizeLog
.
CreateAddr
,
collateralizeLog
.
CollateralizeId
,
collateralizeLog
.
Status
,
collateralizeLog
.
Index
)
...
)
break
}
}
...
...
plugin/dapp/collateralize/proto/collateralize.proto
View file @
1a2863b7
...
...
@@ -20,6 +20,7 @@ message Collateralize {
int64
index
=
14
;
//当前索引
int64
preIndex
=
15
;
//上一个索引
int64
collBalance
=
16
;
//抵押bty
int32
preStatus
=
17
;
//上一个状态
}
// 借出记录
...
...
plugin/dapp/collateralize/types/collateralize.pb.go
View file @
1a2863b7
This diff is collapsed.
Click to expand it.
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