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
855c253e
Commit
855c253e
authored
Oct 28, 2021
by
轻松
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
优化判断逻辑
parent
1c757073
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
14 additions
and
5 deletions
+14
-5
evmxgodb.go
plugin/dapp/evmxgo/executor/evmxgodb.go
+14
-5
No files found.
plugin/dapp/evmxgo/executor/evmxgodb.go
View file @
855c253e
...
...
@@ -62,12 +62,21 @@ func loadEvmxgoDB(db dbm.KV, symbol string) (*evmxgoDB, error) {
return
&
evmxgoDB
{
e
},
nil
}
func
safeAdd
(
balance
,
amount
int64
)
(
int64
,
error
)
{
if
balance
+
amount
<
amount
||
balance
+
amount
>
types
.
MaxTokenBalance
{
return
balance
,
types
.
ErrAmount
}
return
balance
+
amount
,
nil
}
func
(
e
*
evmxgoDB
)
mint
(
db
dbm
.
KV
,
addr
string
,
amount
int64
)
([]
*
types
.
KeyValue
,
[]
*
types
.
ReceiptLog
,
error
)
{
if
e
.
evmxgo
.
Total
+
amount
>
types
.
MaxTokenBalance
{
return
nil
,
nil
,
types
.
ErrAmount
newTotal
,
err
:=
safeAdd
(
e
.
evmxgo
.
Total
,
amount
)
if
err
!=
nil
{
return
nil
,
nil
,
err
}
prevEvmxgo
:=
e
.
evmxgo
e
.
evmxgo
.
Total
+=
amount
e
.
evmxgo
.
Total
=
newTotal
kvs
:=
e
.
getKVSet
(
calcEvmxgoKey
(
e
.
evmxgo
.
Symbol
))
logs
:=
[]
*
types
.
ReceiptLog
{{
Ty
:
evmxgotypes
.
TyLogEvmxgoMint
,
Log
:
types
.
Encode
(
&
evmxgotypes
.
ReceiptEvmxgoAmount
{
Prev
:
&
prevEvmxgo
,
Current
:
&
e
.
evmxgo
})}}
...
...
@@ -264,11 +273,11 @@ func (action *evmxgoAction) mint(mint *evmxgotypes.EvmxgoMint) (*types.Receipt,
// TODO check()
evmxgodb
,
err
:=
loadEvmxgoDB
(
action
.
db
,
mint
.
GetSymbol
())
if
err
!=
nil
&&
err
!=
evmxgotypes
.
ErrEvmxgoSymbolNotExist
{
if
err
!=
nil
{
if
err
!=
evmxgotypes
.
ErrEvmxgoSymbolNotExist
{
return
nil
,
err
}
// evmxgo合约,只要配置了就可以铸币
if
err
==
evmxgotypes
.
ErrEvmxgoSymbolNotExist
{
configSynbol
,
err
:=
loadEvmxgoMintConfig
(
action
.
db
,
mint
.
GetSymbol
())
if
err
!=
nil
||
configSynbol
==
nil
{
elog
.
Error
(
"evmxgo mint "
,
"not config symbol"
,
mint
.
GetSymbol
(),
"error"
,
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