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
1a3c8998
Commit
1a3c8998
authored
Mar 11, 2019
by
linj
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
exec local burn
parent
0a56b03b
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
61 additions
and
1 deletion
+61
-1
exec_del_local.go
plugin/dapp/token/executor/exec_del_local.go
+25
-0
exec_local.go
plugin/dapp/token/executor/exec_local.go
+36
-1
No files found.
plugin/dapp/token/executor/exec_del_local.go
View file @
1a3c8998
...
@@ -162,3 +162,28 @@ func (t *token) ExecDelLocal_TokenMint(payload *tokenty.TokenMint, tx *types.Tra
...
@@ -162,3 +162,28 @@ func (t *token) ExecDelLocal_TokenMint(payload *tokenty.TokenMint, tx *types.Tra
return
&
types
.
LocalDBSet
{
KV
:
set
},
nil
return
&
types
.
LocalDBSet
{
KV
:
set
},
nil
}
}
func
(
t
*
token
)
ExecDelLocal_TokenBurn
(
payload
*
tokenty
.
TokenBurn
,
tx
*
types
.
Transaction
,
receiptData
*
types
.
ReceiptData
,
index
int
)
(
*
types
.
LocalDBSet
,
error
)
{
localToken
,
err
:=
loadLocalToken
(
payload
.
Symbol
,
tx
.
From
(),
tokenty
.
TokenStatusCreated
,
t
.
GetLocalDB
())
if
err
!=
nil
{
return
nil
,
err
}
localToken
=
resetBurn
(
localToken
,
t
.
GetHeight
(),
t
.
GetBlockTime
(),
payload
.
Amount
)
key
:=
calcTokenStatusKeyLocal
(
payload
.
Symbol
,
tx
.
From
(),
tokenty
.
TokenStatusCreated
)
var
set
[]
*
types
.
KeyValue
set
=
append
(
set
,
&
types
.
KeyValue
{
Key
:
key
,
Value
:
types
.
Encode
(
localToken
)})
table
:=
NewLogsTable
(
t
.
GetLocalDB
())
txIndex
:=
dapp
.
HeightIndexStr
(
t
.
GetHeight
(),
int64
(
index
))
err
=
table
.
Del
([]
byte
(
txIndex
))
if
err
!=
nil
{
return
nil
,
err
}
kv
,
err
:=
table
.
Save
()
if
err
!=
nil
{
return
nil
,
err
}
set
=
append
(
set
,
kv
...
)
return
&
types
.
LocalDBSet
{
KV
:
set
},
nil
}
plugin/dapp/token/executor/exec_local.go
View file @
1a3c8998
...
@@ -203,6 +203,11 @@ func setMint(t *tokenty.LocalToken, height, time, amount int64) *tokenty.LocalTo
...
@@ -203,6 +203,11 @@ func setMint(t *tokenty.LocalToken, height, time, amount int64) *tokenty.LocalTo
return
t
return
t
}
}
func
setBurn
(
t
*
tokenty
.
LocalToken
,
height
,
time
,
amount
int64
)
*
tokenty
.
LocalToken
{
t
.
Total
=
t
.
Total
-
amount
return
t
}
func
resetCreated
(
t
*
tokenty
.
LocalToken
)
*
tokenty
.
LocalToken
{
func
resetCreated
(
t
*
tokenty
.
LocalToken
)
*
tokenty
.
LocalToken
{
t
.
CreatedTime
=
0
t
.
CreatedTime
=
0
t
.
CreatedHeight
=
0
t
.
CreatedHeight
=
0
...
@@ -222,6 +227,11 @@ func resetMint(t *tokenty.LocalToken, height, time, amount int64) *tokenty.Local
...
@@ -222,6 +227,11 @@ func resetMint(t *tokenty.LocalToken, height, time, amount int64) *tokenty.Local
return
t
return
t
}
}
func
resetBurn
(
t
*
tokenty
.
LocalToken
,
height
,
time
,
amount
int64
)
*
tokenty
.
LocalToken
{
t
.
Total
=
t
.
Total
+
amount
return
t
}
func
(
t
*
token
)
ExecLocal_TokenMint
(
payload
*
tokenty
.
TokenMint
,
tx
*
types
.
Transaction
,
receiptData
*
types
.
ReceiptData
,
index
int
)
(
*
types
.
LocalDBSet
,
error
)
{
func
(
t
*
token
)
ExecLocal_TokenMint
(
payload
*
tokenty
.
TokenMint
,
tx
*
types
.
Transaction
,
receiptData
*
types
.
ReceiptData
,
index
int
)
(
*
types
.
LocalDBSet
,
error
)
{
localToken
,
err
:=
loadLocalToken
(
payload
.
Symbol
,
tx
.
From
(),
tokenty
.
TokenStatusCreated
,
t
.
GetLocalDB
())
localToken
,
err
:=
loadLocalToken
(
payload
.
Symbol
,
tx
.
From
(),
tokenty
.
TokenStatusCreated
,
t
.
GetLocalDB
())
if
err
!=
nil
{
if
err
!=
nil
{
...
@@ -234,7 +244,32 @@ func (t *token) ExecLocal_TokenMint(payload *tokenty.TokenMint, tx *types.Transa
...
@@ -234,7 +244,32 @@ func (t *token) ExecLocal_TokenMint(payload *tokenty.TokenMint, tx *types.Transa
table
:=
NewLogsTable
(
t
.
GetLocalDB
())
table
:=
NewLogsTable
(
t
.
GetLocalDB
())
txIndex
:=
dapp
.
HeightIndexStr
(
t
.
GetHeight
(),
int64
(
index
))
txIndex
:=
dapp
.
HeightIndexStr
(
t
.
GetHeight
(),
int64
(
index
))
err
=
table
.
Add
(
&
tokenty
.
LocalLogs
{
Symbol
:
payload
.
Symbol
,
TxIndex
:
txIndex
,
ActionType
:
tokenty
.
TokenActionMint
,
TxHash
:
hex
.
EncodeToString
(
tx
.
Hash
())})
err
=
table
.
Add
(
&
tokenty
.
LocalLogs
{
Symbol
:
payload
.
Symbol
,
TxIndex
:
txIndex
,
ActionType
:
tokenty
.
TokenActionMint
,
TxHash
:
"0x"
+
hex
.
EncodeToString
(
tx
.
Hash
())})
if
err
!=
nil
{
return
nil
,
err
}
kv
,
err
:=
table
.
Save
()
if
err
!=
nil
{
return
nil
,
err
}
set
=
append
(
set
,
kv
...
)
return
&
types
.
LocalDBSet
{
KV
:
set
},
nil
}
func
(
t
*
token
)
ExecLocal_TokenBurn
(
payload
*
tokenty
.
TokenBurn
,
tx
*
types
.
Transaction
,
receiptData
*
types
.
ReceiptData
,
index
int
)
(
*
types
.
LocalDBSet
,
error
)
{
localToken
,
err
:=
loadLocalToken
(
payload
.
Symbol
,
tx
.
From
(),
tokenty
.
TokenStatusCreated
,
t
.
GetLocalDB
())
if
err
!=
nil
{
return
nil
,
err
}
localToken
=
setBurn
(
localToken
,
t
.
GetHeight
(),
t
.
GetBlockTime
(),
payload
.
Amount
)
var
set
[]
*
types
.
KeyValue
key
:=
calcTokenStatusKeyLocal
(
payload
.
Symbol
,
tx
.
From
(),
tokenty
.
TokenStatusCreated
)
set
=
append
(
set
,
&
types
.
KeyValue
{
Key
:
key
,
Value
:
types
.
Encode
(
localToken
)})
table
:=
NewLogsTable
(
t
.
GetLocalDB
())
txIndex
:=
dapp
.
HeightIndexStr
(
t
.
GetHeight
(),
int64
(
index
))
err
=
table
.
Add
(
&
tokenty
.
LocalLogs
{
Symbol
:
payload
.
Symbol
,
TxIndex
:
txIndex
,
ActionType
:
tokenty
.
TokenActionBurn
,
TxHash
:
"0x"
+
hex
.
EncodeToString
(
tx
.
Hash
())})
if
err
!=
nil
{
if
err
!=
nil
{
return
nil
,
err
return
nil
,
err
}
}
...
...
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