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
6584e084
Unverified
Commit
6584e084
authored
Oct 28, 2021
by
unpolaris
Committed by
GitHub
Oct 28, 2021
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #4 from unpolaris/evmxgo_contract
fix: 优化判断逻辑
parents
1c757073
855c253e
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 @
6584e084
...
@@ -62,12 +62,21 @@ func loadEvmxgoDB(db dbm.KV, symbol string) (*evmxgoDB, error) {
...
@@ -62,12 +62,21 @@ func loadEvmxgoDB(db dbm.KV, symbol string) (*evmxgoDB, error) {
return
&
evmxgoDB
{
e
},
nil
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
)
{
func
(
e
*
evmxgoDB
)
mint
(
db
dbm
.
KV
,
addr
string
,
amount
int64
)
([]
*
types
.
KeyValue
,
[]
*
types
.
ReceiptLog
,
error
)
{
if
e
.
evmxgo
.
Total
+
amount
>
types
.
MaxTokenBalance
{
newTotal
,
err
:=
safeAdd
(
e
.
evmxgo
.
Total
,
amount
)
return
nil
,
nil
,
types
.
ErrAmount
if
err
!=
nil
{
return
nil
,
nil
,
err
}
}
prevEvmxgo
:=
e
.
evmxgo
prevEvmxgo
:=
e
.
evmxgo
e
.
evmxgo
.
Total
+=
amount
e
.
evmxgo
.
Total
=
newTotal
kvs
:=
e
.
getKVSet
(
calcEvmxgoKey
(
e
.
evmxgo
.
Symbol
))
kvs
:=
e
.
getKVSet
(
calcEvmxgoKey
(
e
.
evmxgo
.
Symbol
))
logs
:=
[]
*
types
.
ReceiptLog
{{
Ty
:
evmxgotypes
.
TyLogEvmxgoMint
,
Log
:
types
.
Encode
(
&
evmxgotypes
.
ReceiptEvmxgoAmount
{
Prev
:
&
prevEvmxgo
,
Current
:
&
e
.
evmxgo
})}}
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,
...
@@ -264,11 +273,11 @@ func (action *evmxgoAction) mint(mint *evmxgotypes.EvmxgoMint) (*types.Receipt,
// TODO check()
// TODO check()
evmxgodb
,
err
:=
loadEvmxgoDB
(
action
.
db
,
mint
.
GetSymbol
())
evmxgodb
,
err
:=
loadEvmxgoDB
(
action
.
db
,
mint
.
GetSymbol
())
if
err
!=
nil
&&
err
!=
evmxgotypes
.
ErrEvmxgoSymbolNotExist
{
if
err
!=
nil
{
if
err
!=
evmxgotypes
.
ErrEvmxgoSymbolNotExist
{
return
nil
,
err
return
nil
,
err
}
}
// evmxgo合约,只要配置了就可以铸币
// evmxgo合约,只要配置了就可以铸币
if
err
==
evmxgotypes
.
ErrEvmxgoSymbolNotExist
{
configSynbol
,
err
:=
loadEvmxgoMintConfig
(
action
.
db
,
mint
.
GetSymbol
())
configSynbol
,
err
:=
loadEvmxgoMintConfig
(
action
.
db
,
mint
.
GetSymbol
())
if
err
!=
nil
||
configSynbol
==
nil
{
if
err
!=
nil
||
configSynbol
==
nil
{
elog
.
Error
(
"evmxgo mint "
,
"not config symbol"
,
mint
.
GetSymbol
(),
"error"
,
err
)
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