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
e8a09f64
Commit
e8a09f64
authored
Nov 27, 2018
by
vipwzw
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
update chain33 to master
parent
19bca53e
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
55 changed files
with
525 additions
and
313 deletions
+525
-313
LICENSE
vendor/github.com/33cn/chain33/LICENSE
+5
-1
Makefile
vendor/github.com/33cn/chain33/Makefile
+5
-1
chain_test.go
vendor/github.com/33cn/chain33/blockchain/chain_test.go
+1
-1
show.go
...thub.com/33cn/chain33/cmd/miner_accounts/accounts/show.go
+0
-1
write.go
vendor/github.com/33cn/chain33/cmd/write/write.go
+2
-2
go_pegasus.go
vendor/github.com/33cn/chain33/common/db/go_pegasus.go
+1
-2
go_ssdb.go
vendor/github.com/33cn/chain33/common/db/go_ssdb.go
+1
-2
go_ssdb_util.go
vendor/github.com/33cn/chain33/common/db/go_ssdb_util.go
+3
-5
mvcc_test.go
vendor/github.com/33cn/chain33/common/db/mvcc_test.go
+6
-6
ntp.go
vendor/github.com/33cn/chain33/common/ntp.go
+2
-2
pubsub_test.go
vendor/github.com/33cn/chain33/common/pubsub/pubsub_test.go
+2
-2
execenv.go
vendor/github.com/33cn/chain33/executor/execenv.go
+1
-1
executor_test.go
vendor/github.com/33cn/chain33/executor/executor_test.go
+1
-0
mempool.go
vendor/github.com/33cn/chain33/mempool/mempool.go
+1
-1
mempool_test.go
vendor/github.com/33cn/chain33/mempool/mempool_test.go
+1
-1
addrbook.go
vendor/github.com/33cn/chain33/p2p/addrbook.go
+16
-15
downloadblocks.go
vendor/github.com/33cn/chain33/p2p/downloadblocks.go
+13
-12
http.go
vendor/github.com/33cn/chain33/rpc/http.go
+7
-7
jrpchandler.go
vendor/github.com/33cn/chain33/rpc/jrpchandler.go
+1
-1
jsonclient.go
vendor/github.com/33cn/chain33/rpc/jsonclient/jsonclient.go
+2
-2
rpc_ctx.go
vendor/github.com/33cn/chain33/rpc/jsonclient/rpc_ctx.go
+9
-9
server.go
vendor/github.com/33cn/chain33/rpc/server.go
+12
-12
server_test.go
vendor/github.com/33cn/chain33/rpc/server_test.go
+7
-7
code.go
vendor/github.com/33cn/chain33/rpc/types/code.go
+2
-2
coins.go
...thub.com/33cn/chain33/system/dapp/coins/autotest/coins.go
+5
-5
transferCase.go
...m/33cn/chain33/system/dapp/coins/autotest/transferCase.go
+10
-10
withdrawCase.go
...m/33cn/chain33/system/dapp/coins/autotest/withdrawCase.go
+10
-10
coins.go
...thub.com/33cn/chain33/system/dapp/coins/executor/coins.go
+14
-1
exec_del_local.go
...33cn/chain33/system/dapp/coins/executor/exec_del_local.go
+0
-9
exec_local.go
...com/33cn/chain33/system/dapp/coins/executor/exec_local.go
+0
-12
account.go
...r/github.com/33cn/chain33/system/dapp/commands/account.go
+22
-22
block.go
vendor/github.com/33cn/chain33/system/dapp/commands/block.go
+13
-13
bty.go
vendor/github.com/33cn/chain33/system/dapp/commands/bty.go
+15
-15
mempool.go
...r/github.com/33cn/chain33/system/dapp/commands/mempool.go
+7
-7
net.go
vendor/github.com/33cn/chain33/system/dapp/commands/net.go
+6
-6
seed.go
vendor/github.com/33cn/chain33/system/dapp/commands/seed.go
+3
-3
stat.go
vendor/github.com/33cn/chain33/system/dapp/commands/stat.go
+16
-16
tx.go
vendor/github.com/33cn/chain33/system/dapp/commands/tx.go
+13
-13
types.go
...thub.com/33cn/chain33/system/dapp/commands/types/types.go
+2
-2
utils.go
...thub.com/33cn/chain33/system/dapp/commands/types/utils.go
+1
-1
version.go
...r/github.com/33cn/chain33/system/dapp/commands/version.go
+1
-1
wallet.go
...or/github.com/33cn/chain33/system/dapp/commands/wallet.go
+15
-15
driver.go
vendor/github.com/33cn/chain33/system/dapp/driver.go
+18
-5
config.go
...ub.com/33cn/chain33/system/dapp/manage/commands/config.go
+1
-1
exec_del_local.go
...3cn/chain33/system/dapp/manage/executor/exec_del_local.go
+0
-3
exec_local.go
...om/33cn/chain33/system/dapp/manage/executor/exec_local.go
+0
-4
manage.go
...ub.com/33cn/chain33/system/dapp/manage/executor/manage.go
+5
-0
prune.go
vendor/github.com/33cn/chain33/system/store/mavl/db/prune.go
+229
-32
mavl_test.go
...or/github.com/33cn/chain33/system/store/mavl/mavl_test.go
+4
-0
config.go
vendor/github.com/33cn/chain33/types/config.go
+1
-1
types.go
vendor/github.com/33cn/chain33/types/types.go
+1
-1
cli.go
vendor/github.com/33cn/chain33/util/cli/cli.go
+1
-1
exec.go
vendor/github.com/33cn/chain33/util/exec.go
+2
-0
util_test.go
vendor/github.com/33cn/chain33/util/util_test.go
+2
-2
wallet_proc.go
vendor/github.com/33cn/chain33/wallet/wallet_proc.go
+7
-7
No files found.
vendor/github.com/33cn/chain33/LICENSE
View file @
e8a09f64
BSD
2
-Clause License
BSD
3
-Clause License
Copyright (c) 2018, 33.cn
Copyright (c) 2018, 33.cn
All rights reserved.
All rights reserved.
...
@@ -13,6 +13,10 @@ modification, are permitted provided that the following conditions are met:
...
@@ -13,6 +13,10 @@ modification, are permitted provided that the following conditions are met:
this list of conditions and the following disclaimer in the documentation
this list of conditions and the following disclaimer in the documentation
and/or other materials provided with the distribution.
and/or other materials provided with the distribution.
* Neither the name of the copyright holder nor the names of its
contributors may be used to endorse or promote products derived from
this software without specific prior written permission.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
...
...
vendor/github.com/33cn/chain33/Makefile
View file @
e8a09f64
...
@@ -16,6 +16,7 @@ SRC_AUTOTEST := github.com/33cn/chain33/cmd/autotest
...
@@ -16,6 +16,7 @@ SRC_AUTOTEST := github.com/33cn/chain33/cmd/autotest
LDFLAGS
:=
-ldflags
"-w -s"
LDFLAGS
:=
-ldflags
"-w -s"
PKG_LIST
:=
`
go list ./... |
grep
-v
"vendor"
|
grep
-v
"mocks"
`
PKG_LIST
:=
`
go list ./... |
grep
-v
"vendor"
|
grep
-v
"mocks"
`
PKG_LIST_VET
:=
`
go list ./... |
grep
-v
"vendor"
|
grep
-v
"common/crypto/sha3"
|
grep
-v
"common/log/log15"
`
PKG_LIST_VET
:=
`
go list ./... |
grep
-v
"vendor"
|
grep
-v
"common/crypto/sha3"
|
grep
-v
"common/log/log15"
`
PKG_LIST_INEFFASSIGN
=
`
go list
-f
{{
.Dir
}}
./... |
grep
-v
"vendor"
|
grep
-v
"common/crypto/sha3"
|
grep
-v
"common/log/log15"
|
grep
-v
"common/ed25519"
`
PKG_LIST_Q
:=
`
go list ./... |
grep
-v
"vendor"
|
grep
-v
"mocks"
`
PKG_LIST_Q
:=
`
go list ./... |
grep
-v
"vendor"
|
grep
-v
"mocks"
`
BUILD_FLAGS
=
-ldflags
"-X github.com/33cn/chain33/common/version.GitCommit=
`
git rev-parse
--short
=
8 HEAD
`
"
BUILD_FLAGS
=
-ldflags
"-X github.com/33cn/chain33/common/version.GitCommit=
`
git rev-parse
--short
=
8 HEAD
`
"
MKPATH
=
$
(
abspath
$
(
lastword
$(MAKEFILE_LIST)
))
MKPATH
=
$
(
abspath
$
(
lastword
$(MAKEFILE_LIST)
))
...
@@ -87,7 +88,7 @@ build_ci: depends ## Build the binary file for CI
...
@@ -87,7 +88,7 @@ build_ci: depends ## Build the binary file for CI
@
go build
$(BUILD_FLAGS)
-v
-o
$(APP)
$(SRC)
@
go build
$(BUILD_FLAGS)
-v
-o
$(APP)
$(SRC)
@
cp
cmd/chain33/chain33.toml build/
@
cp
cmd/chain33/chain33.toml build/
linter
:
##
Use gometalinter check code
,
ignore some unserious warning
linter
:
vet ineffassign
##
Use gometalinter check code
,
ignore some unserious warning
@
./golinter.sh
"filter"
@
./golinter.sh
"filter"
@
find
.
-name
'*.sh'
-not
-path
"./vendor/*"
| xargs shellcheck
@
find
.
-name
'*.sh'
-not
-path
"./vendor/*"
| xargs shellcheck
...
@@ -101,6 +102,9 @@ race: ## Run data race detector
...
@@ -101,6 +102,9 @@ race: ## Run data race detector
vet
:
vet
:
@
go vet
${
PKG_LIST_VET
}
@
go vet
${
PKG_LIST_VET
}
ineffassign
:
@
ineffassign
-n
${
PKG_LIST_INEFFASSIGN
}
test
:
##
Run unittests
test
:
##
Run unittests
@
go
test
-race
$(PKG_LIST)
@
go
test
-race
$(PKG_LIST)
...
...
vendor/github.com/33cn/chain33/blockchain/chain_test.go
View file @
e8a09f64
...
@@ -640,7 +640,7 @@ func testGetSeqByHash(t *testing.T, blockchain *blockchain.BlockChain) {
...
@@ -640,7 +640,7 @@ func testGetSeqByHash(t *testing.T, blockchain *blockchain.BlockChain) {
}
}
}
}
seq
,
err
:=
blockchain
.
ProcGetSeqByHash
(
hashes
[
0
])
seq
,
_
:=
blockchain
.
ProcGetSeqByHash
(
hashes
[
0
])
if
seq
!=
-
1
{
if
seq
!=
-
1
{
t
.
Error
(
"testGetSeqByHash only para chain GetSeqByHash "
)
t
.
Error
(
"testGetSeqByHash only para chain GetSeqByHash "
)
}
}
...
...
vendor/github.com/33cn/chain33/cmd/miner_accounts/accounts/show.go
View file @
e8a09f64
...
@@ -102,7 +102,6 @@ func (show *ShowMinerAccount) Get(in *TimeAt, out *interface{}) error {
...
@@ -102,7 +102,6 @@ func (show *ShowMinerAccount) Get(in *TimeAt, out *interface{}) error {
miner
=
calcIncrease
(
miner
,
curAcc
,
lastAcc
,
header
)
miner
=
calcIncrease
(
miner
,
curAcc
,
lastAcc
,
header
)
*
out
=
&
miner
*
out
=
&
miner
seconds
=
seconds
-
statInterval
//}
//}
return
nil
return
nil
...
...
vendor/github.com/33cn/chain33/cmd/write/write.go
View file @
e8a09f64
...
@@ -195,12 +195,12 @@ func scanWrite() {
...
@@ -195,12 +195,12 @@ func scanWrite() {
Expire
:
"0"
,
Expire
:
"0"
,
}
}
var
signed
string
var
signed
string
err
=
rpc
.
Call
(
"Chain33.SignRawTx"
,
paramsReqSignRawTx
,
&
signed
)
rpc
.
Call
(
"Chain33.SignRawTx"
,
paramsReqSignRawTx
,
&
signed
)
paramsRaw
:=
rpctypes
.
RawParm
{
paramsRaw
:=
rpctypes
.
RawParm
{
Data
:
signed
,
Data
:
signed
,
}
}
var
sent
string
var
sent
string
err
=
rpc
.
Call
(
"Chain33.SendTransaction"
,
paramsRaw
,
&
sent
)
rpc
.
Call
(
"Chain33.SendTransaction"
,
paramsRaw
,
&
sent
)
f
,
_
:=
os
.
OpenFile
(
heightFile
,
os
.
O_RDWR
,
0666
)
f
,
_
:=
os
.
OpenFile
(
heightFile
,
os
.
O_RDWR
,
0666
)
height
:=
strconv
.
FormatInt
(
currentHeight
,
10
)
height
:=
strconv
.
FormatInt
(
currentHeight
,
10
)
index
:=
strconv
.
FormatInt
(
currentIndex
,
10
)
index
:=
strconv
.
FormatInt
(
currentIndex
,
10
)
...
...
vendor/github.com/33cn/chain33/common/db/go_pegasus.go
View file @
e8a09f64
...
@@ -372,8 +372,7 @@ func (dbit *PegasusIt) findInPage(key []byte) int {
...
@@ -372,8 +372,7 @@ func (dbit *PegasusIt) findInPage(key []byte) int {
//Seek 查找
//Seek 查找
func
(
dbit
*
PegasusIt
)
Seek
(
key
[]
byte
)
bool
{
func
(
dbit
*
PegasusIt
)
Seek
(
key
[]
byte
)
bool
{
pos
:=
-
1
pos
:=
dbit
.
findInPage
(
key
)
pos
=
dbit
.
findInPage
(
key
)
// 如果第一页已经找到,不会走入此逻辑
// 如果第一页已经找到,不会走入此逻辑
for
pos
==
-
1
&&
dbit
.
nextPage
{
for
pos
==
-
1
&&
dbit
.
nextPage
{
...
...
vendor/github.com/33cn/chain33/common/db/go_ssdb.go
View file @
e8a09f64
...
@@ -378,8 +378,7 @@ func (dbit *ssDBIt) findInPage(key string) int {
...
@@ -378,8 +378,7 @@ func (dbit *ssDBIt) findInPage(key string) int {
func
(
dbit
*
ssDBIt
)
Seek
(
key
[]
byte
)
bool
{
func
(
dbit
*
ssDBIt
)
Seek
(
key
[]
byte
)
bool
{
keyStr
:=
string
(
key
)
keyStr
:=
string
(
key
)
pos
:=
-
1
pos
:=
dbit
.
findInPage
(
keyStr
)
pos
=
dbit
.
findInPage
(
keyStr
)
// 如果第一页已经找到,不会走入此逻辑
// 如果第一页已经找到,不会走入此逻辑
for
pos
==
-
1
&&
dbit
.
nextPage
{
for
pos
==
-
1
&&
dbit
.
nextPage
{
...
...
vendor/github.com/33cn/chain33/common/db/go_ssdb_util.go
View file @
e8a09f64
...
@@ -336,7 +336,6 @@ func (c *SDBClient) send(args []interface{}) error {
...
@@ -336,7 +336,6 @@ func (c *SDBClient) send(args []interface{}) error {
return
nil
return
nil
}
}
func
(
c
*
SDBClient
)
recv
()
(
resp
[]
string
,
err
error
)
{
func
(
c
*
SDBClient
)
recv
()
(
resp
[]
string
,
err
error
)
{
bufSize
:=
0
packetBuf
:=
[]
byte
{}
packetBuf
:=
[]
byte
{}
//设置读取数据超时,
//设置读取数据超时,
if
err
=
c
.
sock
.
SetReadDeadline
(
time
.
Now
()
.
Add
(
time
.
Second
*
ReadTimeOut
));
err
!=
nil
{
if
err
=
c
.
sock
.
SetReadDeadline
(
time
.
Now
()
.
Add
(
time
.
Second
*
ReadTimeOut
));
err
!=
nil
{
...
@@ -345,7 +344,7 @@ func (c *SDBClient) recv() (resp []string, err error) {
...
@@ -345,7 +344,7 @@ func (c *SDBClient) recv() (resp []string, err error) {
//数据包分解,发现长度,找到结尾,循环发现,发现空行,结束
//数据包分解,发现长度,找到结尾,循环发现,发现空行,结束
readBuf
:=
make
([]
byte
,
ReadBufSize
)
readBuf
:=
make
([]
byte
,
ReadBufSize
)
for
{
for
{
bufSize
,
err
=
c
.
sock
.
Read
(
readBuf
)
bufSize
,
err
:
=
c
.
sock
.
Read
(
readBuf
)
if
err
!=
nil
{
if
err
!=
nil
{
return
nil
,
newErrorf
(
err
,
"client socket read error"
)
return
nil
,
newErrorf
(
err
,
"client socket read error"
)
}
}
...
@@ -359,7 +358,7 @@ func (c *SDBClient) recv() (resp []string, err error) {
...
@@ -359,7 +358,7 @@ func (c *SDBClient) recv() (resp []string, err error) {
if
n
==
-
1
{
if
n
==
-
1
{
break
break
}
else
if
n
==
-
2
{
}
else
if
n
==
-
2
{
return
return
nil
,
newErrorf
(
err
,
"parse error"
)
}
else
{
}
else
{
resp
=
append
(
resp
,
rsp
)
resp
=
append
(
resp
,
rsp
)
packetBuf
=
packetBuf
[
n
+
1
:
]
packetBuf
=
packetBuf
[
n
+
1
:
]
...
@@ -370,7 +369,6 @@ func (c *SDBClient) recv() (resp []string, err error) {
...
@@ -370,7 +369,6 @@ func (c *SDBClient) recv() (resp []string, err error) {
func
(
c
*
SDBClient
)
parse
(
buf
[]
byte
)
(
resp
string
,
size
int
)
{
func
(
c
*
SDBClient
)
parse
(
buf
[]
byte
)
(
resp
string
,
size
int
)
{
n
:=
bytes
.
IndexByte
(
buf
,
ENDN
)
n
:=
bytes
.
IndexByte
(
buf
,
ENDN
)
blockSize
:=
-
1
size
=
-
1
size
=
-
1
if
n
!=
-
1
{
if
n
!=
-
1
{
if
n
==
0
||
n
==
1
&&
buf
[
0
]
==
ENDR
{
//空行,说明一个数据包结束
if
n
==
0
||
n
==
1
&&
buf
[
0
]
==
ENDR
{
//空行,说明一个数据包结束
...
@@ -378,7 +376,7 @@ func (c *SDBClient) parse(buf []byte) (resp string, size int) {
...
@@ -378,7 +376,7 @@ func (c *SDBClient) parse(buf []byte) (resp string, size int) {
return
return
}
}
//数据包开始,包长度解析
//数据包开始,包长度解析
blockSize
=
ToNum
(
buf
[
:
n
])
blockSize
:
=
ToNum
(
buf
[
:
n
])
bufSize
:=
len
(
buf
)
bufSize
:=
len
(
buf
)
if
n
+
blockSize
<
bufSize
{
if
n
+
blockSize
<
bufSize
{
...
...
vendor/github.com/33cn/chain33/common/db/mvcc_test.go
View file @
e8a09f64
...
@@ -150,7 +150,7 @@ func TestVersionSetAndGet(t *testing.T) {
...
@@ -150,7 +150,7 @@ func TestVersionSetAndGet(t *testing.T) {
assert
.
Equal
(
t
,
v
,
[]
byte
(
"v03"
))
assert
.
Equal
(
t
,
v
,
[]
byte
(
"v03"
))
m
.
Trash
(
3
)
m
.
Trash
(
3
)
v
,
err
=
m
.
GetV
([]
byte
(
"k0"
),
0
)
_
,
err
=
m
.
GetV
([]
byte
(
"k0"
),
0
)
assert
.
Equal
(
t
,
err
,
types
.
ErrNotFound
)
assert
.
Equal
(
t
,
err
,
types
.
ErrNotFound
)
v
,
err
=
m
.
GetV
([]
byte
(
"k3"
),
4
)
v
,
err
=
m
.
GetV
([]
byte
(
"k3"
),
4
)
...
@@ -192,23 +192,23 @@ func TestAddDelMVCC(t *testing.T) {
...
@@ -192,23 +192,23 @@ func TestAddDelMVCC(t *testing.T) {
m
.
db
.
Set
(
v
.
Key
,
v
.
Value
)
m
.
db
.
Set
(
v
.
Key
,
v
.
Value
)
}
}
kvlist
,
err
=
m
.
AddMVCC
(
genkv
(
2
),
hashN
(
2
),
hashN
(
1
),
1
)
_
,
err
=
m
.
AddMVCC
(
genkv
(
2
),
hashN
(
2
),
hashN
(
1
),
1
)
assert
.
Equal
(
t
,
err
,
types
.
ErrPrevVersion
)
assert
.
Equal
(
t
,
err
,
types
.
ErrPrevVersion
)
kvlist
,
err
=
m
.
AddMVCC
(
genkv
(
2
),
hashN
(
2
),
hashN
(
0
),
3
)
_
,
err
=
m
.
AddMVCC
(
genkv
(
2
),
hashN
(
2
),
hashN
(
0
),
3
)
assert
.
Equal
(
t
,
err
,
types
.
ErrPrevVersion
)
assert
.
Equal
(
t
,
err
,
types
.
ErrPrevVersion
)
kvlist
,
err
=
m
.
AddMVCC
(
genkv
(
2
),
hashN
(
2
),
hashN
(
3
),
3
)
_
,
err
=
m
.
AddMVCC
(
genkv
(
2
),
hashN
(
2
),
hashN
(
3
),
3
)
assert
.
Equal
(
t
,
err
,
types
.
ErrNotFound
)
assert
.
Equal
(
t
,
err
,
types
.
ErrNotFound
)
maxv
,
err
:=
m
.
GetMaxVersion
()
maxv
,
err
:=
m
.
GetMaxVersion
()
assert
.
Nil
(
t
,
err
)
assert
.
Nil
(
t
,
err
)
assert
.
Equal
(
t
,
int64
(
1
),
maxv
)
assert
.
Equal
(
t
,
int64
(
1
),
maxv
)
kvlist
,
err
=
m
.
DelMVCC
(
hashN
(
2
),
1
,
true
)
_
,
err
=
m
.
DelMVCC
(
hashN
(
2
),
1
,
true
)
assert
.
Equal
(
t
,
err
,
types
.
ErrNotFound
)
assert
.
Equal
(
t
,
err
,
types
.
ErrNotFound
)
kvlist
,
err
=
m
.
DelMVCC
(
hashN
(
0
),
0
,
true
)
_
,
err
=
m
.
DelMVCC
(
hashN
(
0
),
0
,
true
)
assert
.
Equal
(
t
,
err
,
types
.
ErrCanOnlyDelTopVersion
)
assert
.
Equal
(
t
,
err
,
types
.
ErrCanOnlyDelTopVersion
)
kvlist
,
err
=
m
.
DelMVCC
(
hashN
(
1
),
1
,
true
)
kvlist
,
err
=
m
.
DelMVCC
(
hashN
(
1
),
1
,
true
)
...
...
vendor/github.com/33cn/chain33/common/ntp.go
View file @
e8a09f64
...
@@ -190,8 +190,6 @@ func abs(t time.Duration) time.Duration {
...
@@ -190,8 +190,6 @@ func abs(t time.Duration) time.Duration {
}
}
func
maxSubList
(
list
[]
time
.
Duration
)
(
sub
[]
time
.
Duration
)
{
func
maxSubList
(
list
[]
time
.
Duration
)
(
sub
[]
time
.
Duration
)
{
start
:=
0
end
:=
0
if
len
(
list
)
==
0
{
if
len
(
list
)
==
0
{
return
list
return
list
}
}
...
@@ -202,6 +200,8 @@ func maxSubList(list []time.Duration) (sub []time.Duration) {
...
@@ -202,6 +200,8 @@ func maxSubList(list []time.Duration) (sub []time.Duration) {
}
else
{
}
else
{
nextheight
=
list
[
i
+
1
]
nextheight
=
list
[
i
+
1
]
}
}
var
start
int
var
end
int
if
abs
(
nextheight
-
list
[
i
])
>
time
.
Millisecond
*
100
{
if
abs
(
nextheight
-
list
[
i
])
>
time
.
Millisecond
*
100
{
end
=
i
+
1
end
=
i
+
1
if
len
(
sub
)
<
(
end
-
start
)
{
if
len
(
sub
)
<
(
end
-
start
)
{
...
...
vendor/github.com/33cn/chain33/common/pubsub/pubsub_test.go
View file @
e8a09f64
...
@@ -98,11 +98,11 @@ func (s *Suite) TestUnsubAll(c *check.C) {
...
@@ -98,11 +98,11 @@ func (s *Suite) TestUnsubAll(c *check.C) {
ps
.
Unsub
(
ch1
)
ps
.
Unsub
(
ch1
)
m
,
ok
:=
<-
ch1
_
,
ok
:=
<-
ch1
c
.
Check
(
ok
,
check
.
Equals
,
false
)
c
.
Check
(
ok
,
check
.
Equals
,
false
)
ps
.
Pub
(
"hi"
,
"t1"
)
ps
.
Pub
(
"hi"
,
"t1"
)
m
,
ok
=
<-
ch2
m
:
=
<-
ch2
c
.
Check
(
m
,
check
.
Equals
,
"hi"
)
c
.
Check
(
m
,
check
.
Equals
,
"hi"
)
ps
.
Shutdown
()
ps
.
Shutdown
()
...
...
vendor/github.com/33cn/chain33/executor/execenv.go
View file @
e8a09f64
...
@@ -136,7 +136,7 @@ func (e *executor) setEnv(exec drivers.Driver) {
...
@@ -136,7 +136,7 @@ func (e *executor) setEnv(exec drivers.Driver) {
exec
.
SetStateDB
(
e
.
stateDB
)
exec
.
SetStateDB
(
e
.
stateDB
)
exec
.
SetLocalDB
(
e
.
localDB
)
exec
.
SetLocalDB
(
e
.
localDB
)
exec
.
SetEnv
(
e
.
height
,
e
.
blocktime
,
e
.
difficulty
)
exec
.
SetEnv
(
e
.
height
,
e
.
blocktime
,
e
.
difficulty
)
exec
.
SetA
pi
(
e
.
api
)
exec
.
SetA
PI
(
e
.
api
)
exec
.
SetTxs
(
e
.
txs
)
exec
.
SetTxs
(
e
.
txs
)
exec
.
SetReceipt
(
e
.
receipts
)
exec
.
SetReceipt
(
e
.
receipts
)
}
}
...
...
vendor/github.com/33cn/chain33/executor/executor_test.go
View file @
e8a09f64
...
@@ -185,4 +185,5 @@ func TestKeyLocalAllow(t *testing.T) {
...
@@ -185,4 +185,5 @@ func TestKeyLocalAllow(t *testing.T) {
err
=
isAllowLocalKey
([]
byte
(
"exec"
),
[]
byte
(
"-exec------aa"
))
err
=
isAllowLocalKey
([]
byte
(
"exec"
),
[]
byte
(
"-exec------aa"
))
assert
.
Equal
(
t
,
err
,
types
.
ErrLocalPrefix
)
assert
.
Equal
(
t
,
err
,
types
.
ErrLocalPrefix
)
err
=
isAllowLocalKey
([]
byte
(
"paracross"
),
[]
byte
(
"LODB-user.p.para.paracross-xxxx"
))
err
=
isAllowLocalKey
([]
byte
(
"paracross"
),
[]
byte
(
"LODB-user.p.para.paracross-xxxx"
))
assert
.
Equal
(
t
,
err
,
types
.
ErrLocalPrefix
)
}
}
vendor/github.com/33cn/chain33/mempool/mempool.go
View file @
e8a09f64
...
@@ -513,7 +513,7 @@ func (mem *Mempool) getSync() {
...
@@ -513,7 +513,7 @@ func (mem *Mempool) getSync() {
panic
(
"client not bind message queue."
)
panic
(
"client not bind message queue."
)
}
}
msg
:=
mem
.
client
.
NewMessage
(
"blockchain"
,
types
.
EventIsSync
,
nil
)
msg
:=
mem
.
client
.
NewMessage
(
"blockchain"
,
types
.
EventIsSync
,
nil
)
err
:=
mem
.
client
.
Send
(
msg
,
true
)
mem
.
client
.
Send
(
msg
,
true
)
resp
,
err
:=
mem
.
client
.
Wait
(
msg
)
resp
,
err
:=
mem
.
client
.
Wait
(
msg
)
if
err
!=
nil
{
if
err
!=
nil
{
time
.
Sleep
(
time
.
Second
)
time
.
Sleep
(
time
.
Second
)
...
...
vendor/github.com/33cn/chain33/mempool/mempool_test.go
View file @
e8a09f64
...
@@ -517,7 +517,7 @@ func TestAddBlockedTx(t *testing.T) {
...
@@ -517,7 +517,7 @@ func TestAddBlockedTx(t *testing.T) {
t
.
Error
(
err
)
t
.
Error
(
err
)
return
return
}
}
msg1
,
err
=
mem
.
client
.
Wait
(
msg1
)
_
,
err
=
mem
.
client
.
Wait
(
msg1
)
if
err
!=
nil
{
if
err
!=
nil
{
t
.
Error
(
err
)
t
.
Error
(
err
)
return
return
...
...
vendor/github.com/33cn/chain33/p2p/addrbook.go
View file @
e8a09f64
...
@@ -34,7 +34,7 @@ func (a *AddrBook) Close() {
...
@@ -34,7 +34,7 @@ func (a *AddrBook) Close() {
type
AddrBook
struct
{
type
AddrBook
struct
{
mtx
sync
.
Mutex
mtx
sync
.
Mutex
ourAddrs
map
[
string
]
*
NetAddress
ourAddrs
map
[
string
]
*
NetAddress
addrPeer
map
[
string
]
*
k
nownAddress
addrPeer
map
[
string
]
*
K
nownAddress
cfg
*
types
.
P2P
cfg
*
types
.
P2P
keymtx
sync
.
Mutex
keymtx
sync
.
Mutex
privkey
string
privkey
string
...
@@ -43,7 +43,8 @@ type AddrBook struct {
...
@@ -43,7 +43,8 @@ type AddrBook struct {
Quit
chan
struct
{}
Quit
chan
struct
{}
}
}
type
knownAddress
struct
{
// KnownAddress defines known address type
type
KnownAddress
struct
{
kmtx
sync
.
Mutex
kmtx
sync
.
Mutex
Addr
*
NetAddress
`json:"addr"`
Addr
*
NetAddress
`json:"addr"`
Attempts
uint
`json:"attempts"`
Attempts
uint
`json:"attempts"`
...
@@ -52,7 +53,7 @@ type knownAddress struct {
...
@@ -52,7 +53,7 @@ type knownAddress struct {
}
}
// GetPeerStat get peer stat
// GetPeerStat get peer stat
func
(
a
*
AddrBook
)
GetPeerStat
(
addr
string
)
*
k
nownAddress
{
func
(
a
*
AddrBook
)
GetPeerStat
(
addr
string
)
*
K
nownAddress
{
a
.
mtx
.
Lock
()
a
.
mtx
.
Lock
()
defer
a
.
mtx
.
Unlock
()
defer
a
.
mtx
.
Unlock
()
if
peer
,
ok
:=
a
.
addrPeer
[
addr
];
ok
{
if
peer
,
ok
:=
a
.
addrPeer
[
addr
];
ok
{
...
@@ -62,7 +63,7 @@ func (a *AddrBook) GetPeerStat(addr string) *knownAddress {
...
@@ -62,7 +63,7 @@ func (a *AddrBook) GetPeerStat(addr string) *knownAddress {
}
}
func
(
a
*
AddrBook
)
setAddrStat
(
addr
string
,
run
bool
)
(
*
k
nownAddress
,
bool
)
{
func
(
a
*
AddrBook
)
setAddrStat
(
addr
string
,
run
bool
)
(
*
K
nownAddress
,
bool
)
{
a
.
mtx
.
Lock
()
a
.
mtx
.
Lock
()
defer
a
.
mtx
.
Unlock
()
defer
a
.
mtx
.
Unlock
()
if
peer
,
ok
:=
a
.
addrPeer
[
addr
];
ok
{
if
peer
,
ok
:=
a
.
addrPeer
[
addr
];
ok
{
...
@@ -82,7 +83,7 @@ func NewAddrBook(cfg *types.P2P) *AddrBook {
...
@@ -82,7 +83,7 @@ func NewAddrBook(cfg *types.P2P) *AddrBook {
a
:=
&
AddrBook
{
a
:=
&
AddrBook
{
ourAddrs
:
make
(
map
[
string
]
*
NetAddress
),
ourAddrs
:
make
(
map
[
string
]
*
NetAddress
),
addrPeer
:
make
(
map
[
string
]
*
k
nownAddress
),
addrPeer
:
make
(
map
[
string
]
*
K
nownAddress
),
cfg
:
cfg
,
cfg
:
cfg
,
Quit
:
make
(
chan
struct
{},
1
),
Quit
:
make
(
chan
struct
{},
1
),
}
}
...
@@ -90,8 +91,8 @@ func NewAddrBook(cfg *types.P2P) *AddrBook {
...
@@ -90,8 +91,8 @@ func NewAddrBook(cfg *types.P2P) *AddrBook {
return
a
return
a
}
}
func
newKnownAddress
(
addr
*
NetAddress
)
*
k
nownAddress
{
func
newKnownAddress
(
addr
*
NetAddress
)
*
K
nownAddress
{
return
&
k
nownAddress
{
return
&
K
nownAddress
{
kmtx
:
sync
.
Mutex
{},
kmtx
:
sync
.
Mutex
{},
Addr
:
addr
,
Addr
:
addr
,
Attempts
:
0
,
Attempts
:
0
,
...
@@ -99,7 +100,7 @@ func newKnownAddress(addr *NetAddress) *knownAddress {
...
@@ -99,7 +100,7 @@ func newKnownAddress(addr *NetAddress) *knownAddress {
}
}
}
}
func
(
ka
*
k
nownAddress
)
markGood
()
{
func
(
ka
*
K
nownAddress
)
markGood
()
{
ka
.
kmtx
.
Lock
()
ka
.
kmtx
.
Lock
()
defer
ka
.
kmtx
.
Unlock
()
defer
ka
.
kmtx
.
Unlock
()
now
:=
types
.
Now
()
now
:=
types
.
Now
()
...
@@ -109,10 +110,10 @@ func (ka *knownAddress) markGood() {
...
@@ -109,10 +110,10 @@ func (ka *knownAddress) markGood() {
}
}
// Copy a KnownAddress
// Copy a KnownAddress
func
(
ka
*
knownAddress
)
Copy
()
*
k
nownAddress
{
func
(
ka
*
KnownAddress
)
Copy
()
*
K
nownAddress
{
ka
.
kmtx
.
Lock
()
ka
.
kmtx
.
Lock
()
ret
:=
k
nownAddress
{
ret
:=
K
nownAddress
{
Addr
:
ka
.
Addr
.
Copy
(),
Addr
:
ka
.
Addr
.
Copy
(),
Attempts
:
ka
.
Attempts
,
Attempts
:
ka
.
Attempts
,
LastAttempt
:
ka
.
LastAttempt
,
LastAttempt
:
ka
.
LastAttempt
,
...
@@ -122,7 +123,7 @@ func (ka *knownAddress) Copy() *knownAddress {
...
@@ -122,7 +123,7 @@ func (ka *knownAddress) Copy() *knownAddress {
return
&
ret
return
&
ret
}
}
func
(
ka
*
k
nownAddress
)
markAttempt
()
{
func
(
ka
*
K
nownAddress
)
markAttempt
()
{
ka
.
kmtx
.
Lock
()
ka
.
kmtx
.
Lock
()
defer
ka
.
kmtx
.
Unlock
()
defer
ka
.
kmtx
.
Unlock
()
...
@@ -133,7 +134,7 @@ func (ka *knownAddress) markAttempt() {
...
@@ -133,7 +134,7 @@ func (ka *knownAddress) markAttempt() {
}
}
// GetAttempts return attempts
// GetAttempts return attempts
func
(
ka
*
k
nownAddress
)
GetAttempts
()
uint
{
func
(
ka
*
K
nownAddress
)
GetAttempts
()
uint
{
ka
.
kmtx
.
Lock
()
ka
.
kmtx
.
Lock
()
defer
ka
.
kmtx
.
Unlock
()
defer
ka
.
kmtx
.
Unlock
()
return
ka
.
Attempts
return
ka
.
Attempts
...
@@ -176,13 +177,13 @@ func (a *AddrBook) Size() int {
...
@@ -176,13 +177,13 @@ func (a *AddrBook) Size() int {
}
}
type
addrBookJSON
struct
{
type
addrBookJSON
struct
{
Addrs
[]
*
k
nownAddress
`json:"addrs"`
Addrs
[]
*
K
nownAddress
`json:"addrs"`
}
}
func
(
a
*
AddrBook
)
saveToDb
()
{
func
(
a
*
AddrBook
)
saveToDb
()
{
a
.
mtx
.
Lock
()
a
.
mtx
.
Lock
()
defer
a
.
mtx
.
Unlock
()
defer
a
.
mtx
.
Unlock
()
addrs
:=
[]
*
k
nownAddress
{}
addrs
:=
[]
*
K
nownAddress
{}
seeds
:=
a
.
cfg
.
Seeds
seeds
:=
a
.
cfg
.
Seeds
seedsMap
:=
make
(
map
[
string
]
int
)
seedsMap
:=
make
(
map
[
string
]
int
)
...
@@ -294,7 +295,7 @@ out:
...
@@ -294,7 +295,7 @@ out:
// AddAddress add a address for ours
// AddAddress add a address for ours
// NOTE: addr must not be nil
// NOTE: addr must not be nil
func
(
a
*
AddrBook
)
AddAddress
(
addr
*
NetAddress
,
ka
*
k
nownAddress
)
{
func
(
a
*
AddrBook
)
AddAddress
(
addr
*
NetAddress
,
ka
*
K
nownAddress
)
{
a
.
mtx
.
Lock
()
a
.
mtx
.
Lock
()
defer
a
.
mtx
.
Unlock
()
defer
a
.
mtx
.
Unlock
()
...
...
vendor/github.com/33cn/chain33/p2p/downloadblocks.go
View file @
e8a09f64
...
@@ -16,7 +16,8 @@ import (
...
@@ -16,7 +16,8 @@ import (
"google.golang.org/grpc"
"google.golang.org/grpc"
)
)
type
downloadJob
struct
{
// DownloadJob defines download job type
type
DownloadJob
struct
{
wg
sync
.
WaitGroup
wg
sync
.
WaitGroup
retryList
*
list
.
List
retryList
*
list
.
List
p2pcli
*
Cli
p2pcli
*
Cli
...
@@ -32,8 +33,8 @@ type peerJob struct {
...
@@ -32,8 +33,8 @@ type peerJob struct {
}
}
// NewDownloadJob create a downloadjob object
// NewDownloadJob create a downloadjob object
func
NewDownloadJob
(
p2pcli
*
Cli
,
peers
[]
*
Peer
)
*
d
ownloadJob
{
func
NewDownloadJob
(
p2pcli
*
Cli
,
peers
[]
*
Peer
)
*
D
ownloadJob
{
job
:=
new
(
d
ownloadJob
)
job
:=
new
(
D
ownloadJob
)
job
.
retryList
=
list
.
New
()
job
.
retryList
=
list
.
New
()
job
.
p2pcli
=
p2pcli
job
.
p2pcli
=
p2pcli
job
.
busyPeer
=
make
(
map
[
string
]
*
peerJob
)
job
.
busyPeer
=
make
(
map
[
string
]
*
peerJob
)
...
@@ -41,7 +42,7 @@ func NewDownloadJob(p2pcli *Cli, peers []*Peer) *downloadJob {
...
@@ -41,7 +42,7 @@ func NewDownloadJob(p2pcli *Cli, peers []*Peer) *downloadJob {
return
job
return
job
}
}
func
(
d
*
d
ownloadJob
)
isBusyPeer
(
pid
string
)
bool
{
func
(
d
*
D
ownloadJob
)
isBusyPeer
(
pid
string
)
bool
{
d
.
mtx
.
Lock
()
d
.
mtx
.
Lock
()
defer
d
.
mtx
.
Unlock
()
defer
d
.
mtx
.
Unlock
()
if
pjob
,
ok
:=
d
.
busyPeer
[
pid
];
ok
{
if
pjob
,
ok
:=
d
.
busyPeer
[
pid
];
ok
{
...
@@ -50,7 +51,7 @@ func (d *downloadJob) isBusyPeer(pid string) bool {
...
@@ -50,7 +51,7 @@ func (d *downloadJob) isBusyPeer(pid string) bool {
return
false
return
false
}
}
func
(
d
*
d
ownloadJob
)
setBusyPeer
(
peer
*
pb
.
Peer
)
{
func
(
d
*
D
ownloadJob
)
setBusyPeer
(
peer
*
pb
.
Peer
)
{
d
.
mtx
.
Lock
()
d
.
mtx
.
Lock
()
defer
d
.
mtx
.
Unlock
()
defer
d
.
mtx
.
Unlock
()
if
pjob
,
ok
:=
d
.
busyPeer
[
peer
.
GetName
()];
ok
{
if
pjob
,
ok
:=
d
.
busyPeer
[
peer
.
GetName
()];
ok
{
...
@@ -62,7 +63,7 @@ func (d *downloadJob) setBusyPeer(peer *pb.Peer) {
...
@@ -62,7 +63,7 @@ func (d *downloadJob) setBusyPeer(peer *pb.Peer) {
d
.
busyPeer
[
peer
.
GetName
()]
=
&
peerJob
{
peer
,
1
}
d
.
busyPeer
[
peer
.
GetName
()]
=
&
peerJob
{
peer
,
1
}
}
}
func
(
d
*
d
ownloadJob
)
setFreePeer
(
pid
string
)
{
func
(
d
*
D
ownloadJob
)
setFreePeer
(
pid
string
)
{
d
.
mtx
.
Lock
()
d
.
mtx
.
Lock
()
defer
d
.
mtx
.
Unlock
()
defer
d
.
mtx
.
Unlock
()
...
@@ -76,7 +77,7 @@ func (d *downloadJob) setFreePeer(pid string) {
...
@@ -76,7 +77,7 @@ func (d *downloadJob) setFreePeer(pid string) {
}
}
// GetFreePeer get free peer ,return peer
// GetFreePeer get free peer ,return peer
func
(
d
*
d
ownloadJob
)
GetFreePeer
(
joblimit
int64
)
*
Peer
{
func
(
d
*
D
ownloadJob
)
GetFreePeer
(
joblimit
int64
)
*
Peer
{
_
,
infos
:=
d
.
p2pcli
.
network
.
node
.
GetActivePeers
()
_
,
infos
:=
d
.
p2pcli
.
network
.
node
.
GetActivePeers
()
for
_
,
peer
:=
range
d
.
downloadPeers
{
for
_
,
peer
:=
range
d
.
downloadPeers
{
pbpeer
,
ok
:=
infos
[
peer
.
Addr
()]
pbpeer
,
ok
:=
infos
[
peer
.
Addr
()]
...
@@ -99,16 +100,16 @@ func (d *downloadJob) GetFreePeer(joblimit int64) *Peer {
...
@@ -99,16 +100,16 @@ func (d *downloadJob) GetFreePeer(joblimit int64) *Peer {
}
}
// CancelJob cancel the downloadjob object
// CancelJob cancel the downloadjob object
func
(
d
*
d
ownloadJob
)
CancelJob
()
{
func
(
d
*
D
ownloadJob
)
CancelJob
()
{
atomic
.
StoreInt32
(
&
d
.
canceljob
,
1
)
atomic
.
StoreInt32
(
&
d
.
canceljob
,
1
)
}
}
func
(
d
*
d
ownloadJob
)
isCancel
()
bool
{
func
(
d
*
D
ownloadJob
)
isCancel
()
bool
{
return
atomic
.
LoadInt32
(
&
d
.
canceljob
)
==
1
return
atomic
.
LoadInt32
(
&
d
.
canceljob
)
==
1
}
}
// DownloadBlock download the block
// DownloadBlock download the block
func
(
d
*
d
ownloadJob
)
DownloadBlock
(
invs
[]
*
pb
.
Inventory
,
func
(
d
*
D
ownloadJob
)
DownloadBlock
(
invs
[]
*
pb
.
Inventory
,
bchan
chan
*
pb
.
BlockPid
)
[]
*
pb
.
Inventory
{
bchan
chan
*
pb
.
BlockPid
)
[]
*
pb
.
Inventory
{
var
errinvs
[]
*
pb
.
Inventory
var
errinvs
[]
*
pb
.
Inventory
if
d
.
isCancel
()
{
if
d
.
isCancel
()
{
...
@@ -140,7 +141,7 @@ func (d *downloadJob) DownloadBlock(invs []*pb.Inventory,
...
@@ -140,7 +141,7 @@ func (d *downloadJob) DownloadBlock(invs []*pb.Inventory,
return
d
.
restOfInvs
(
bchan
)
return
d
.
restOfInvs
(
bchan
)
}
}
func
(
d
*
d
ownloadJob
)
restOfInvs
(
bchan
chan
*
pb
.
BlockPid
)
[]
*
pb
.
Inventory
{
func
(
d
*
D
ownloadJob
)
restOfInvs
(
bchan
chan
*
pb
.
BlockPid
)
[]
*
pb
.
Inventory
{
var
errinvs
[]
*
pb
.
Inventory
var
errinvs
[]
*
pb
.
Inventory
if
d
.
isCancel
()
{
if
d
.
isCancel
()
{
return
errinvs
return
errinvs
...
@@ -166,7 +167,7 @@ func (d *downloadJob) restOfInvs(bchan chan *pb.BlockPid) []*pb.Inventory {
...
@@ -166,7 +167,7 @@ func (d *downloadJob) restOfInvs(bchan chan *pb.BlockPid) []*pb.Inventory {
return
invs
return
invs
}
}
func
(
d
*
d
ownloadJob
)
syncDownloadBlock
(
peer
*
Peer
,
inv
*
pb
.
Inventory
,
bchan
chan
*
pb
.
BlockPid
)
error
{
func
(
d
*
D
ownloadJob
)
syncDownloadBlock
(
peer
*
Peer
,
inv
*
pb
.
Inventory
,
bchan
chan
*
pb
.
BlockPid
)
error
{
//每次下载一个高度的数据,通过bchan返回上层
//每次下载一个高度的数据,通过bchan返回上层
if
peer
==
nil
{
if
peer
==
nil
{
return
fmt
.
Errorf
(
"peer is not exist"
)
return
fmt
.
Errorf
(
"peer is not exist"
)
...
...
vendor/github.com/33cn/chain33/rpc/http.go
View file @
e8a09f64
...
@@ -64,7 +64,7 @@ func (j *JSONRPCServer) Listen() (int, error) {
...
@@ -64,7 +64,7 @@ func (j *JSONRPCServer) Listen() (int, error) {
return
return
}
}
if
!
checkI
p
Whitelist
(
ip
)
{
if
!
checkI
P
Whitelist
(
ip
)
{
writeError
(
w
,
r
,
0
,
fmt
.
Sprintf
(
`The %s Address is not authorized!`
,
ip
))
writeError
(
w
,
r
,
0
,
fmt
.
Sprintf
(
`The %s Address is not authorized!`
,
ip
))
return
return
}
}
...
@@ -75,7 +75,7 @@ func (j *JSONRPCServer) Listen() (int, error) {
...
@@ -75,7 +75,7 @@ func (j *JSONRPCServer) Listen() (int, error) {
return
return
}
}
//格式做一个检查
//格式做一个检查
client
,
err
:=
parseJ
son
RpcParams
(
data
)
client
,
err
:=
parseJ
SON
RpcParams
(
data
)
errstr
:=
"nil"
errstr
:=
"nil"
if
err
!=
nil
{
if
err
!=
nil
{
errstr
=
err
.
Error
()
errstr
=
err
.
Error
()
...
@@ -90,7 +90,7 @@ func (j *JSONRPCServer) Listen() (int, error) {
...
@@ -90,7 +90,7 @@ func (j *JSONRPCServer) Listen() (int, error) {
if
!
ipaddr
.
IsLoopback
()
{
if
!
ipaddr
.
IsLoopback
()
{
funcName
:=
strings
.
Split
(
client
.
Method
,
"."
)[
len
(
strings
.
Split
(
client
.
Method
,
"."
))
-
1
]
funcName
:=
strings
.
Split
(
client
.
Method
,
"."
)[
len
(
strings
.
Split
(
client
.
Method
,
"."
))
-
1
]
if
checkJrpcFuncBlacklist
(
funcName
)
||
!
checkJrpcFuncWhitelist
(
funcName
)
{
if
checkJrpcFuncBlacklist
(
funcName
)
||
!
checkJrpcFuncWhitelist
(
funcName
)
{
writeError
(
w
,
r
,
client
.
I
d
,
fmt
.
Sprintf
(
`The %s method is not authorized!`
,
funcName
))
writeError
(
w
,
r
,
client
.
I
D
,
fmt
.
Sprintf
(
`The %s method is not authorized!`
,
funcName
))
return
return
}
}
}
}
...
@@ -114,7 +114,7 @@ func (j *JSONRPCServer) Listen() (int, error) {
...
@@ -114,7 +114,7 @@ func (j *JSONRPCServer) Listen() (int, error) {
}
}
type
serverResponse
struct
{
type
serverResponse
struct
{
I
d
uint64
`json:"id"`
I
D
uint64
`json:"id"`
Result
interface
{}
`json:"result"`
Result
interface
{}
`json:"result"`
Error
interface
{}
`json:"error"`
Error
interface
{}
`json:"error"`
}
}
...
@@ -161,7 +161,7 @@ func auth(ctx context.Context, info *grpc.UnaryServerInfo) error {
...
@@ -161,7 +161,7 @@ func auth(ctx context.Context, info *grpc.UnaryServerInfo) error {
return
fmt
.
Errorf
(
"the %s Address is not authorized"
,
ip
)
return
fmt
.
Errorf
(
"the %s Address is not authorized"
,
ip
)
}
}
if
!
checkI
p
Whitelist
(
ip
)
{
if
!
checkI
P
Whitelist
(
ip
)
{
return
fmt
.
Errorf
(
"the %s Address is not authorized"
,
ip
)
return
fmt
.
Errorf
(
"the %s Address is not authorized"
,
ip
)
}
}
...
@@ -177,10 +177,10 @@ func auth(ctx context.Context, info *grpc.UnaryServerInfo) error {
...
@@ -177,10 +177,10 @@ func auth(ctx context.Context, info *grpc.UnaryServerInfo) error {
type
clientRequest
struct
{
type
clientRequest
struct
{
Method
string
`json:"method"`
Method
string
`json:"method"`
Params
[
1
]
interface
{}
`json:"params"`
Params
[
1
]
interface
{}
`json:"params"`
I
d
uint64
`json:"id"`
I
D
uint64
`json:"id"`
}
}
func
parseJ
son
RpcParams
(
data
[]
byte
)
(
*
clientRequest
,
error
)
{
func
parseJ
SON
RpcParams
(
data
[]
byte
)
(
*
clientRequest
,
error
)
{
var
req
clientRequest
var
req
clientRequest
err
:=
json
.
Unmarshal
(
data
,
&
req
)
err
:=
json
.
Unmarshal
(
data
,
&
req
)
if
err
!=
nil
{
if
err
!=
nil
{
...
...
vendor/github.com/33cn/chain33/rpc/jrpchandler.go
View file @
e8a09f64
...
@@ -422,7 +422,7 @@ func (c *Chain33) WalletTxList(in rpctypes.ReqWalletTransactionList, result *int
...
@@ -422,7 +422,7 @@ func (c *Chain33) WalletTxList(in rpctypes.ReqWalletTransactionList, result *int
}
}
{
{
var
txdetails
rpctypes
.
WalletTxDetails
var
txdetails
rpctypes
.
WalletTxDetails
rpctypes
.
ConvertWalletTxDetailToJ
son
(
reply
,
&
txdetails
)
rpctypes
.
ConvertWalletTxDetailToJ
SON
(
reply
,
&
txdetails
)
*
result
=
&
txdetails
*
result
=
&
txdetails
}
}
return
nil
return
nil
...
...
vendor/github.com/33cn/chain33/rpc/jsonclient/jsonclient.go
View file @
e8a09f64
...
@@ -42,11 +42,11 @@ func New(prefix, url string) (*JSONClient, error) {
...
@@ -42,11 +42,11 @@ func New(prefix, url string) (*JSONClient, error) {
type
clientRequest
struct
{
type
clientRequest
struct
{
Method
string
`json:"method"`
Method
string
`json:"method"`
Params
[
1
]
interface
{}
`json:"params"`
Params
[
1
]
interface
{}
`json:"params"`
I
d
uint64
`json:"id"`
I
D
uint64
`json:"id"`
}
}
type
clientResponse
struct
{
type
clientResponse
struct
{
I
d
uint64
`json:"id"`
I
D
uint64
`json:"id"`
Result
*
json
.
RawMessage
`json:"result"`
Result
*
json
.
RawMessage
`json:"result"`
Error
interface
{}
`json:"error"`
Error
interface
{}
`json:"error"`
}
}
...
...
vendor/github.com/33cn/chain33/rpc/jsonclient/rpc_ctx.go
View file @
e8a09f64
...
@@ -10,9 +10,9 @@ import (
...
@@ -10,9 +10,9 @@ import (
"os"
"os"
)
)
// R
pc
Ctx rpc ctx interface
// R
PC
Ctx rpc ctx interface
// TODO: SetPostRunCb()
// TODO: SetPostRunCb()
type
R
pc
Ctx
struct
{
type
R
PC
Ctx
struct
{
Addr
string
Addr
string
Method
string
Method
string
Params
interface
{}
Params
interface
{}
...
@@ -23,9 +23,9 @@ type RpcCtx struct {
...
@@ -23,9 +23,9 @@ type RpcCtx struct {
// Callback a callback function
// Callback a callback function
type
Callback
func
(
res
interface
{})
(
interface
{},
error
)
type
Callback
func
(
res
interface
{})
(
interface
{},
error
)
// NewR
pc
Ctx produce a object of rpcctx
// NewR
PC
Ctx produce a object of rpcctx
func
NewR
pcCtx
(
laddr
,
method
string
,
params
,
res
interface
{})
*
Rpc
Ctx
{
func
NewR
PCCtx
(
laddr
,
method
string
,
params
,
res
interface
{})
*
RPC
Ctx
{
return
&
R
pc
Ctx
{
return
&
R
PC
Ctx
{
Addr
:
laddr
,
Addr
:
laddr
,
Method
:
method
,
Method
:
method
,
Params
:
params
,
Params
:
params
,
...
@@ -34,12 +34,12 @@ func NewRpcCtx(laddr, method string, params, res interface{}) *RpcCtx {
...
@@ -34,12 +34,12 @@ func NewRpcCtx(laddr, method string, params, res interface{}) *RpcCtx {
}
}
// SetResultCb rpcctx callback
// SetResultCb rpcctx callback
func
(
c
*
R
pc
Ctx
)
SetResultCb
(
cb
Callback
)
{
func
(
c
*
R
PC
Ctx
)
SetResultCb
(
cb
Callback
)
{
c
.
cb
=
cb
c
.
cb
=
cb
}
}
// RunResult format rpc result
// RunResult format rpc result
func
(
c
*
R
pc
Ctx
)
RunResult
()
(
interface
{},
error
)
{
func
(
c
*
R
PC
Ctx
)
RunResult
()
(
interface
{},
error
)
{
rpc
,
err
:=
NewJSONClient
(
c
.
Addr
)
rpc
,
err
:=
NewJSONClient
(
c
.
Addr
)
if
err
!=
nil
{
if
err
!=
nil
{
return
nil
,
err
return
nil
,
err
...
@@ -63,7 +63,7 @@ func (c *RpcCtx) RunResult() (interface{}, error) {
...
@@ -63,7 +63,7 @@ func (c *RpcCtx) RunResult() (interface{}, error) {
}
}
// Run rpcctx to runresult
// Run rpcctx to runresult
func
(
c
*
R
pc
Ctx
)
Run
()
{
func
(
c
*
R
PC
Ctx
)
Run
()
{
result
,
err
:=
c
.
RunResult
()
result
,
err
:=
c
.
RunResult
()
if
err
!=
nil
{
if
err
!=
nil
{
fmt
.
Fprintln
(
os
.
Stderr
,
err
)
fmt
.
Fprintln
(
os
.
Stderr
,
err
)
...
@@ -78,7 +78,7 @@ func (c *RpcCtx) Run() {
...
@@ -78,7 +78,7 @@ func (c *RpcCtx) Run() {
}
}
// RunWithoutMarshal return source result of string
// RunWithoutMarshal return source result of string
func
(
c
*
R
pc
Ctx
)
RunWithoutMarshal
()
{
func
(
c
*
R
PC
Ctx
)
RunWithoutMarshal
()
{
var
res
string
var
res
string
rpc
,
err
:=
NewJSONClient
(
c
.
Addr
)
rpc
,
err
:=
NewJSONClient
(
c
.
Addr
)
if
err
!=
nil
{
if
err
!=
nil
{
...
...
vendor/github.com/33cn/chain33/rpc/server.go
View file @
e8a09f64
...
@@ -20,7 +20,7 @@ import (
...
@@ -20,7 +20,7 @@ import (
)
)
var
(
var
(
remoteI
p
Whitelist
=
make
(
map
[
string
]
bool
)
remoteI
P
Whitelist
=
make
(
map
[
string
]
bool
)
rpcCfg
*
types
.
RPC
rpcCfg
*
types
.
RPC
jrpcFuncWhitelist
=
make
(
map
[
string
]
bool
)
jrpcFuncWhitelist
=
make
(
map
[
string
]
bool
)
grpcFuncWhitelist
=
make
(
map
[
string
]
bool
)
grpcFuncWhitelist
=
make
(
map
[
string
]
bool
)
...
@@ -67,7 +67,7 @@ func (s *JSONRPCServer) Close() {
...
@@ -67,7 +67,7 @@ func (s *JSONRPCServer) Close() {
}
}
}
}
func
checkI
p
Whitelist
(
addr
string
)
bool
{
func
checkI
P
Whitelist
(
addr
string
)
bool
{
//回环网络直接允许
//回环网络直接允许
ip
:=
net
.
ParseIP
(
addr
)
ip
:=
net
.
ParseIP
(
addr
)
if
ip
.
IsLoopback
()
{
if
ip
.
IsLoopback
()
{
...
@@ -77,10 +77,10 @@ func checkIpWhitelist(addr string) bool {
...
@@ -77,10 +77,10 @@ func checkIpWhitelist(addr string) bool {
if
ipv4
!=
nil
{
if
ipv4
!=
nil
{
addr
=
ipv4
.
String
()
addr
=
ipv4
.
String
()
}
}
if
_
,
ok
:=
remoteI
p
Whitelist
[
"0.0.0.0"
];
ok
{
if
_
,
ok
:=
remoteI
P
Whitelist
[
"0.0.0.0"
];
ok
{
return
true
return
true
}
}
if
_
,
ok
:=
remoteI
p
Whitelist
[
addr
];
ok
{
if
_
,
ok
:=
remoteI
P
Whitelist
[
addr
];
ok
{
return
true
return
true
}
}
return
false
return
false
...
@@ -177,7 +177,7 @@ type RPC struct {
...
@@ -177,7 +177,7 @@ type RPC struct {
// InitCfg interfaces
// InitCfg interfaces
func
InitCfg
(
cfg
*
types
.
RPC
)
{
func
InitCfg
(
cfg
*
types
.
RPC
)
{
rpcCfg
=
cfg
rpcCfg
=
cfg
InitI
p
Whitelist
(
cfg
)
InitI
P
Whitelist
(
cfg
)
InitJrpcFuncWhitelist
(
cfg
)
InitJrpcFuncWhitelist
(
cfg
)
InitGrpcFuncWhitelist
(
cfg
)
InitGrpcFuncWhitelist
(
cfg
)
InitJrpcFuncBlacklist
(
cfg
)
InitJrpcFuncBlacklist
(
cfg
)
...
@@ -265,29 +265,29 @@ func (r *RPC) Close() {
...
@@ -265,29 +265,29 @@ func (r *RPC) Close() {
}
}
}
}
// InitI
p
Whitelist init ip whitelist
// InitI
P
Whitelist init ip whitelist
func
InitI
p
Whitelist
(
cfg
*
types
.
RPC
)
{
func
InitI
P
Whitelist
(
cfg
*
types
.
RPC
)
{
if
len
(
cfg
.
Whitelist
)
==
0
&&
len
(
cfg
.
Whitlist
)
==
0
{
if
len
(
cfg
.
Whitelist
)
==
0
&&
len
(
cfg
.
Whitlist
)
==
0
{
remoteI
p
Whitelist
[
"127.0.0.1"
]
=
true
remoteI
P
Whitelist
[
"127.0.0.1"
]
=
true
return
return
}
}
if
len
(
cfg
.
Whitelist
)
==
1
&&
cfg
.
Whitelist
[
0
]
==
"*"
{
if
len
(
cfg
.
Whitelist
)
==
1
&&
cfg
.
Whitelist
[
0
]
==
"*"
{
remoteI
p
Whitelist
[
"0.0.0.0"
]
=
true
remoteI
P
Whitelist
[
"0.0.0.0"
]
=
true
return
return
}
}
if
len
(
cfg
.
Whitlist
)
==
1
&&
cfg
.
Whitlist
[
0
]
==
"*"
{
if
len
(
cfg
.
Whitlist
)
==
1
&&
cfg
.
Whitlist
[
0
]
==
"*"
{
remoteI
p
Whitelist
[
"0.0.0.0"
]
=
true
remoteI
P
Whitelist
[
"0.0.0.0"
]
=
true
return
return
}
}
if
len
(
cfg
.
Whitelist
)
!=
0
{
if
len
(
cfg
.
Whitelist
)
!=
0
{
for
_
,
addr
:=
range
cfg
.
Whitelist
{
for
_
,
addr
:=
range
cfg
.
Whitelist
{
remoteI
p
Whitelist
[
addr
]
=
true
remoteI
P
Whitelist
[
addr
]
=
true
}
}
return
return
}
}
if
len
(
cfg
.
Whitlist
)
!=
0
{
if
len
(
cfg
.
Whitlist
)
!=
0
{
for
_
,
addr
:=
range
cfg
.
Whitlist
{
for
_
,
addr
:=
range
cfg
.
Whitlist
{
remoteI
p
Whitelist
[
addr
]
=
true
remoteI
P
Whitelist
[
addr
]
=
true
}
}
return
return
}
}
...
...
vendor/github.com/33cn/chain33/rpc/server_test.go
View file @
e8a09f64
...
@@ -22,18 +22,18 @@ import (
...
@@ -22,18 +22,18 @@ import (
func
TestCheckIpWhitelist
(
t
*
testing
.
T
)
{
func
TestCheckIpWhitelist
(
t
*
testing
.
T
)
{
address
:=
"127.0.0.1"
address
:=
"127.0.0.1"
assert
.
True
(
t
,
checkI
p
Whitelist
(
address
))
assert
.
True
(
t
,
checkI
P
Whitelist
(
address
))
address
=
"::1"
address
=
"::1"
assert
.
True
(
t
,
checkI
p
Whitelist
(
address
))
assert
.
True
(
t
,
checkI
P
Whitelist
(
address
))
address
=
"192.168.3.1"
address
=
"192.168.3.1"
remoteI
p
Whitelist
[
address
]
=
true
remoteI
P
Whitelist
[
address
]
=
true
assert
.
False
(
t
,
checkI
p
Whitelist
(
"192.168.3.2"
))
assert
.
False
(
t
,
checkI
P
Whitelist
(
"192.168.3.2"
))
remoteI
p
Whitelist
[
"0.0.0.0"
]
=
true
remoteI
P
Whitelist
[
"0.0.0.0"
]
=
true
assert
.
True
(
t
,
checkI
p
Whitelist
(
address
))
assert
.
True
(
t
,
checkI
P
Whitelist
(
address
))
assert
.
True
(
t
,
checkI
p
Whitelist
(
"192.168.3.2"
))
assert
.
True
(
t
,
checkI
P
Whitelist
(
"192.168.3.2"
))
}
}
...
...
vendor/github.com/33cn/chain33/rpc/types/code.go
View file @
e8a09f64
...
@@ -47,8 +47,8 @@ func DecodeLog(execer []byte, rlog *ReceiptData) (*ReceiptDataResult, error) {
...
@@ -47,8 +47,8 @@ func DecodeLog(execer []byte, rlog *ReceiptData) (*ReceiptDataResult, error) {
return
rd
,
nil
return
rd
,
nil
}
}
// ConvertWalletTxDetailToJ
son
conver the wallet tx detail to json
// ConvertWalletTxDetailToJ
SON
conver the wallet tx detail to json
func
ConvertWalletTxDetailToJ
son
(
in
*
types
.
WalletTxDetails
,
out
*
WalletTxDetails
)
error
{
func
ConvertWalletTxDetailToJ
SON
(
in
*
types
.
WalletTxDetails
,
out
*
WalletTxDetails
)
error
{
if
in
==
nil
||
out
==
nil
{
if
in
==
nil
||
out
==
nil
{
return
types
.
ErrInvalidParam
return
types
.
ErrInvalidParam
}
}
...
...
vendor/github.com/33cn/chain33/system/dapp/coins/autotest/coins.go
View file @
e8a09f64
...
@@ -7,18 +7,18 @@ package autotest
...
@@ -7,18 +7,18 @@ package autotest
import
(
import
(
"reflect"
"reflect"
.
"github.com/33cn/chain33/cmd/autotest/types"
"github.com/33cn/chain33/cmd/autotest/types"
)
)
type
coinsAutoTest
struct
{
type
coinsAutoTest
struct
{
SimpleCaseArr
[]
SimpleCase
`toml:"SimpleCase,omitempty"`
SimpleCaseArr
[]
types
.
SimpleCase
`toml:"SimpleCase,omitempty"`
TransferCaseArr
[]
TransferCase
`toml:"TransferCase,omitempty"`
TransferCaseArr
[]
TransferCase
`toml:"TransferCase,omitempty"`
WithdrawCaseArr
[]
WithdrawCase
`toml:"WithdrawCase,omitempty"`
WithdrawCaseArr
[]
WithdrawCase
`toml:"WithdrawCase,omitempty"`
}
}
func
init
()
{
func
init
()
{
RegisterAutoTest
(
coinsAutoTest
{})
types
.
RegisterAutoTest
(
coinsAutoTest
{})
}
}
...
...
vendor/github.com/33cn/chain33/system/dapp/coins/autotest/transferCase.go
View file @
e8a09f64
...
@@ -7,12 +7,12 @@ package autotest
...
@@ -7,12 +7,12 @@ package autotest
import
(
import
(
"strconv"
"strconv"
.
"github.com/33cn/chain33/cmd/autotest/types"
"github.com/33cn/chain33/cmd/autotest/types"
)
)
// TransferCase transfer case
// TransferCase transfer case
type
TransferCase
struct
{
type
TransferCase
struct
{
BaseCase
types
.
BaseCase
From
string
`toml:"from"`
From
string
`toml:"from"`
To
string
`toml:"to"`
To
string
`toml:"to"`
Amount
string
`toml:"amount"`
Amount
string
`toml:"amount"`
...
@@ -20,19 +20,19 @@ type TransferCase struct {
...
@@ -20,19 +20,19 @@ type TransferCase struct {
// TransferPack transfer pack
// TransferPack transfer pack
type
TransferPack
struct
{
type
TransferPack
struct
{
BaseCasePack
types
.
BaseCasePack
}
}
// SendCommand sed command
// SendCommand sed command
func
(
testCase
*
TransferCase
)
SendCommand
(
packID
string
)
(
PackFunc
,
error
)
{
func
(
testCase
*
TransferCase
)
SendCommand
(
packID
string
)
(
types
.
PackFunc
,
error
)
{
return
DefaultSend
(
testCase
,
&
TransferPack
{},
packID
)
return
types
.
DefaultSend
(
testCase
,
&
TransferPack
{},
packID
)
}
}
// GetCheckHandlerMap get check handle for map
// GetCheckHandlerMap get check handle for map
func
(
pack
*
TransferPack
)
GetCheckHandlerMap
()
interface
{}
{
func
(
pack
*
TransferPack
)
GetCheckHandlerMap
()
interface
{}
{
funcMap
:=
make
(
CheckHandlerMapDiscard
,
2
)
funcMap
:=
make
(
types
.
CheckHandlerMapDiscard
,
2
)
funcMap
[
"balance"
]
=
pack
.
checkBalance
funcMap
[
"balance"
]
=
pack
.
checkBalance
return
funcMap
return
funcMap
...
@@ -61,10 +61,10 @@ func (pack *TransferPack) checkBalance(txInfo map[string]interface{}) bool {
...
@@ -61,10 +61,10 @@ func (pack *TransferPack) checkBalance(txInfo map[string]interface{}) bool {
//transfer to contract, deposit
//transfer to contract, deposit
if
len
(
logArr
)
==
4
{
if
len
(
logArr
)
==
4
{
logDeposit
:=
logArr
[
3
]
.
(
map
[
string
]
interface
{})[
"log"
]
.
(
map
[
string
]
interface
{})
logDeposit
:=
logArr
[
3
]
.
(
map
[
string
]
interface
{})[
"log"
]
.
(
map
[
string
]
interface
{})
depositCheck
=
CheckBalanceDeltaWithAddr
(
logDeposit
,
interCase
.
From
,
Amount
)
depositCheck
=
types
.
CheckBalanceDeltaWithAddr
(
logDeposit
,
interCase
.
From
,
Amount
)
}
}
return
CheckBalanceDeltaWithAddr
(
logFee
,
interCase
.
From
,
-
fee
)
&&
return
types
.
CheckBalanceDeltaWithAddr
(
logFee
,
interCase
.
From
,
-
fee
)
&&
CheckBalanceDeltaWithAddr
(
logSend
,
interCase
.
From
,
-
Amount
)
&&
types
.
CheckBalanceDeltaWithAddr
(
logSend
,
interCase
.
From
,
-
Amount
)
&&
CheckBalanceDeltaWithAddr
(
logRecv
,
interCase
.
To
,
Amount
)
&&
depositCheck
types
.
CheckBalanceDeltaWithAddr
(
logRecv
,
interCase
.
To
,
Amount
)
&&
depositCheck
}
}
vendor/github.com/33cn/chain33/system/dapp/coins/autotest/withdrawCase.go
View file @
e8a09f64
...
@@ -7,31 +7,31 @@ package autotest
...
@@ -7,31 +7,31 @@ package autotest
import
(
import
(
"strconv"
"strconv"
.
"github.com/33cn/chain33/cmd/autotest/types"
"github.com/33cn/chain33/cmd/autotest/types"
)
)
// WithdrawCase defines the withdraw case
// WithdrawCase defines the withdraw case
type
WithdrawCase
struct
{
type
WithdrawCase
struct
{
BaseCase
types
.
BaseCase
Addr
string
`toml:"addr"`
Addr
string
`toml:"addr"`
Amount
string
`toml:"amount"`
Amount
string
`toml:"amount"`
}
}
// WithdrawPack defines the withdraw pack
// WithdrawPack defines the withdraw pack
type
WithdrawPack
struct
{
type
WithdrawPack
struct
{
BaseCasePack
types
.
BaseCasePack
}
}
// SendCommand send command of withdrawcase
// SendCommand send command of withdrawcase
func
(
testCase
*
WithdrawCase
)
SendCommand
(
packID
string
)
(
PackFunc
,
error
)
{
func
(
testCase
*
WithdrawCase
)
SendCommand
(
packID
string
)
(
types
.
PackFunc
,
error
)
{
return
DefaultSend
(
testCase
,
&
WithdrawPack
{},
packID
)
return
types
.
DefaultSend
(
testCase
,
&
WithdrawPack
{},
packID
)
}
}
// GetCheckHandlerMap get check handler for map
// GetCheckHandlerMap get check handler for map
func
(
pack
*
WithdrawPack
)
GetCheckHandlerMap
()
interface
{}
{
func
(
pack
*
WithdrawPack
)
GetCheckHandlerMap
()
interface
{}
{
funcMap
:=
make
(
CheckHandlerMapDiscard
,
1
)
funcMap
:=
make
(
types
.
CheckHandlerMapDiscard
,
1
)
funcMap
[
"balance"
]
=
pack
.
checkBalance
funcMap
[
"balance"
]
=
pack
.
checkBalance
return
funcMap
return
funcMap
...
@@ -62,8 +62,8 @@ func (pack *WithdrawPack) checkBalance(txInfo map[string]interface{}) bool {
...
@@ -62,8 +62,8 @@ func (pack *WithdrawPack) checkBalance(txInfo map[string]interface{}) bool {
"ToPrev"
,
logRecv
[
"prev"
]
.
(
map
[
string
]
interface
{})[
"balance"
]
.
(
string
),
"ToPrev"
,
logRecv
[
"prev"
]
.
(
map
[
string
]
interface
{})[
"balance"
]
.
(
string
),
"ToCurr"
,
logRecv
[
"current"
]
.
(
map
[
string
]
interface
{})[
"balance"
]
.
(
string
))
"ToCurr"
,
logRecv
[
"current"
]
.
(
map
[
string
]
interface
{})[
"balance"
]
.
(
string
))
return
CheckBalanceDeltaWithAddr
(
logFee
,
interCase
.
Addr
,
-
fee
)
&&
return
types
.
CheckBalanceDeltaWithAddr
(
logFee
,
interCase
.
Addr
,
-
fee
)
&&
CheckBalanceDeltaWithAddr
(
logWithdraw
,
interCase
.
Addr
,
-
Amount
)
&&
types
.
CheckBalanceDeltaWithAddr
(
logWithdraw
,
interCase
.
Addr
,
-
Amount
)
&&
CheckBalanceDeltaWithAddr
(
logSend
,
withdrawFrom
,
-
Amount
)
&&
types
.
CheckBalanceDeltaWithAddr
(
logSend
,
withdrawFrom
,
-
Amount
)
&&
CheckBalanceDeltaWithAddr
(
logRecv
,
interCase
.
Addr
,
Amount
)
types
.
CheckBalanceDeltaWithAddr
(
logRecv
,
interCase
.
Addr
,
Amount
)
}
}
vendor/github.com/33cn/chain33/system/dapp/coins/executor/coins.go
View file @
e8a09f64
...
@@ -59,8 +59,16 @@ func (c *Coins) GetDriverName() string {
...
@@ -59,8 +59,16 @@ func (c *Coins) GetDriverName() string {
return
driverName
return
driverName
}
}
// CheckTx check transaction
// CheckTx check transaction
amount 必须不能为负数
func
(
c
*
Coins
)
CheckTx
(
tx
*
types
.
Transaction
,
index
int
)
error
{
func
(
c
*
Coins
)
CheckTx
(
tx
*
types
.
Transaction
,
index
int
)
error
{
ety
:=
c
.
GetExecutorType
()
amount
,
err
:=
ety
.
Amount
(
tx
)
if
err
!=
nil
{
return
err
}
if
amount
<
0
{
return
types
.
ErrAmount
}
return
nil
return
nil
}
}
...
@@ -76,3 +84,8 @@ func (c *Coins) IsFriend(myexec, writekey []byte, othertx *types.Transaction) bo
...
@@ -76,3 +84,8 @@ func (c *Coins) IsFriend(myexec, writekey []byte, othertx *types.Transaction) bo
}
}
return
false
return
false
}
}
// CheckReceiptExecOk return true to check if receipt ty is ok
func
(
c
*
Coins
)
CheckReceiptExecOk
()
bool
{
return
true
}
vendor/github.com/33cn/chain33/system/dapp/coins/executor/exec_del_local.go
View file @
e8a09f64
...
@@ -10,9 +10,6 @@ import (
...
@@ -10,9 +10,6 @@ import (
// ExecDelLocal_Transfer delete transfer of local exec
// ExecDelLocal_Transfer delete transfer of local exec
func
(
c
*
Coins
)
ExecDelLocal_Transfer
(
transfer
*
types
.
AssetsTransfer
,
tx
*
types
.
Transaction
,
receipt
*
types
.
ReceiptData
,
index
int
)
(
*
types
.
LocalDBSet
,
error
)
{
func
(
c
*
Coins
)
ExecDelLocal_Transfer
(
transfer
*
types
.
AssetsTransfer
,
tx
*
types
.
Transaction
,
receipt
*
types
.
ReceiptData
,
index
int
)
(
*
types
.
LocalDBSet
,
error
)
{
if
receipt
.
GetTy
()
!=
types
.
ExecOk
{
return
&
types
.
LocalDBSet
{},
nil
}
kv
,
err
:=
updateAddrReciver
(
c
.
GetLocalDB
(),
tx
.
GetRealToAddr
(),
transfer
.
Amount
,
false
)
kv
,
err
:=
updateAddrReciver
(
c
.
GetLocalDB
(),
tx
.
GetRealToAddr
(),
transfer
.
Amount
,
false
)
if
err
!=
nil
{
if
err
!=
nil
{
return
nil
,
err
return
nil
,
err
...
@@ -22,9 +19,6 @@ func (c *Coins) ExecDelLocal_Transfer(transfer *types.AssetsTransfer, tx *types.
...
@@ -22,9 +19,6 @@ func (c *Coins) ExecDelLocal_Transfer(transfer *types.AssetsTransfer, tx *types.
// ExecDelLocal_TransferToExec delete transfer of local exec to exec
// ExecDelLocal_TransferToExec delete transfer of local exec to exec
func
(
c
*
Coins
)
ExecDelLocal_TransferToExec
(
transfer
*
types
.
AssetsTransferToExec
,
tx
*
types
.
Transaction
,
receipt
*
types
.
ReceiptData
,
index
int
)
(
*
types
.
LocalDBSet
,
error
)
{
func
(
c
*
Coins
)
ExecDelLocal_TransferToExec
(
transfer
*
types
.
AssetsTransferToExec
,
tx
*
types
.
Transaction
,
receipt
*
types
.
ReceiptData
,
index
int
)
(
*
types
.
LocalDBSet
,
error
)
{
if
receipt
.
GetTy
()
!=
types
.
ExecOk
{
return
&
types
.
LocalDBSet
{},
nil
}
kv
,
err
:=
updateAddrReciver
(
c
.
GetLocalDB
(),
tx
.
GetRealToAddr
(),
transfer
.
Amount
,
false
)
kv
,
err
:=
updateAddrReciver
(
c
.
GetLocalDB
(),
tx
.
GetRealToAddr
(),
transfer
.
Amount
,
false
)
if
err
!=
nil
{
if
err
!=
nil
{
return
nil
,
err
return
nil
,
err
...
@@ -34,9 +28,6 @@ func (c *Coins) ExecDelLocal_TransferToExec(transfer *types.AssetsTransferToExec
...
@@ -34,9 +28,6 @@ func (c *Coins) ExecDelLocal_TransferToExec(transfer *types.AssetsTransferToExec
// ExecDelLocal_Withdraw delete withdraw of local exec
// ExecDelLocal_Withdraw delete withdraw of local exec
func
(
c
*
Coins
)
ExecDelLocal_Withdraw
(
withdraw
*
types
.
AssetsWithdraw
,
tx
*
types
.
Transaction
,
receipt
*
types
.
ReceiptData
,
index
int
)
(
*
types
.
LocalDBSet
,
error
)
{
func
(
c
*
Coins
)
ExecDelLocal_Withdraw
(
withdraw
*
types
.
AssetsWithdraw
,
tx
*
types
.
Transaction
,
receipt
*
types
.
ReceiptData
,
index
int
)
(
*
types
.
LocalDBSet
,
error
)
{
if
receipt
.
GetTy
()
!=
types
.
ExecOk
{
return
&
types
.
LocalDBSet
{},
nil
}
from
:=
tx
.
From
()
from
:=
tx
.
From
()
kv
,
err
:=
updateAddrReciver
(
c
.
GetLocalDB
(),
from
,
withdraw
.
Amount
,
false
)
kv
,
err
:=
updateAddrReciver
(
c
.
GetLocalDB
(),
from
,
withdraw
.
Amount
,
false
)
if
err
!=
nil
{
if
err
!=
nil
{
...
...
vendor/github.com/33cn/chain33/system/dapp/coins/executor/exec_local.go
View file @
e8a09f64
...
@@ -10,9 +10,6 @@ import (
...
@@ -10,9 +10,6 @@ import (
// ExecLocal_Transfer transfer of local exec
// ExecLocal_Transfer transfer of local exec
func
(
c
*
Coins
)
ExecLocal_Transfer
(
transfer
*
types
.
AssetsTransfer
,
tx
*
types
.
Transaction
,
receipt
*
types
.
ReceiptData
,
index
int
)
(
*
types
.
LocalDBSet
,
error
)
{
func
(
c
*
Coins
)
ExecLocal_Transfer
(
transfer
*
types
.
AssetsTransfer
,
tx
*
types
.
Transaction
,
receipt
*
types
.
ReceiptData
,
index
int
)
(
*
types
.
LocalDBSet
,
error
)
{
if
receipt
.
GetTy
()
!=
types
.
ExecOk
{
return
&
types
.
LocalDBSet
{},
nil
}
kv
,
err
:=
updateAddrReciver
(
c
.
GetLocalDB
(),
tx
.
GetRealToAddr
(),
transfer
.
Amount
,
true
)
kv
,
err
:=
updateAddrReciver
(
c
.
GetLocalDB
(),
tx
.
GetRealToAddr
(),
transfer
.
Amount
,
true
)
if
err
!=
nil
{
if
err
!=
nil
{
return
nil
,
err
return
nil
,
err
...
@@ -22,9 +19,6 @@ func (c *Coins) ExecLocal_Transfer(transfer *types.AssetsTransfer, tx *types.Tra
...
@@ -22,9 +19,6 @@ func (c *Coins) ExecLocal_Transfer(transfer *types.AssetsTransfer, tx *types.Tra
// ExecLocal_TransferToExec transfer of local exec to exec
// ExecLocal_TransferToExec transfer of local exec to exec
func
(
c
*
Coins
)
ExecLocal_TransferToExec
(
transfer
*
types
.
AssetsTransferToExec
,
tx
*
types
.
Transaction
,
receipt
*
types
.
ReceiptData
,
index
int
)
(
*
types
.
LocalDBSet
,
error
)
{
func
(
c
*
Coins
)
ExecLocal_TransferToExec
(
transfer
*
types
.
AssetsTransferToExec
,
tx
*
types
.
Transaction
,
receipt
*
types
.
ReceiptData
,
index
int
)
(
*
types
.
LocalDBSet
,
error
)
{
if
receipt
.
GetTy
()
!=
types
.
ExecOk
{
return
&
types
.
LocalDBSet
{},
nil
}
kv
,
err
:=
updateAddrReciver
(
c
.
GetLocalDB
(),
tx
.
GetRealToAddr
(),
transfer
.
Amount
,
true
)
kv
,
err
:=
updateAddrReciver
(
c
.
GetLocalDB
(),
tx
.
GetRealToAddr
(),
transfer
.
Amount
,
true
)
if
err
!=
nil
{
if
err
!=
nil
{
return
nil
,
err
return
nil
,
err
...
@@ -34,9 +28,6 @@ func (c *Coins) ExecLocal_TransferToExec(transfer *types.AssetsTransferToExec, t
...
@@ -34,9 +28,6 @@ func (c *Coins) ExecLocal_TransferToExec(transfer *types.AssetsTransferToExec, t
// ExecLocal_Withdraw withdraw local exec
// ExecLocal_Withdraw withdraw local exec
func
(
c
*
Coins
)
ExecLocal_Withdraw
(
withdraw
*
types
.
AssetsWithdraw
,
tx
*
types
.
Transaction
,
receipt
*
types
.
ReceiptData
,
index
int
)
(
*
types
.
LocalDBSet
,
error
)
{
func
(
c
*
Coins
)
ExecLocal_Withdraw
(
withdraw
*
types
.
AssetsWithdraw
,
tx
*
types
.
Transaction
,
receipt
*
types
.
ReceiptData
,
index
int
)
(
*
types
.
LocalDBSet
,
error
)
{
if
receipt
.
GetTy
()
!=
types
.
ExecOk
{
return
&
types
.
LocalDBSet
{},
nil
}
from
:=
tx
.
From
()
from
:=
tx
.
From
()
kv
,
err
:=
updateAddrReciver
(
c
.
GetLocalDB
(),
from
,
withdraw
.
Amount
,
true
)
kv
,
err
:=
updateAddrReciver
(
c
.
GetLocalDB
(),
from
,
withdraw
.
Amount
,
true
)
if
err
!=
nil
{
if
err
!=
nil
{
...
@@ -47,9 +38,6 @@ func (c *Coins) ExecLocal_Withdraw(withdraw *types.AssetsWithdraw, tx *types.Tra
...
@@ -47,9 +38,6 @@ func (c *Coins) ExecLocal_Withdraw(withdraw *types.AssetsWithdraw, tx *types.Tra
// ExecLocal_Genesis Genesis of local exec
// ExecLocal_Genesis Genesis of local exec
func
(
c
*
Coins
)
ExecLocal_Genesis
(
gen
*
types
.
AssetsGenesis
,
tx
*
types
.
Transaction
,
receipt
*
types
.
ReceiptData
,
index
int
)
(
*
types
.
LocalDBSet
,
error
)
{
func
(
c
*
Coins
)
ExecLocal_Genesis
(
gen
*
types
.
AssetsGenesis
,
tx
*
types
.
Transaction
,
receipt
*
types
.
ReceiptData
,
index
int
)
(
*
types
.
LocalDBSet
,
error
)
{
if
receipt
.
GetTy
()
!=
types
.
ExecOk
{
return
&
types
.
LocalDBSet
{},
nil
}
kv
,
err
:=
updateAddrReciver
(
c
.
GetLocalDB
(),
tx
.
GetRealToAddr
(),
gen
.
Amount
,
true
)
kv
,
err
:=
updateAddrReciver
(
c
.
GetLocalDB
(),
tx
.
GetRealToAddr
(),
gen
.
Amount
,
true
)
if
err
!=
nil
{
if
err
!=
nil
{
return
nil
,
err
return
nil
,
err
...
...
vendor/github.com/33cn/chain33/system/dapp/commands/account.go
View file @
e8a09f64
...
@@ -12,7 +12,7 @@ import (
...
@@ -12,7 +12,7 @@ import (
"github.com/33cn/chain33/common/address"
"github.com/33cn/chain33/common/address"
"github.com/33cn/chain33/rpc/jsonclient"
"github.com/33cn/chain33/rpc/jsonclient"
rpctypes
"github.com/33cn/chain33/rpc/types"
rpctypes
"github.com/33cn/chain33/rpc/types"
.
"github.com/33cn/chain33/system/dapp/commands/types"
commandtypes
"github.com/33cn/chain33/system/dapp/commands/types"
"github.com/33cn/chain33/types"
"github.com/33cn/chain33/types"
"github.com/spf13/cobra"
"github.com/spf13/cobra"
)
)
...
@@ -60,7 +60,7 @@ func dumpKey(cmd *cobra.Command, args []string) {
...
@@ -60,7 +60,7 @@ func dumpKey(cmd *cobra.Command, args []string) {
Data
:
addr
,
Data
:
addr
,
}
}
var
res
types
.
ReplyString
var
res
types
.
ReplyString
ctx
:=
jsonclient
.
NewR
pc
Ctx
(
rpcLaddr
,
"Chain33.DumpPrivkey"
,
params
,
&
res
)
ctx
:=
jsonclient
.
NewR
PC
Ctx
(
rpcLaddr
,
"Chain33.DumpPrivkey"
,
params
,
&
res
)
ctx
.
Run
()
ctx
.
Run
()
}
}
...
@@ -77,24 +77,24 @@ func GetAccountListCmd() *cobra.Command {
...
@@ -77,24 +77,24 @@ func GetAccountListCmd() *cobra.Command {
func
listAccount
(
cmd
*
cobra
.
Command
,
args
[]
string
)
{
func
listAccount
(
cmd
*
cobra
.
Command
,
args
[]
string
)
{
rpcLaddr
,
_
:=
cmd
.
Flags
()
.
GetString
(
"rpc_laddr"
)
rpcLaddr
,
_
:=
cmd
.
Flags
()
.
GetString
(
"rpc_laddr"
)
var
res
rpctypes
.
WalletAccounts
var
res
rpctypes
.
WalletAccounts
ctx
:=
jsonclient
.
NewR
pc
Ctx
(
rpcLaddr
,
"Chain33.GetAccounts"
,
nil
,
&
res
)
ctx
:=
jsonclient
.
NewR
PC
Ctx
(
rpcLaddr
,
"Chain33.GetAccounts"
,
nil
,
&
res
)
ctx
.
SetResultCb
(
parseListAccountRes
)
ctx
.
SetResultCb
(
parseListAccountRes
)
ctx
.
Run
()
ctx
.
Run
()
}
}
func
parseListAccountRes
(
arg
interface
{})
(
interface
{},
error
)
{
func
parseListAccountRes
(
arg
interface
{})
(
interface
{},
error
)
{
res
:=
arg
.
(
*
rpctypes
.
WalletAccounts
)
res
:=
arg
.
(
*
rpctypes
.
WalletAccounts
)
var
result
AccountsResult
var
result
commandtypes
.
AccountsResult
for
_
,
r
:=
range
res
.
Wallets
{
for
_
,
r
:=
range
res
.
Wallets
{
balanceResult
:=
strconv
.
FormatFloat
(
float64
(
r
.
Acc
.
Balance
)
/
float64
(
types
.
Coin
),
'f'
,
4
,
64
)
balanceResult
:=
strconv
.
FormatFloat
(
float64
(
r
.
Acc
.
Balance
)
/
float64
(
types
.
Coin
),
'f'
,
4
,
64
)
frozenResult
:=
strconv
.
FormatFloat
(
float64
(
r
.
Acc
.
Frozen
)
/
float64
(
types
.
Coin
),
'f'
,
4
,
64
)
frozenResult
:=
strconv
.
FormatFloat
(
float64
(
r
.
Acc
.
Frozen
)
/
float64
(
types
.
Coin
),
'f'
,
4
,
64
)
accResult
:=
&
AccountResult
{
accResult
:=
&
commandtypes
.
AccountResult
{
Currency
:
r
.
Acc
.
Currency
,
Currency
:
r
.
Acc
.
Currency
,
Addr
:
r
.
Acc
.
Addr
,
Addr
:
r
.
Acc
.
Addr
,
Balance
:
balanceResult
,
Balance
:
balanceResult
,
Frozen
:
frozenResult
,
Frozen
:
frozenResult
,
}
}
result
.
Wallets
=
append
(
result
.
Wallets
,
&
WalletResult
{
Acc
:
accResult
,
Label
:
r
.
Label
})
result
.
Wallets
=
append
(
result
.
Wallets
,
&
commandtypes
.
WalletResult
{
Acc
:
accResult
,
Label
:
r
.
Label
})
}
}
return
result
,
nil
return
result
,
nil
}
}
...
@@ -144,7 +144,7 @@ func balance(cmd *cobra.Command, args []string) {
...
@@ -144,7 +144,7 @@ func balance(cmd *cobra.Command, args []string) {
if
execer
==
""
{
if
execer
==
""
{
req
:=
types
.
ReqAddr
{
Addr
:
addr
}
req
:=
types
.
ReqAddr
{
Addr
:
addr
}
var
res
rpctypes
.
AllExecBalance
var
res
rpctypes
.
AllExecBalance
ctx
:=
jsonclient
.
NewR
pc
Ctx
(
rpcLaddr
,
"Chain33.GetAllExecBalance"
,
req
,
&
res
)
ctx
:=
jsonclient
.
NewR
PC
Ctx
(
rpcLaddr
,
"Chain33.GetAllExecBalance"
,
req
,
&
res
)
ctx
.
SetResultCb
(
parseGetAllBalanceRes
)
ctx
.
SetResultCb
(
parseGetAllBalanceRes
)
ctx
.
Run
()
ctx
.
Run
()
return
return
...
@@ -161,7 +161,7 @@ func balance(cmd *cobra.Command, args []string) {
...
@@ -161,7 +161,7 @@ func balance(cmd *cobra.Command, args []string) {
IsDetail
:
false
,
IsDetail
:
false
,
}
}
var
res
rpctypes
.
Headers
var
res
rpctypes
.
Headers
ctx
:=
jsonclient
.
NewR
pc
Ctx
(
rpcLaddr
,
"Chain33.GetHeaders"
,
params
,
&
res
)
ctx
:=
jsonclient
.
NewR
PC
Ctx
(
rpcLaddr
,
"Chain33.GetHeaders"
,
params
,
&
res
)
_
,
err
:=
ctx
.
RunResult
()
_
,
err
:=
ctx
.
RunResult
()
if
err
!=
nil
{
if
err
!=
nil
{
fmt
.
Fprintln
(
os
.
Stderr
,
err
)
fmt
.
Fprintln
(
os
.
Stderr
,
err
)
...
@@ -179,7 +179,7 @@ func balance(cmd *cobra.Command, args []string) {
...
@@ -179,7 +179,7 @@ func balance(cmd *cobra.Command, args []string) {
StateHash
:
stateHash
,
StateHash
:
stateHash
,
}
}
var
res
[]
*
rpctypes
.
Account
var
res
[]
*
rpctypes
.
Account
ctx
:=
jsonclient
.
NewR
pc
Ctx
(
rpcLaddr
,
"Chain33.GetBalance"
,
params
,
&
res
)
ctx
:=
jsonclient
.
NewR
PC
Ctx
(
rpcLaddr
,
"Chain33.GetBalance"
,
params
,
&
res
)
ctx
.
SetResultCb
(
parseGetBalanceRes
)
ctx
.
SetResultCb
(
parseGetBalanceRes
)
ctx
.
Run
()
ctx
.
Run
()
}
}
...
@@ -188,7 +188,7 @@ func parseGetBalanceRes(arg interface{}) (interface{}, error) {
...
@@ -188,7 +188,7 @@ func parseGetBalanceRes(arg interface{}) (interface{}, error) {
res
:=
*
arg
.
(
*
[]
*
rpctypes
.
Account
)
res
:=
*
arg
.
(
*
[]
*
rpctypes
.
Account
)
balanceResult
:=
strconv
.
FormatFloat
(
float64
(
res
[
0
]
.
Balance
)
/
float64
(
types
.
Coin
),
'f'
,
4
,
64
)
balanceResult
:=
strconv
.
FormatFloat
(
float64
(
res
[
0
]
.
Balance
)
/
float64
(
types
.
Coin
),
'f'
,
4
,
64
)
frozenResult
:=
strconv
.
FormatFloat
(
float64
(
res
[
0
]
.
Frozen
)
/
float64
(
types
.
Coin
),
'f'
,
4
,
64
)
frozenResult
:=
strconv
.
FormatFloat
(
float64
(
res
[
0
]
.
Frozen
)
/
float64
(
types
.
Coin
),
'f'
,
4
,
64
)
result
:=
&
AccountResult
{
result
:=
&
commandtypes
.
AccountResult
{
Addr
:
res
[
0
]
.
Addr
,
Addr
:
res
[
0
]
.
Addr
,
Currency
:
res
[
0
]
.
Currency
,
Currency
:
res
[
0
]
.
Currency
,
Balance
:
balanceResult
,
Balance
:
balanceResult
,
...
@@ -200,16 +200,16 @@ func parseGetBalanceRes(arg interface{}) (interface{}, error) {
...
@@ -200,16 +200,16 @@ func parseGetBalanceRes(arg interface{}) (interface{}, error) {
func
parseGetAllBalanceRes
(
arg
interface
{})
(
interface
{},
error
)
{
func
parseGetAllBalanceRes
(
arg
interface
{})
(
interface
{},
error
)
{
res
:=
*
arg
.
(
*
rpctypes
.
AllExecBalance
)
res
:=
*
arg
.
(
*
rpctypes
.
AllExecBalance
)
accs
:=
res
.
ExecAccount
accs
:=
res
.
ExecAccount
result
:=
AllExecBalance
{
Addr
:
res
.
Addr
}
result
:=
commandtypes
.
AllExecBalance
{
Addr
:
res
.
Addr
}
for
_
,
acc
:=
range
accs
{
for
_
,
acc
:=
range
accs
{
balanceResult
:=
strconv
.
FormatFloat
(
float64
(
acc
.
Account
.
Balance
)
/
float64
(
types
.
Coin
),
'f'
,
4
,
64
)
balanceResult
:=
strconv
.
FormatFloat
(
float64
(
acc
.
Account
.
Balance
)
/
float64
(
types
.
Coin
),
'f'
,
4
,
64
)
frozenResult
:=
strconv
.
FormatFloat
(
float64
(
acc
.
Account
.
Frozen
)
/
float64
(
types
.
Coin
),
'f'
,
4
,
64
)
frozenResult
:=
strconv
.
FormatFloat
(
float64
(
acc
.
Account
.
Frozen
)
/
float64
(
types
.
Coin
),
'f'
,
4
,
64
)
ar
:=
&
AccountResult
{
ar
:=
&
commandtypes
.
AccountResult
{
Currency
:
acc
.
Account
.
Currency
,
Currency
:
acc
.
Account
.
Currency
,
Balance
:
balanceResult
,
Balance
:
balanceResult
,
Frozen
:
frozenResult
,
Frozen
:
frozenResult
,
}
}
result
.
ExecAccount
=
append
(
result
.
ExecAccount
,
&
ExecAccount
{
Execer
:
acc
.
Execer
,
Account
:
ar
})
result
.
ExecAccount
=
append
(
result
.
ExecAccount
,
&
commandtypes
.
ExecAccount
{
Execer
:
acc
.
Execer
,
Account
:
ar
})
}
}
return
result
,
nil
return
result
,
nil
}
}
...
@@ -242,15 +242,15 @@ func importKey(cmd *cobra.Command, args []string) {
...
@@ -242,15 +242,15 @@ func importKey(cmd *cobra.Command, args []string) {
Label
:
label
,
Label
:
label
,
}
}
var
res
types
.
WalletAccount
var
res
types
.
WalletAccount
ctx
:=
jsonclient
.
NewR
pc
Ctx
(
rpcLaddr
,
"Chain33.ImportPrivkey"
,
params
,
&
res
)
ctx
:=
jsonclient
.
NewR
PC
Ctx
(
rpcLaddr
,
"Chain33.ImportPrivkey"
,
params
,
&
res
)
ctx
.
SetResultCb
(
parseImportKeyRes
)
ctx
.
SetResultCb
(
parseImportKeyRes
)
ctx
.
Run
()
ctx
.
Run
()
}
}
func
parseImportKeyRes
(
arg
interface
{})
(
interface
{},
error
)
{
func
parseImportKeyRes
(
arg
interface
{})
(
interface
{},
error
)
{
res
:=
arg
.
(
*
types
.
WalletAccount
)
res
:=
arg
.
(
*
types
.
WalletAccount
)
accResult
:=
DecodeAccount
(
res
.
GetAcc
(),
types
.
Coin
)
accResult
:=
commandtypes
.
DecodeAccount
(
res
.
GetAcc
(),
types
.
Coin
)
result
:=
WalletResult
{
result
:=
commandtypes
.
WalletResult
{
Acc
:
accResult
,
Acc
:
accResult
,
Label
:
res
.
GetLabel
(),
Label
:
res
.
GetLabel
(),
}
}
...
@@ -280,15 +280,15 @@ func createAccount(cmd *cobra.Command, args []string) {
...
@@ -280,15 +280,15 @@ func createAccount(cmd *cobra.Command, args []string) {
Label
:
label
,
Label
:
label
,
}
}
var
res
types
.
WalletAccount
var
res
types
.
WalletAccount
ctx
:=
jsonclient
.
NewR
pc
Ctx
(
rpcLaddr
,
"Chain33.NewAccount"
,
params
,
&
res
)
ctx
:=
jsonclient
.
NewR
PC
Ctx
(
rpcLaddr
,
"Chain33.NewAccount"
,
params
,
&
res
)
ctx
.
SetResultCb
(
parseCreateAccountRes
)
ctx
.
SetResultCb
(
parseCreateAccountRes
)
ctx
.
Run
()
ctx
.
Run
()
}
}
func
parseCreateAccountRes
(
arg
interface
{})
(
interface
{},
error
)
{
func
parseCreateAccountRes
(
arg
interface
{})
(
interface
{},
error
)
{
res
:=
arg
.
(
*
types
.
WalletAccount
)
res
:=
arg
.
(
*
types
.
WalletAccount
)
accResult
:=
DecodeAccount
(
res
.
GetAcc
(),
types
.
Coin
)
accResult
:=
commandtypes
.
DecodeAccount
(
res
.
GetAcc
(),
types
.
Coin
)
result
:=
WalletResult
{
result
:=
commandtypes
.
WalletResult
{
Acc
:
accResult
,
Acc
:
accResult
,
Label
:
res
.
GetLabel
(),
Label
:
res
.
GetLabel
(),
}
}
...
@@ -323,15 +323,15 @@ func setLabel(cmd *cobra.Command, args []string) {
...
@@ -323,15 +323,15 @@ func setLabel(cmd *cobra.Command, args []string) {
Label
:
label
,
Label
:
label
,
}
}
var
res
types
.
WalletAccount
var
res
types
.
WalletAccount
ctx
:=
jsonclient
.
NewR
pc
Ctx
(
rpcLaddr
,
"Chain33.SetLabl"
,
params
,
&
res
)
ctx
:=
jsonclient
.
NewR
PC
Ctx
(
rpcLaddr
,
"Chain33.SetLabl"
,
params
,
&
res
)
ctx
.
SetResultCb
(
parseSetLabelRes
)
ctx
.
SetResultCb
(
parseSetLabelRes
)
ctx
.
Run
()
ctx
.
Run
()
}
}
func
parseSetLabelRes
(
arg
interface
{})
(
interface
{},
error
)
{
func
parseSetLabelRes
(
arg
interface
{})
(
interface
{},
error
)
{
res
:=
arg
.
(
*
types
.
WalletAccount
)
res
:=
arg
.
(
*
types
.
WalletAccount
)
accResult
:=
DecodeAccount
(
res
.
GetAcc
(),
types
.
Coin
)
accResult
:=
commandtypes
.
DecodeAccount
(
res
.
GetAcc
(),
types
.
Coin
)
result
:=
WalletResult
{
result
:=
commandtypes
.
WalletResult
{
Acc
:
accResult
,
Acc
:
accResult
,
Label
:
res
.
GetLabel
(),
Label
:
res
.
GetLabel
(),
}
}
...
...
vendor/github.com/33cn/chain33/system/dapp/commands/block.go
View file @
e8a09f64
...
@@ -12,7 +12,7 @@ import (
...
@@ -12,7 +12,7 @@ import (
"github.com/33cn/chain33/rpc/jsonclient"
"github.com/33cn/chain33/rpc/jsonclient"
rpctypes
"github.com/33cn/chain33/rpc/types"
rpctypes
"github.com/33cn/chain33/rpc/types"
.
"github.com/33cn/chain33/system/dapp/commands/types"
commandtypes
"github.com/33cn/chain33/system/dapp/commands/types"
"github.com/33cn/chain33/types"
"github.com/33cn/chain33/types"
"github.com/spf13/cobra"
"github.com/spf13/cobra"
)
)
...
@@ -77,15 +77,15 @@ func blockBodyCmd(cmd *cobra.Command, args []string) {
...
@@ -77,15 +77,15 @@ func blockBodyCmd(cmd *cobra.Command, args []string) {
Isdetail
:
detailBool
,
Isdetail
:
detailBool
,
}
}
var
res
rpctypes
.
BlockDetails
var
res
rpctypes
.
BlockDetails
ctx
:=
jsonclient
.
NewR
pc
Ctx
(
rpcLaddr
,
"Chain33.GetBlocks"
,
params
,
&
res
)
ctx
:=
jsonclient
.
NewR
PC
Ctx
(
rpcLaddr
,
"Chain33.GetBlocks"
,
params
,
&
res
)
ctx
.
SetResultCb
(
parseBlockDetail
)
ctx
.
SetResultCb
(
parseBlockDetail
)
ctx
.
Run
()
ctx
.
Run
()
}
}
func
parseBlockDetail
(
res
interface
{})
(
interface
{},
error
)
{
func
parseBlockDetail
(
res
interface
{})
(
interface
{},
error
)
{
var
result
BlockDetailsResult
var
result
commandtypes
.
BlockDetailsResult
for
_
,
vItem
:=
range
res
.
(
*
rpctypes
.
BlockDetails
)
.
Items
{
for
_
,
vItem
:=
range
res
.
(
*
rpctypes
.
BlockDetails
)
.
Items
{
b
:=
&
BlockResult
{
b
:=
&
commandtypes
.
BlockResult
{
Version
:
vItem
.
Block
.
Version
,
Version
:
vItem
.
Block
.
Version
,
ParentHash
:
vItem
.
Block
.
ParentHash
,
ParentHash
:
vItem
.
Block
.
ParentHash
,
TxHash
:
vItem
.
Block
.
TxHash
,
TxHash
:
vItem
.
Block
.
TxHash
,
...
@@ -94,9 +94,9 @@ func parseBlockDetail(res interface{}) (interface{}, error) {
...
@@ -94,9 +94,9 @@ func parseBlockDetail(res interface{}) (interface{}, error) {
BlockTime
:
vItem
.
Block
.
BlockTime
,
BlockTime
:
vItem
.
Block
.
BlockTime
,
}
}
for
_
,
vTx
:=
range
vItem
.
Block
.
Txs
{
for
_
,
vTx
:=
range
vItem
.
Block
.
Txs
{
b
.
Txs
=
append
(
b
.
Txs
,
DecodeTransaction
(
vTx
))
b
.
Txs
=
append
(
b
.
Txs
,
commandtypes
.
DecodeTransaction
(
vTx
))
}
}
bd
:=
&
BlockDetailResult
{
Block
:
b
,
Receipts
:
vItem
.
Receipts
}
bd
:=
&
commandtypes
.
BlockDetailResult
{
Block
:
b
,
Receipts
:
vItem
.
Receipts
}
result
.
Items
=
append
(
result
.
Items
,
bd
)
result
.
Items
=
append
(
result
.
Items
,
bd
)
}
}
return
result
,
nil
return
result
,
nil
...
@@ -125,7 +125,7 @@ func blockHeightHash(cmd *cobra.Command, args []string) {
...
@@ -125,7 +125,7 @@ func blockHeightHash(cmd *cobra.Command, args []string) {
Height
:
height
,
Height
:
height
,
}
}
var
res
rpctypes
.
ReplyHash
var
res
rpctypes
.
ReplyHash
ctx
:=
jsonclient
.
NewR
pc
Ctx
(
rpcLaddr
,
"Chain33.GetBlockHash"
,
params
,
&
res
)
ctx
:=
jsonclient
.
NewR
PC
Ctx
(
rpcLaddr
,
"Chain33.GetBlockHash"
,
params
,
&
res
)
ctx
.
Run
()
ctx
.
Run
()
}
}
...
@@ -152,7 +152,7 @@ func blockViewByHash(cmd *cobra.Command, args []string) {
...
@@ -152,7 +152,7 @@ func blockViewByHash(cmd *cobra.Command, args []string) {
Hash
:
blockHash
,
Hash
:
blockHash
,
}
}
var
res
rpctypes
.
BlockOverview
var
res
rpctypes
.
BlockOverview
ctx
:=
jsonclient
.
NewR
pc
Ctx
(
rpcLaddr
,
"Chain33.GetBlockOverview"
,
params
,
&
res
)
ctx
:=
jsonclient
.
NewR
PC
Ctx
(
rpcLaddr
,
"Chain33.GetBlockOverview"
,
params
,
&
res
)
ctx
.
Run
()
ctx
.
Run
()
}
}
...
@@ -193,7 +193,7 @@ func blockHeader(cmd *cobra.Command, args []string) {
...
@@ -193,7 +193,7 @@ func blockHeader(cmd *cobra.Command, args []string) {
IsDetail
:
detailBool
,
IsDetail
:
detailBool
,
}
}
var
res
rpctypes
.
Headers
var
res
rpctypes
.
Headers
ctx
:=
jsonclient
.
NewR
pc
Ctx
(
rpcLaddr
,
"Chain33.GetHeaders"
,
params
,
&
res
)
ctx
:=
jsonclient
.
NewR
PC
Ctx
(
rpcLaddr
,
"Chain33.GetHeaders"
,
params
,
&
res
)
ctx
.
Run
()
ctx
.
Run
()
}
}
...
@@ -210,7 +210,7 @@ func GetLastHeaderCmd() *cobra.Command {
...
@@ -210,7 +210,7 @@ func GetLastHeaderCmd() *cobra.Command {
func
lastHeader
(
cmd
*
cobra
.
Command
,
args
[]
string
)
{
func
lastHeader
(
cmd
*
cobra
.
Command
,
args
[]
string
)
{
rpcLaddr
,
_
:=
cmd
.
Flags
()
.
GetString
(
"rpc_laddr"
)
rpcLaddr
,
_
:=
cmd
.
Flags
()
.
GetString
(
"rpc_laddr"
)
var
res
rpctypes
.
Header
var
res
rpctypes
.
Header
ctx
:=
jsonclient
.
NewR
pc
Ctx
(
rpcLaddr
,
"Chain33.GetLastHeader"
,
nil
,
&
res
)
ctx
:=
jsonclient
.
NewR
PC
Ctx
(
rpcLaddr
,
"Chain33.GetLastHeader"
,
nil
,
&
res
)
ctx
.
Run
()
ctx
.
Run
()
}
}
...
@@ -227,7 +227,7 @@ func GetLastBlockSequenceCmd() *cobra.Command {
...
@@ -227,7 +227,7 @@ func GetLastBlockSequenceCmd() *cobra.Command {
func
lastSequence
(
cmd
*
cobra
.
Command
,
args
[]
string
)
{
func
lastSequence
(
cmd
*
cobra
.
Command
,
args
[]
string
)
{
rpcLaddr
,
_
:=
cmd
.
Flags
()
.
GetString
(
"rpc_laddr"
)
rpcLaddr
,
_
:=
cmd
.
Flags
()
.
GetString
(
"rpc_laddr"
)
var
res
int64
var
res
int64
ctx
:=
jsonclient
.
NewR
pc
Ctx
(
rpcLaddr
,
"Chain33.GetLastBlockSequence"
,
nil
,
&
res
)
ctx
:=
jsonclient
.
NewR
PC
Ctx
(
rpcLaddr
,
"Chain33.GetLastBlockSequence"
,
nil
,
&
res
)
ctx
.
Run
()
ctx
.
Run
()
}
}
...
@@ -253,7 +253,7 @@ func getsequences(cmd *cobra.Command, args []string) {
...
@@ -253,7 +253,7 @@ func getsequences(cmd *cobra.Command, args []string) {
Isdetail
:
false
,
Isdetail
:
false
,
}
}
var
res
rpctypes
.
ReplyBlkSeqs
var
res
rpctypes
.
ReplyBlkSeqs
ctx
:=
jsonclient
.
NewR
pc
Ctx
(
rpcLaddr
,
"Chain33.GetBlockSequences"
,
params
,
&
res
)
ctx
:=
jsonclient
.
NewR
PC
Ctx
(
rpcLaddr
,
"Chain33.GetBlockSequences"
,
params
,
&
res
)
//ctx.SetResultCb(parseBlockDetail)
//ctx.SetResultCb(parseBlockDetail)
ctx
.
Run
()
ctx
.
Run
()
}
}
...
@@ -291,7 +291,7 @@ func getblockbyhashs(cmd *cobra.Command, args []string) {
...
@@ -291,7 +291,7 @@ func getblockbyhashs(cmd *cobra.Command, args []string) {
}
}
var
res
types
.
BlockDetails
var
res
types
.
BlockDetails
ctx
:=
jsonclient
.
NewR
pc
Ctx
(
rpcLaddr
,
"Chain33.GetBlockByHashes"
,
params
,
&
res
)
ctx
:=
jsonclient
.
NewR
PC
Ctx
(
rpcLaddr
,
"Chain33.GetBlockByHashes"
,
params
,
&
res
)
//ctx.SetResultCb(parseQueryTxsByHashesRes)
//ctx.SetResultCb(parseQueryTxsByHashesRes)
ctx
.
Run
()
ctx
.
Run
()
}
}
vendor/github.com/33cn/chain33/system/dapp/commands/bty.go
View file @
e8a09f64
...
@@ -14,7 +14,7 @@ import (
...
@@ -14,7 +14,7 @@ import (
"time"
"time"
"github.com/33cn/chain33/rpc/jsonclient"
"github.com/33cn/chain33/rpc/jsonclient"
.
"github.com/33cn/chain33/system/dapp/commands/types"
commandtypes
"github.com/33cn/chain33/system/dapp/commands/types"
"github.com/33cn/chain33/types"
"github.com/33cn/chain33/types"
"github.com/spf13/cobra"
"github.com/spf13/cobra"
)
)
...
@@ -86,7 +86,7 @@ func createTransfer(cmd *cobra.Command, args []string) {
...
@@ -86,7 +86,7 @@ func createTransfer(cmd *cobra.Command, args []string) {
toAddr
,
_
:=
cmd
.
Flags
()
.
GetString
(
"to"
)
toAddr
,
_
:=
cmd
.
Flags
()
.
GetString
(
"to"
)
amount
,
_
:=
cmd
.
Flags
()
.
GetFloat64
(
"amount"
)
amount
,
_
:=
cmd
.
Flags
()
.
GetFloat64
(
"amount"
)
note
,
_
:=
cmd
.
Flags
()
.
GetString
(
"note"
)
note
,
_
:=
cmd
.
Flags
()
.
GetString
(
"note"
)
txHex
,
err
:=
CreateRawTx
(
cmd
,
toAddr
,
amount
,
note
,
false
,
""
,
""
)
txHex
,
err
:=
commandtypes
.
CreateRawTx
(
cmd
,
toAddr
,
amount
,
note
,
false
,
""
,
""
)
if
err
!=
nil
{
if
err
!=
nil
{
fmt
.
Fprintln
(
os
.
Stderr
,
err
)
fmt
.
Fprintln
(
os
.
Stderr
,
err
)
return
return
...
@@ -119,12 +119,12 @@ func createWithdraw(cmd *cobra.Command, args []string) {
...
@@ -119,12 +119,12 @@ func createWithdraw(cmd *cobra.Command, args []string) {
exec
,
_
:=
cmd
.
Flags
()
.
GetString
(
"exec"
)
exec
,
_
:=
cmd
.
Flags
()
.
GetString
(
"exec"
)
amount
,
_
:=
cmd
.
Flags
()
.
GetFloat64
(
"amount"
)
amount
,
_
:=
cmd
.
Flags
()
.
GetFloat64
(
"amount"
)
note
,
_
:=
cmd
.
Flags
()
.
GetString
(
"note"
)
note
,
_
:=
cmd
.
Flags
()
.
GetString
(
"note"
)
execAddr
,
err
:=
GetExecAddr
(
exec
)
execAddr
,
err
:=
commandtypes
.
GetExecAddr
(
exec
)
if
err
!=
nil
{
if
err
!=
nil
{
fmt
.
Fprintln
(
os
.
Stderr
,
err
)
fmt
.
Fprintln
(
os
.
Stderr
,
err
)
return
return
}
}
txHex
,
err
:=
CreateRawTx
(
cmd
,
execAddr
,
amount
,
note
,
true
,
""
,
exec
)
txHex
,
err
:=
commandtypes
.
CreateRawTx
(
cmd
,
execAddr
,
amount
,
note
,
true
,
""
,
exec
)
if
err
!=
nil
{
if
err
!=
nil
{
fmt
.
Fprintln
(
os
.
Stderr
,
err
)
fmt
.
Fprintln
(
os
.
Stderr
,
err
)
return
return
...
@@ -157,12 +157,12 @@ func sendToExec(cmd *cobra.Command, args []string) {
...
@@ -157,12 +157,12 @@ func sendToExec(cmd *cobra.Command, args []string) {
exec
,
_
:=
cmd
.
Flags
()
.
GetString
(
"exec"
)
exec
,
_
:=
cmd
.
Flags
()
.
GetString
(
"exec"
)
amount
,
_
:=
cmd
.
Flags
()
.
GetFloat64
(
"amount"
)
amount
,
_
:=
cmd
.
Flags
()
.
GetFloat64
(
"amount"
)
note
,
_
:=
cmd
.
Flags
()
.
GetString
(
"note"
)
note
,
_
:=
cmd
.
Flags
()
.
GetString
(
"note"
)
execAddr
,
err
:=
GetExecAddr
(
exec
)
execAddr
,
err
:=
commandtypes
.
GetExecAddr
(
exec
)
if
err
!=
nil
{
if
err
!=
nil
{
fmt
.
Fprintln
(
os
.
Stderr
,
err
)
fmt
.
Fprintln
(
os
.
Stderr
,
err
)
return
return
}
}
txHex
,
err
:=
CreateRawTx
(
cmd
,
execAddr
,
amount
,
note
,
false
,
""
,
exec
)
txHex
,
err
:=
commandtypes
.
CreateRawTx
(
cmd
,
execAddr
,
amount
,
note
,
false
,
""
,
exec
)
if
err
!=
nil
{
if
err
!=
nil
{
fmt
.
Fprintln
(
os
.
Stderr
,
err
)
fmt
.
Fprintln
(
os
.
Stderr
,
err
)
return
return
...
@@ -201,7 +201,7 @@ func transfer(cmd *cobra.Command, args []string) {
...
@@ -201,7 +201,7 @@ func transfer(cmd *cobra.Command, args []string) {
amount
,
_
:=
cmd
.
Flags
()
.
GetFloat64
(
"amount"
)
amount
,
_
:=
cmd
.
Flags
()
.
GetFloat64
(
"amount"
)
note
,
_
:=
cmd
.
Flags
()
.
GetString
(
"note"
)
note
,
_
:=
cmd
.
Flags
()
.
GetString
(
"note"
)
amountInt64
:=
int64
(
amount
*
types
.
InputPrecision
)
*
types
.
Multiple1E4
//支持4位小数输入,多余的输入将被截断
amountInt64
:=
int64
(
amount
*
types
.
InputPrecision
)
*
types
.
Multiple1E4
//支持4位小数输入,多余的输入将被截断
SendToAddress
(
rpcLaddr
,
fromAddr
,
toAddr
,
amountInt64
,
note
,
false
,
""
,
false
)
commandtypes
.
SendToAddress
(
rpcLaddr
,
fromAddr
,
toAddr
,
amountInt64
,
note
,
false
,
""
,
false
)
}
}
// WithdrawFromExecCmd withdraw from executor
// WithdrawFromExecCmd withdraw from executor
...
@@ -234,13 +234,13 @@ func withdraw(cmd *cobra.Command, args []string) {
...
@@ -234,13 +234,13 @@ func withdraw(cmd *cobra.Command, args []string) {
exec
,
_
:=
cmd
.
Flags
()
.
GetString
(
"exec"
)
exec
,
_
:=
cmd
.
Flags
()
.
GetString
(
"exec"
)
amount
,
_
:=
cmd
.
Flags
()
.
GetFloat64
(
"amount"
)
amount
,
_
:=
cmd
.
Flags
()
.
GetFloat64
(
"amount"
)
note
,
_
:=
cmd
.
Flags
()
.
GetString
(
"note"
)
note
,
_
:=
cmd
.
Flags
()
.
GetString
(
"note"
)
execAddr
,
err
:=
GetExecAddr
(
exec
)
execAddr
,
err
:=
commandtypes
.
GetExecAddr
(
exec
)
if
err
!=
nil
{
if
err
!=
nil
{
fmt
.
Fprintln
(
os
.
Stderr
,
err
)
fmt
.
Fprintln
(
os
.
Stderr
,
err
)
return
return
}
}
amountInt64
:=
int64
(
amount
*
types
.
InputPrecision
)
*
types
.
Multiple1E4
//支持4位小数输入,多余的输入将被截断
amountInt64
:=
int64
(
amount
*
types
.
InputPrecision
)
*
types
.
Multiple1E4
//支持4位小数输入,多余的输入将被截断
SendToAddress
(
rpcLaddr
,
addr
,
execAddr
,
amountInt64
,
note
,
false
,
""
,
true
)
commandtypes
.
SendToAddress
(
rpcLaddr
,
addr
,
execAddr
,
amountInt64
,
note
,
false
,
""
,
true
)
}
}
// CreateTxGroupCmd create tx group
// CreateTxGroupCmd create tx group
...
@@ -348,7 +348,7 @@ func createPub2PrivTxFlags(cmd *cobra.Command) {
...
@@ -348,7 +348,7 @@ func createPub2PrivTxFlags(cmd *cobra.Command) {
func
createPub2PrivTx
(
cmd
*
cobra
.
Command
,
args
[]
string
)
{
func
createPub2PrivTx
(
cmd
*
cobra
.
Command
,
args
[]
string
)
{
rpcLaddr
,
_
:=
cmd
.
Flags
()
.
GetString
(
"rpc_laddr"
)
rpcLaddr
,
_
:=
cmd
.
Flags
()
.
GetString
(
"rpc_laddr"
)
pubkeypair
,
_
:=
cmd
.
Flags
()
.
GetString
(
"pubkeypair"
)
pubkeypair
,
_
:=
cmd
.
Flags
()
.
GetString
(
"pubkeypair"
)
amount
:=
GetAmountValue
(
cmd
,
"amount"
)
amount
:=
commandtypes
.
GetAmountValue
(
cmd
,
"amount"
)
tokenname
,
_
:=
cmd
.
Flags
()
.
GetString
(
"tokenname"
)
tokenname
,
_
:=
cmd
.
Flags
()
.
GetString
(
"tokenname"
)
note
,
_
:=
cmd
.
Flags
()
.
GetString
(
"note"
)
note
,
_
:=
cmd
.
Flags
()
.
GetString
(
"note"
)
expire
,
_
:=
cmd
.
Flags
()
.
GetInt64
(
"expire"
)
expire
,
_
:=
cmd
.
Flags
()
.
GetInt64
(
"expire"
)
...
@@ -375,7 +375,7 @@ func createPub2PrivTx(cmd *cobra.Command, args []string) {
...
@@ -375,7 +375,7 @@ func createPub2PrivTx(cmd *cobra.Command, args []string) {
Pubkeypair
:
pubkeypair
,
Pubkeypair
:
pubkeypair
,
Expire
:
expire
,
Expire
:
expire
,
}
}
ctx
:=
jsonclient
.
NewR
pc
Ctx
(
rpcLaddr
,
"privacy.CreateRawTransaction"
,
params
,
nil
)
ctx
:=
jsonclient
.
NewR
PC
Ctx
(
rpcLaddr
,
"privacy.CreateRawTransaction"
,
params
,
nil
)
ctx
.
RunWithoutMarshal
()
ctx
.
RunWithoutMarshal
()
}
}
...
@@ -407,7 +407,7 @@ func createPriv2PrivTxFlags(cmd *cobra.Command) {
...
@@ -407,7 +407,7 @@ func createPriv2PrivTxFlags(cmd *cobra.Command) {
func
createPriv2PrivTx
(
cmd
*
cobra
.
Command
,
args
[]
string
)
{
func
createPriv2PrivTx
(
cmd
*
cobra
.
Command
,
args
[]
string
)
{
rpcLaddr
,
_
:=
cmd
.
Flags
()
.
GetString
(
"rpc_laddr"
)
rpcLaddr
,
_
:=
cmd
.
Flags
()
.
GetString
(
"rpc_laddr"
)
pubkeypair
,
_
:=
cmd
.
Flags
()
.
GetString
(
"pubkeypair"
)
pubkeypair
,
_
:=
cmd
.
Flags
()
.
GetString
(
"pubkeypair"
)
amount
:=
GetAmountValue
(
cmd
,
"amount"
)
amount
:=
commandtypes
.
GetAmountValue
(
cmd
,
"amount"
)
tokenname
,
_
:=
cmd
.
Flags
()
.
GetString
(
"tokenname"
)
tokenname
,
_
:=
cmd
.
Flags
()
.
GetString
(
"tokenname"
)
note
,
_
:=
cmd
.
Flags
()
.
GetString
(
"note"
)
note
,
_
:=
cmd
.
Flags
()
.
GetString
(
"note"
)
sender
,
_
:=
cmd
.
Flags
()
.
GetString
(
"sender"
)
sender
,
_
:=
cmd
.
Flags
()
.
GetString
(
"sender"
)
...
@@ -437,7 +437,7 @@ func createPriv2PrivTx(cmd *cobra.Command, args []string) {
...
@@ -437,7 +437,7 @@ func createPriv2PrivTx(cmd *cobra.Command, args []string) {
Mixcount
:
defaultPrivacyMixCount
,
Mixcount
:
defaultPrivacyMixCount
,
Expire
:
expire
,
Expire
:
expire
,
}
}
ctx
:=
jsonclient
.
NewR
pc
Ctx
(
rpcLaddr
,
"privacy.CreateRawTransaction"
,
params
,
nil
)
ctx
:=
jsonclient
.
NewR
PC
Ctx
(
rpcLaddr
,
"privacy.CreateRawTransaction"
,
params
,
nil
)
ctx
.
RunWithoutMarshal
()
ctx
.
RunWithoutMarshal
()
}
}
...
@@ -468,7 +468,7 @@ func createPriv2PubTxFlags(cmd *cobra.Command) {
...
@@ -468,7 +468,7 @@ func createPriv2PubTxFlags(cmd *cobra.Command) {
func
createPriv2PubTx
(
cmd
*
cobra
.
Command
,
args
[]
string
)
{
func
createPriv2PubTx
(
cmd
*
cobra
.
Command
,
args
[]
string
)
{
rpcLaddr
,
_
:=
cmd
.
Flags
()
.
GetString
(
"rpc_laddr"
)
rpcLaddr
,
_
:=
cmd
.
Flags
()
.
GetString
(
"rpc_laddr"
)
amount
:=
GetAmountValue
(
cmd
,
"amount"
)
amount
:=
commandtypes
.
GetAmountValue
(
cmd
,
"amount"
)
tokenname
,
_
:=
cmd
.
Flags
()
.
GetString
(
"tokenname"
)
tokenname
,
_
:=
cmd
.
Flags
()
.
GetString
(
"tokenname"
)
from
,
_
:=
cmd
.
Flags
()
.
GetString
(
"from"
)
from
,
_
:=
cmd
.
Flags
()
.
GetString
(
"from"
)
to
,
_
:=
cmd
.
Flags
()
.
GetString
(
"to"
)
to
,
_
:=
cmd
.
Flags
()
.
GetString
(
"to"
)
...
@@ -499,6 +499,6 @@ func createPriv2PubTx(cmd *cobra.Command, args []string) {
...
@@ -499,6 +499,6 @@ func createPriv2PubTx(cmd *cobra.Command, args []string) {
Mixcount
:
defaultPrivacyMixCount
,
Mixcount
:
defaultPrivacyMixCount
,
Expire
:
expire
,
Expire
:
expire
,
}
}
ctx
:=
jsonclient
.
NewR
pc
Ctx
(
rpcLaddr
,
"privacy.CreateRawTransaction"
,
params
,
nil
)
ctx
:=
jsonclient
.
NewR
PC
Ctx
(
rpcLaddr
,
"privacy.CreateRawTransaction"
,
params
,
nil
)
ctx
.
RunWithoutMarshal
()
ctx
.
RunWithoutMarshal
()
}
}
vendor/github.com/33cn/chain33/system/dapp/commands/mempool.go
View file @
e8a09f64
...
@@ -7,7 +7,7 @@ package commands
...
@@ -7,7 +7,7 @@ package commands
import
(
import
(
"github.com/33cn/chain33/rpc/jsonclient"
"github.com/33cn/chain33/rpc/jsonclient"
rpctypes
"github.com/33cn/chain33/rpc/types"
rpctypes
"github.com/33cn/chain33/rpc/types"
.
"github.com/33cn/chain33/system/dapp/commands/types"
"github.com/33cn/chain33/system/dapp/commands/types"
"github.com/spf13/cobra"
"github.com/spf13/cobra"
)
)
...
@@ -40,16 +40,16 @@ func GetMempoolCmd() *cobra.Command {
...
@@ -40,16 +40,16 @@ func GetMempoolCmd() *cobra.Command {
func
listMempoolTxs
(
cmd
*
cobra
.
Command
,
args
[]
string
)
{
func
listMempoolTxs
(
cmd
*
cobra
.
Command
,
args
[]
string
)
{
rpcLaddr
,
_
:=
cmd
.
Flags
()
.
GetString
(
"rpc_laddr"
)
rpcLaddr
,
_
:=
cmd
.
Flags
()
.
GetString
(
"rpc_laddr"
)
var
res
rpctypes
.
ReplyTxList
var
res
rpctypes
.
ReplyTxList
ctx
:=
jsonclient
.
NewR
pc
Ctx
(
rpcLaddr
,
"Chain33.GetMempool"
,
nil
,
&
res
)
ctx
:=
jsonclient
.
NewR
PC
Ctx
(
rpcLaddr
,
"Chain33.GetMempool"
,
nil
,
&
res
)
ctx
.
SetResultCb
(
parseListMempoolTxsRes
)
ctx
.
SetResultCb
(
parseListMempoolTxsRes
)
ctx
.
Run
()
ctx
.
Run
()
}
}
func
parseListMempoolTxsRes
(
arg
interface
{})
(
interface
{},
error
)
{
func
parseListMempoolTxsRes
(
arg
interface
{})
(
interface
{},
error
)
{
res
:=
arg
.
(
*
rpctypes
.
ReplyTxList
)
res
:=
arg
.
(
*
rpctypes
.
ReplyTxList
)
var
result
TxListResult
var
result
types
.
TxListResult
for
_
,
v
:=
range
res
.
Txs
{
for
_
,
v
:=
range
res
.
Txs
{
result
.
Txs
=
append
(
result
.
Txs
,
DecodeTransaction
(
v
))
result
.
Txs
=
append
(
result
.
Txs
,
types
.
DecodeTransaction
(
v
))
}
}
return
result
,
nil
return
result
,
nil
}
}
...
@@ -67,16 +67,16 @@ func GetLastMempoolCmd() *cobra.Command {
...
@@ -67,16 +67,16 @@ func GetLastMempoolCmd() *cobra.Command {
func
lastMempoolTxs
(
cmd
*
cobra
.
Command
,
args
[]
string
)
{
func
lastMempoolTxs
(
cmd
*
cobra
.
Command
,
args
[]
string
)
{
rpcLaddr
,
_
:=
cmd
.
Flags
()
.
GetString
(
"rpc_laddr"
)
rpcLaddr
,
_
:=
cmd
.
Flags
()
.
GetString
(
"rpc_laddr"
)
var
res
rpctypes
.
ReplyTxList
var
res
rpctypes
.
ReplyTxList
ctx
:=
jsonclient
.
NewR
pc
Ctx
(
rpcLaddr
,
"Chain33.GetLastMemPool"
,
nil
,
&
res
)
ctx
:=
jsonclient
.
NewR
PC
Ctx
(
rpcLaddr
,
"Chain33.GetLastMemPool"
,
nil
,
&
res
)
ctx
.
SetResultCb
(
parselastMempoolTxsRes
)
ctx
.
SetResultCb
(
parselastMempoolTxsRes
)
ctx
.
Run
()
ctx
.
Run
()
}
}
func
parselastMempoolTxsRes
(
arg
interface
{})
(
interface
{},
error
)
{
func
parselastMempoolTxsRes
(
arg
interface
{})
(
interface
{},
error
)
{
res
:=
arg
.
(
*
rpctypes
.
ReplyTxList
)
res
:=
arg
.
(
*
rpctypes
.
ReplyTxList
)
var
result
TxListResult
var
result
types
.
TxListResult
for
_
,
v
:=
range
res
.
Txs
{
for
_
,
v
:=
range
res
.
Txs
{
result
.
Txs
=
append
(
result
.
Txs
,
DecodeTransaction
(
v
))
result
.
Txs
=
append
(
result
.
Txs
,
types
.
DecodeTransaction
(
v
))
}
}
return
result
,
nil
return
result
,
nil
}
}
vendor/github.com/33cn/chain33/system/dapp/commands/net.go
View file @
e8a09f64
...
@@ -44,7 +44,7 @@ func GetPeerInfoCmd() *cobra.Command {
...
@@ -44,7 +44,7 @@ func GetPeerInfoCmd() *cobra.Command {
func
peerInfo
(
cmd
*
cobra
.
Command
,
args
[]
string
)
{
func
peerInfo
(
cmd
*
cobra
.
Command
,
args
[]
string
)
{
rpcLaddr
,
_
:=
cmd
.
Flags
()
.
GetString
(
"rpc_laddr"
)
rpcLaddr
,
_
:=
cmd
.
Flags
()
.
GetString
(
"rpc_laddr"
)
var
res
rpctypes
.
PeerList
var
res
rpctypes
.
PeerList
ctx
:=
jsonclient
.
NewR
pc
Ctx
(
rpcLaddr
,
"Chain33.GetPeerInfo"
,
nil
,
&
res
)
ctx
:=
jsonclient
.
NewR
PC
Ctx
(
rpcLaddr
,
"Chain33.GetPeerInfo"
,
nil
,
&
res
)
ctx
.
Run
()
ctx
.
Run
()
}
}
...
@@ -61,7 +61,7 @@ func IsClockSyncCmd() *cobra.Command {
...
@@ -61,7 +61,7 @@ func IsClockSyncCmd() *cobra.Command {
func
isClockSync
(
cmd
*
cobra
.
Command
,
args
[]
string
)
{
func
isClockSync
(
cmd
*
cobra
.
Command
,
args
[]
string
)
{
rpcLaddr
,
_
:=
cmd
.
Flags
()
.
GetString
(
"rpc_laddr"
)
rpcLaddr
,
_
:=
cmd
.
Flags
()
.
GetString
(
"rpc_laddr"
)
var
res
bool
var
res
bool
ctx
:=
jsonclient
.
NewR
pc
Ctx
(
rpcLaddr
,
"Chain33.IsNtpClockSync"
,
nil
,
&
res
)
ctx
:=
jsonclient
.
NewR
PC
Ctx
(
rpcLaddr
,
"Chain33.IsNtpClockSync"
,
nil
,
&
res
)
ctx
.
Run
()
ctx
.
Run
()
}
}
...
@@ -78,7 +78,7 @@ func IsSyncCmd() *cobra.Command {
...
@@ -78,7 +78,7 @@ func IsSyncCmd() *cobra.Command {
func
isSync
(
cmd
*
cobra
.
Command
,
args
[]
string
)
{
func
isSync
(
cmd
*
cobra
.
Command
,
args
[]
string
)
{
rpcLaddr
,
_
:=
cmd
.
Flags
()
.
GetString
(
"rpc_laddr"
)
rpcLaddr
,
_
:=
cmd
.
Flags
()
.
GetString
(
"rpc_laddr"
)
var
res
bool
var
res
bool
ctx
:=
jsonclient
.
NewR
pc
Ctx
(
rpcLaddr
,
"Chain33.IsSync"
,
nil
,
&
res
)
ctx
:=
jsonclient
.
NewR
PC
Ctx
(
rpcLaddr
,
"Chain33.IsSync"
,
nil
,
&
res
)
ctx
.
Run
()
ctx
.
Run
()
}
}
...
@@ -95,7 +95,7 @@ func GetNetInfoCmd() *cobra.Command {
...
@@ -95,7 +95,7 @@ func GetNetInfoCmd() *cobra.Command {
func
netInfo
(
cmd
*
cobra
.
Command
,
args
[]
string
)
{
func
netInfo
(
cmd
*
cobra
.
Command
,
args
[]
string
)
{
rpcLaddr
,
_
:=
cmd
.
Flags
()
.
GetString
(
"rpc_laddr"
)
rpcLaddr
,
_
:=
cmd
.
Flags
()
.
GetString
(
"rpc_laddr"
)
var
res
rpctypes
.
NodeNetinfo
var
res
rpctypes
.
NodeNetinfo
ctx
:=
jsonclient
.
NewR
pc
Ctx
(
rpcLaddr
,
"Chain33.GetNetInfo"
,
nil
,
&
res
)
ctx
:=
jsonclient
.
NewR
PC
Ctx
(
rpcLaddr
,
"Chain33.GetNetInfo"
,
nil
,
&
res
)
ctx
.
Run
()
ctx
.
Run
()
}
}
...
@@ -112,7 +112,7 @@ func GetFatalFailureCmd() *cobra.Command {
...
@@ -112,7 +112,7 @@ func GetFatalFailureCmd() *cobra.Command {
func
fatalFailure
(
cmd
*
cobra
.
Command
,
args
[]
string
)
{
func
fatalFailure
(
cmd
*
cobra
.
Command
,
args
[]
string
)
{
rpcLaddr
,
_
:=
cmd
.
Flags
()
.
GetString
(
"rpc_laddr"
)
rpcLaddr
,
_
:=
cmd
.
Flags
()
.
GetString
(
"rpc_laddr"
)
var
res
int64
var
res
int64
ctx
:=
jsonclient
.
NewR
pc
Ctx
(
rpcLaddr
,
"Chain33.GetFatalFailure"
,
nil
,
&
res
)
ctx
:=
jsonclient
.
NewR
PC
Ctx
(
rpcLaddr
,
"Chain33.GetFatalFailure"
,
nil
,
&
res
)
ctx
.
Run
()
ctx
.
Run
()
}
}
...
@@ -129,6 +129,6 @@ func GetTimeStausCmd() *cobra.Command {
...
@@ -129,6 +129,6 @@ func GetTimeStausCmd() *cobra.Command {
func
timestatus
(
cmd
*
cobra
.
Command
,
args
[]
string
)
{
func
timestatus
(
cmd
*
cobra
.
Command
,
args
[]
string
)
{
rpcLaddr
,
_
:=
cmd
.
Flags
()
.
GetString
(
"rpc_laddr"
)
rpcLaddr
,
_
:=
cmd
.
Flags
()
.
GetString
(
"rpc_laddr"
)
var
res
rpctypes
.
TimeStatus
var
res
rpctypes
.
TimeStatus
ctx
:=
jsonclient
.
NewR
pc
Ctx
(
rpcLaddr
,
"Chain33.GetTimeStatus"
,
nil
,
&
res
)
ctx
:=
jsonclient
.
NewR
PC
Ctx
(
rpcLaddr
,
"Chain33.GetTimeStatus"
,
nil
,
&
res
)
ctx
.
Run
()
ctx
.
Run
()
}
}
vendor/github.com/33cn/chain33/system/dapp/commands/seed.go
View file @
e8a09f64
...
@@ -51,7 +51,7 @@ func genSeed(cmd *cobra.Command, args []string) {
...
@@ -51,7 +51,7 @@ func genSeed(cmd *cobra.Command, args []string) {
Lang
:
lang
,
Lang
:
lang
,
}
}
var
res
types
.
ReplySeed
var
res
types
.
ReplySeed
ctx
:=
jsonclient
.
NewR
pc
Ctx
(
rpcLaddr
,
"Chain33.GenSeed"
,
params
,
&
res
)
ctx
:=
jsonclient
.
NewR
PC
Ctx
(
rpcLaddr
,
"Chain33.GenSeed"
,
params
,
&
res
)
ctx
.
Run
()
ctx
.
Run
()
}
}
...
@@ -78,7 +78,7 @@ func getSeed(cmd *cobra.Command, args []string) {
...
@@ -78,7 +78,7 @@ func getSeed(cmd *cobra.Command, args []string) {
Passwd
:
pwd
,
Passwd
:
pwd
,
}
}
var
res
types
.
ReplySeed
var
res
types
.
ReplySeed
ctx
:=
jsonclient
.
NewR
pc
Ctx
(
rpcLaddr
,
"Chain33.GetSeed"
,
params
,
&
res
)
ctx
:=
jsonclient
.
NewR
PC
Ctx
(
rpcLaddr
,
"Chain33.GetSeed"
,
params
,
&
res
)
ctx
.
Run
()
ctx
.
Run
()
}
}
...
@@ -110,6 +110,6 @@ func saveSeed(cmd *cobra.Command, args []string) {
...
@@ -110,6 +110,6 @@ func saveSeed(cmd *cobra.Command, args []string) {
Passwd
:
pwd
,
Passwd
:
pwd
,
}
}
var
res
rpctypes
.
Reply
var
res
rpctypes
.
Reply
ctx
:=
jsonclient
.
NewR
pc
Ctx
(
rpcLaddr
,
"Chain33.SaveSeed"
,
params
,
&
res
)
ctx
:=
jsonclient
.
NewR
PC
Ctx
(
rpcLaddr
,
"Chain33.SaveSeed"
,
params
,
&
res
)
ctx
.
Run
()
ctx
.
Run
()
}
}
vendor/github.com/33cn/chain33/system/dapp/commands/stat.go
View file @
e8a09f64
...
@@ -19,7 +19,7 @@ import (
...
@@ -19,7 +19,7 @@ import (
"github.com/33cn/chain33/common"
"github.com/33cn/chain33/common"
"github.com/33cn/chain33/common/difficulty"
"github.com/33cn/chain33/common/difficulty"
rpctypes
"github.com/33cn/chain33/rpc/types"
rpctypes
"github.com/33cn/chain33/rpc/types"
.
"github.com/33cn/chain33/system/dapp/commands/types"
commandtypes
"github.com/33cn/chain33/system/dapp/commands/types"
"github.com/33cn/chain33/types"
"github.com/33cn/chain33/types"
"github.com/spf13/cobra"
"github.com/spf13/cobra"
)
)
...
@@ -111,7 +111,7 @@ func totalCoins(cmd *cobra.Command, args []string) {
...
@@ -111,7 +111,7 @@ func totalCoins(cmd *cobra.Command, args []string) {
// 查询高度哈希对应数据
// 查询高度哈希对应数据
var
totalAmount
int64
var
totalAmount
int64
resp
:=
GetTotalCoinsResult
{}
resp
:=
commandtypes
.
GetTotalCoinsResult
{}
if
symbol
==
"bty"
{
if
symbol
==
"bty"
{
//查询高度blockhash
//查询高度blockhash
...
@@ -249,7 +249,7 @@ func ticketStat(cmd *cobra.Command, args []string) {
...
@@ -249,7 +249,7 @@ func ticketStat(cmd *cobra.Command, args []string) {
return
return
}
}
var
resp
GetTicketStatisticResult
var
resp
commandtypes
.
GetTicketStatisticResult
resp
.
CurrentOpenCount
=
res
.
CurrentOpenCount
resp
.
CurrentOpenCount
=
res
.
CurrentOpenCount
resp
.
TotalMinerCount
=
res
.
TotalMinerCount
resp
.
TotalMinerCount
=
res
.
TotalMinerCount
resp
.
TotalCloseCount
=
res
.
TotalCancleCount
resp
.
TotalCloseCount
=
res
.
TotalCancleCount
...
@@ -281,7 +281,7 @@ func addTicketInfoCmdFlags(cmd *cobra.Command) {
...
@@ -281,7 +281,7 @@ func addTicketInfoCmdFlags(cmd *cobra.Command) {
func
ticketInfo
(
cmd
*
cobra
.
Command
,
args
[]
string
)
{
func
ticketInfo
(
cmd
*
cobra
.
Command
,
args
[]
string
)
{
rpcAddr
,
_
:=
cmd
.
Flags
()
.
GetString
(
"rpc_laddr"
)
rpcAddr
,
_
:=
cmd
.
Flags
()
.
GetString
(
"rpc_laddr"
)
ticketI
d
,
_
:=
cmd
.
Flags
()
.
GetString
(
"ticket_id"
)
ticketI
D
,
_
:=
cmd
.
Flags
()
.
GetString
(
"ticket_id"
)
rpc
,
err
:=
jsonclient
.
NewJSONClient
(
rpcAddr
)
rpc
,
err
:=
jsonclient
.
NewJSONClient
(
rpcAddr
)
if
err
!=
nil
{
if
err
!=
nil
{
...
@@ -289,7 +289,7 @@ func ticketInfo(cmd *cobra.Command, args []string) {
...
@@ -289,7 +289,7 @@ func ticketInfo(cmd *cobra.Command, args []string) {
return
return
}
}
key
:=
[]
byte
(
"Statistics:TicketInfo:TicketId:"
+
ticketI
d
)
key
:=
[]
byte
(
"Statistics:TicketInfo:TicketId:"
+
ticketI
D
)
fmt
.
Println
(
string
(
key
))
fmt
.
Println
(
string
(
key
))
params
:=
types
.
LocalDBGet
{
Keys
:
[][]
byte
{
key
}}
params
:=
types
.
LocalDBGet
{
Keys
:
[][]
byte
{
key
}}
var
res
types
.
TicketMinerInfo
var
res
types
.
TicketMinerInfo
...
@@ -299,8 +299,8 @@ func ticketInfo(cmd *cobra.Command, args []string) {
...
@@ -299,8 +299,8 @@ func ticketInfo(cmd *cobra.Command, args []string) {
return
return
}
}
var
resp
GetTicketMinerInfoResult
var
resp
commandtypes
.
GetTicketMinerInfoResult
resp
.
TicketI
d
=
res
.
TicketId
resp
.
TicketI
D
=
res
.
TicketId
switch
res
.
Status
{
switch
res
.
Status
{
case
1
:
case
1
:
resp
.
Status
=
"openTicket"
resp
.
Status
=
"openTicket"
...
@@ -360,7 +360,7 @@ func ticketInfoList(cmd *cobra.Command, args []string) {
...
@@ -360,7 +360,7 @@ func ticketInfoList(cmd *cobra.Command, args []string) {
count
,
_
:=
cmd
.
Flags
()
.
GetInt32
(
"count"
)
count
,
_
:=
cmd
.
Flags
()
.
GetInt32
(
"count"
)
direction
,
_
:=
cmd
.
Flags
()
.
GetInt32
(
"direction"
)
direction
,
_
:=
cmd
.
Flags
()
.
GetInt32
(
"direction"
)
createTime
,
_
:=
cmd
.
Flags
()
.
GetString
(
"create_time"
)
createTime
,
_
:=
cmd
.
Flags
()
.
GetString
(
"create_time"
)
ticketI
d
,
_
:=
cmd
.
Flags
()
.
GetString
(
"ticket_id"
)
ticketI
D
,
_
:=
cmd
.
Flags
()
.
GetString
(
"ticket_id"
)
if
count
<=
0
{
if
count
<=
0
{
fmt
.
Fprintln
(
os
.
Stderr
,
fmt
.
Errorf
(
"input err, count:%v"
,
count
))
fmt
.
Fprintln
(
os
.
Stderr
,
fmt
.
Errorf
(
"input err, count:%v"
,
count
))
...
@@ -375,8 +375,8 @@ func ticketInfoList(cmd *cobra.Command, args []string) {
...
@@ -375,8 +375,8 @@ func ticketInfoList(cmd *cobra.Command, args []string) {
var
key
[]
byte
var
key
[]
byte
prefix
:=
[]
byte
(
"Statistics:TicketInfoOrder:Addr:"
+
addr
)
prefix
:=
[]
byte
(
"Statistics:TicketInfoOrder:Addr:"
+
addr
)
if
ticketI
d
!=
""
&&
createTime
!=
""
{
if
ticketI
D
!=
""
&&
createTime
!=
""
{
key
=
[]
byte
(
"Statistics:TicketInfoOrder:Addr:"
+
addr
+
":CreateTime:"
+
createTime
+
":TicketId:"
+
ticketI
d
)
key
=
[]
byte
(
"Statistics:TicketInfoOrder:Addr:"
+
addr
+
":CreateTime:"
+
createTime
+
":TicketId:"
+
ticketI
D
)
}
}
fmt
.
Println
(
string
(
prefix
))
fmt
.
Println
(
string
(
prefix
))
fmt
.
Println
(
string
(
key
))
fmt
.
Println
(
string
(
key
))
...
@@ -388,10 +388,10 @@ func ticketInfoList(cmd *cobra.Command, args []string) {
...
@@ -388,10 +388,10 @@ func ticketInfoList(cmd *cobra.Command, args []string) {
return
return
}
}
var
resp
[]
GetTicketMinerInfoResult
var
resp
[]
commandtypes
.
GetTicketMinerInfoResult
for
_
,
v
:=
range
res
{
for
_
,
v
:=
range
res
{
var
ticket
GetTicketMinerInfoResult
var
ticket
commandtypes
.
GetTicketMinerInfoResult
ticket
.
TicketI
d
=
v
.
TicketId
ticket
.
TicketI
D
=
v
.
TicketId
switch
v
.
Status
{
switch
v
.
Status
{
case
1
:
case
1
:
...
@@ -714,7 +714,7 @@ func execBalance(cmd *cobra.Command, args []string) {
...
@@ -714,7 +714,7 @@ func execBalance(cmd *cobra.Command, args []string) {
return
return
}
}
resp
:=
GetExecBalanceResult
{}
resp
:=
commandtypes
.
GetExecBalanceResult
{}
if
symbol
==
"bty"
{
if
symbol
==
"bty"
{
exec
=
"coins"
exec
=
"coins"
...
@@ -787,13 +787,13 @@ func execBalance(cmd *cobra.Command, args []string) {
...
@@ -787,13 +787,13 @@ func execBalance(cmd *cobra.Command, args []string) {
fmt
.
Println
(
string
(
data
))
fmt
.
Println
(
string
(
data
))
}
}
func
convertReplyToResult
(
reply
*
types
.
ReplyGetExecBalance
,
result
*
GetExecBalanceResult
,
precision
int64
)
{
func
convertReplyToResult
(
reply
*
types
.
ReplyGetExecBalance
,
result
*
commandtypes
.
GetExecBalanceResult
,
precision
int64
)
{
result
.
Amount
=
strconv
.
FormatFloat
(
float64
(
reply
.
Amount
)
/
float64
(
precision
),
'f'
,
4
,
64
)
result
.
Amount
=
strconv
.
FormatFloat
(
float64
(
reply
.
Amount
)
/
float64
(
precision
),
'f'
,
4
,
64
)
result
.
AmountFrozen
=
strconv
.
FormatFloat
(
float64
(
reply
.
AmountFrozen
)
/
float64
(
precision
),
'f'
,
4
,
64
)
result
.
AmountFrozen
=
strconv
.
FormatFloat
(
float64
(
reply
.
AmountFrozen
)
/
float64
(
precision
),
'f'
,
4
,
64
)
result
.
AmountActive
=
strconv
.
FormatFloat
(
float64
(
reply
.
AmountActive
)
/
float64
(
precision
),
'f'
,
4
,
64
)
result
.
AmountActive
=
strconv
.
FormatFloat
(
float64
(
reply
.
AmountActive
)
/
float64
(
precision
),
'f'
,
4
,
64
)
for
i
:=
0
;
i
<
len
(
reply
.
Items
);
i
++
{
for
i
:=
0
;
i
<
len
(
reply
.
Items
);
i
++
{
item
:=
&
ExecBalance
{}
item
:=
&
commandtypes
.
ExecBalance
{}
item
.
ExecAddr
=
string
(
reply
.
Items
[
i
]
.
ExecAddr
)
item
.
ExecAddr
=
string
(
reply
.
Items
[
i
]
.
ExecAddr
)
item
.
Frozen
=
strconv
.
FormatFloat
(
float64
(
reply
.
Items
[
i
]
.
Frozen
)
/
float64
(
precision
),
'f'
,
4
,
64
)
item
.
Frozen
=
strconv
.
FormatFloat
(
float64
(
reply
.
Items
[
i
]
.
Frozen
)
/
float64
(
precision
),
'f'
,
4
,
64
)
item
.
Active
=
strconv
.
FormatFloat
(
float64
(
reply
.
Items
[
i
]
.
Active
)
/
float64
(
precision
),
'f'
,
4
,
64
)
item
.
Active
=
strconv
.
FormatFloat
(
float64
(
reply
.
Items
[
i
]
.
Active
)
/
float64
(
precision
),
'f'
,
4
,
64
)
...
...
vendor/github.com/33cn/chain33/system/dapp/commands/tx.go
View file @
e8a09f64
...
@@ -15,7 +15,7 @@ import (
...
@@ -15,7 +15,7 @@ import (
"github.com/33cn/chain33/common"
"github.com/33cn/chain33/common"
"github.com/33cn/chain33/rpc/jsonclient"
"github.com/33cn/chain33/rpc/jsonclient"
rpctypes
"github.com/33cn/chain33/rpc/types"
rpctypes
"github.com/33cn/chain33/rpc/types"
.
"github.com/33cn/chain33/system/dapp/commands/types"
commandtypes
"github.com/33cn/chain33/system/dapp/commands/types"
"github.com/33cn/chain33/types"
"github.com/33cn/chain33/types"
"github.com/spf13/cobra"
"github.com/spf13/cobra"
)
)
...
@@ -79,7 +79,7 @@ func queryTxByAddr(cmd *cobra.Command, args []string) {
...
@@ -79,7 +79,7 @@ func queryTxByAddr(cmd *cobra.Command, args []string) {
Index
:
index
,
Index
:
index
,
}
}
var
res
rpctypes
.
ReplyTxInfos
var
res
rpctypes
.
ReplyTxInfos
ctx
:=
jsonclient
.
NewR
pc
Ctx
(
rpcLaddr
,
"Chain33.GetTxByAddr"
,
params
,
&
res
)
ctx
:=
jsonclient
.
NewR
PC
Ctx
(
rpcLaddr
,
"Chain33.GetTxByAddr"
,
params
,
&
res
)
ctx
.
Run
()
ctx
.
Run
()
}
}
...
@@ -110,7 +110,7 @@ func queryTx(cmd *cobra.Command, args []string) {
...
@@ -110,7 +110,7 @@ func queryTx(cmd *cobra.Command, args []string) {
Hash
:
hash
,
Hash
:
hash
,
}
}
var
res
rpctypes
.
TransactionDetail
var
res
rpctypes
.
TransactionDetail
ctx
:=
jsonclient
.
NewR
pc
Ctx
(
rpcLaddr
,
"Chain33.QueryTransaction"
,
params
,
&
res
)
ctx
:=
jsonclient
.
NewR
PC
Ctx
(
rpcLaddr
,
"Chain33.QueryTransaction"
,
params
,
&
res
)
ctx
.
SetResultCb
(
parseQueryTxRes
)
ctx
.
SetResultCb
(
parseQueryTxRes
)
ctx
.
Run
()
ctx
.
Run
()
}
}
...
@@ -118,8 +118,8 @@ func queryTx(cmd *cobra.Command, args []string) {
...
@@ -118,8 +118,8 @@ func queryTx(cmd *cobra.Command, args []string) {
func
parseQueryTxRes
(
arg
interface
{})
(
interface
{},
error
)
{
func
parseQueryTxRes
(
arg
interface
{})
(
interface
{},
error
)
{
res
:=
arg
.
(
*
rpctypes
.
TransactionDetail
)
res
:=
arg
.
(
*
rpctypes
.
TransactionDetail
)
amountResult
:=
strconv
.
FormatFloat
(
float64
(
res
.
Amount
)
/
float64
(
types
.
Coin
),
'f'
,
4
,
64
)
amountResult
:=
strconv
.
FormatFloat
(
float64
(
res
.
Amount
)
/
float64
(
types
.
Coin
),
'f'
,
4
,
64
)
result
:=
TxDetailResult
{
result
:=
commandtypes
.
TxDetailResult
{
Tx
:
DecodeTransaction
(
res
.
Tx
),
Tx
:
commandtypes
.
DecodeTransaction
(
res
.
Tx
),
Receipt
:
res
.
Receipt
,
Receipt
:
res
.
Receipt
,
Proofs
:
res
.
Proofs
,
Proofs
:
res
.
Proofs
,
Height
:
res
.
Height
,
Height
:
res
.
Height
,
...
@@ -158,21 +158,21 @@ func getTxsByHashes(cmd *cobra.Command, args []string) {
...
@@ -158,21 +158,21 @@ func getTxsByHashes(cmd *cobra.Command, args []string) {
}
}
var
res
rpctypes
.
TransactionDetails
var
res
rpctypes
.
TransactionDetails
ctx
:=
jsonclient
.
NewR
pc
Ctx
(
rpcLaddr
,
"Chain33.GetTxByHashes"
,
params
,
&
res
)
ctx
:=
jsonclient
.
NewR
PC
Ctx
(
rpcLaddr
,
"Chain33.GetTxByHashes"
,
params
,
&
res
)
ctx
.
SetResultCb
(
parseQueryTxsByHashesRes
)
ctx
.
SetResultCb
(
parseQueryTxsByHashesRes
)
ctx
.
Run
()
ctx
.
Run
()
}
}
func
parseQueryTxsByHashesRes
(
arg
interface
{})
(
interface
{},
error
)
{
func
parseQueryTxsByHashesRes
(
arg
interface
{})
(
interface
{},
error
)
{
var
result
TxDetailsResult
var
result
commandtypes
.
TxDetailsResult
for
_
,
v
:=
range
arg
.
(
*
rpctypes
.
TransactionDetails
)
.
Txs
{
for
_
,
v
:=
range
arg
.
(
*
rpctypes
.
TransactionDetails
)
.
Txs
{
if
v
==
nil
{
if
v
==
nil
{
result
.
Txs
=
append
(
result
.
Txs
,
nil
)
result
.
Txs
=
append
(
result
.
Txs
,
nil
)
continue
continue
}
}
amountResult
:=
strconv
.
FormatFloat
(
float64
(
v
.
Amount
)
/
float64
(
types
.
Coin
),
'f'
,
4
,
64
)
amountResult
:=
strconv
.
FormatFloat
(
float64
(
v
.
Amount
)
/
float64
(
types
.
Coin
),
'f'
,
4
,
64
)
td
:=
TxDetailResult
{
td
:=
commandtypes
.
TxDetailResult
{
Tx
:
DecodeTransaction
(
v
.
Tx
),
Tx
:
commandtypes
.
DecodeTransaction
(
v
.
Tx
),
Receipt
:
v
.
Receipt
,
Receipt
:
v
.
Receipt
,
Proofs
:
v
.
Proofs
,
Proofs
:
v
.
Proofs
,
Height
:
v
.
Height
,
Height
:
v
.
Height
,
...
@@ -211,7 +211,7 @@ func getTxHexByHash(cmd *cobra.Command, args []string) {
...
@@ -211,7 +211,7 @@ func getTxHexByHash(cmd *cobra.Command, args []string) {
Hash
:
txHash
,
Hash
:
txHash
,
}
}
ctx
:=
jsonclient
.
NewR
pc
Ctx
(
rpcLaddr
,
"Chain33.GetHexTxByHash"
,
params
,
nil
)
ctx
:=
jsonclient
.
NewR
PC
Ctx
(
rpcLaddr
,
"Chain33.GetHexTxByHash"
,
params
,
nil
)
ctx
.
RunWithoutMarshal
()
ctx
.
RunWithoutMarshal
()
}
}
...
@@ -252,7 +252,7 @@ func decodeTx(cmd *cobra.Command, args []string) {
...
@@ -252,7 +252,7 @@ func decodeTx(cmd *cobra.Command, args []string) {
return
return
}
}
txResult
:=
DecodeTransaction
(
res
)
txResult
:=
commandtypes
.
DecodeTransaction
(
res
)
result
,
err
:=
json
.
MarshalIndent
(
txResult
,
""
,
" "
)
result
,
err
:=
json
.
MarshalIndent
(
txResult
,
""
,
" "
)
if
err
!=
nil
{
if
err
!=
nil
{
...
@@ -287,7 +287,7 @@ func viewAddress(cmd *cobra.Command, args []string) {
...
@@ -287,7 +287,7 @@ func viewAddress(cmd *cobra.Command, args []string) {
}
}
var
res
types
.
AddrOverview
var
res
types
.
AddrOverview
ctx
:=
jsonclient
.
NewR
pc
Ctx
(
rpcLaddr
,
"Chain33.GetAddrOverview"
,
params
,
&
res
)
ctx
:=
jsonclient
.
NewR
PC
Ctx
(
rpcLaddr
,
"Chain33.GetAddrOverview"
,
params
,
&
res
)
ctx
.
SetResultCb
(
parseAddrOverview
)
ctx
.
SetResultCb
(
parseAddrOverview
)
ctx
.
Run
()
ctx
.
Run
()
}
}
...
@@ -296,7 +296,7 @@ func parseAddrOverview(view interface{}) (interface{}, error) {
...
@@ -296,7 +296,7 @@ func parseAddrOverview(view interface{}) (interface{}, error) {
res
:=
view
.
(
*
types
.
AddrOverview
)
res
:=
view
.
(
*
types
.
AddrOverview
)
balance
:=
strconv
.
FormatFloat
(
float64
(
res
.
GetBalance
())
/
float64
(
types
.
Coin
),
'f'
,
4
,
64
)
balance
:=
strconv
.
FormatFloat
(
float64
(
res
.
GetBalance
())
/
float64
(
types
.
Coin
),
'f'
,
4
,
64
)
receiver
:=
strconv
.
FormatFloat
(
float64
(
res
.
GetReciver
())
/
float64
(
types
.
Coin
),
'f'
,
4
,
64
)
receiver
:=
strconv
.
FormatFloat
(
float64
(
res
.
GetReciver
())
/
float64
(
types
.
Coin
),
'f'
,
4
,
64
)
addrOverview
:=
&
AddrOverviewResult
{
addrOverview
:=
&
commandtypes
.
AddrOverviewResult
{
Balance
:
balance
,
Balance
:
balance
,
Receiver
:
receiver
,
Receiver
:
receiver
,
TxCount
:
res
.
GetTxCount
(),
TxCount
:
res
.
GetTxCount
(),
...
...
vendor/github.com/33cn/chain33/system/dapp/commands/types/types.go
View file @
e8a09f64
...
@@ -156,7 +156,7 @@ type GetTicketStatisticResult struct {
...
@@ -156,7 +156,7 @@ type GetTicketStatisticResult struct {
// GetTicketMinerInfoResult defines ticker minerinformation result rpc command
// GetTicketMinerInfoResult defines ticker minerinformation result rpc command
type
GetTicketMinerInfoResult
struct
{
type
GetTicketMinerInfoResult
struct
{
TicketI
d
string
`json:"ticketId"`
TicketI
D
string
`json:"ticketId"`
Status
string
`json:"status"`
Status
string
`json:"status"`
PrevStatus
string
`json:"prevStatus"`
PrevStatus
string
`json:"prevStatus"`
IsGenesis
bool
`json:"isGenesis"`
IsGenesis
bool
`json:"isGenesis"`
...
@@ -256,7 +256,7 @@ type HashlockLockCLI struct {
...
@@ -256,7 +256,7 @@ type HashlockLockCLI struct {
type
TicketMinerCLI
struct
{
type
TicketMinerCLI
struct
{
Bits
uint32
`json:"bits,omitempty"`
Bits
uint32
`json:"bits,omitempty"`
Reward
string
`json:"reward,omitempty"`
Reward
string
`json:"reward,omitempty"`
TicketI
d
string
`json:"ticketId,omitempty"`
TicketI
D
string
`json:"ticketId,omitempty"`
Modify
[]
byte
`json:"modify,omitempty"`
Modify
[]
byte
`json:"modify,omitempty"`
}
}
...
...
vendor/github.com/33cn/chain33/system/dapp/commands/types/utils.go
View file @
e8a09f64
...
@@ -71,7 +71,7 @@ func SendToAddress(rpcAddr string, from string, to string, amount int64, note st
...
@@ -71,7 +71,7 @@ func SendToAddress(rpcAddr string, from string, to string, amount int64, note st
}
}
var
res
rpctypes
.
ReplyHash
var
res
rpctypes
.
ReplyHash
ctx
:=
jsonclient
.
NewR
pc
Ctx
(
rpcAddr
,
"Chain33.SendToAddress"
,
params
,
&
res
)
ctx
:=
jsonclient
.
NewR
PC
Ctx
(
rpcAddr
,
"Chain33.SendToAddress"
,
params
,
&
res
)
ctx
.
Run
()
ctx
.
Run
()
}
}
...
...
vendor/github.com/33cn/chain33/system/dapp/commands/version.go
View file @
e8a09f64
...
@@ -23,6 +23,6 @@ func VersionCmd() *cobra.Command {
...
@@ -23,6 +23,6 @@ func VersionCmd() *cobra.Command {
func
version
(
cmd
*
cobra
.
Command
,
args
[]
string
)
{
func
version
(
cmd
*
cobra
.
Command
,
args
[]
string
)
{
rpcLaddr
,
_
:=
cmd
.
Flags
()
.
GetString
(
"rpc_laddr"
)
rpcLaddr
,
_
:=
cmd
.
Flags
()
.
GetString
(
"rpc_laddr"
)
ctx
:=
jsonclient
.
NewR
pc
Ctx
(
rpcLaddr
,
"Chain33.Version"
,
nil
,
nil
)
ctx
:=
jsonclient
.
NewR
PC
Ctx
(
rpcLaddr
,
"Chain33.Version"
,
nil
,
nil
)
ctx
.
RunWithoutMarshal
()
ctx
.
RunWithoutMarshal
()
}
}
vendor/github.com/33cn/chain33/system/dapp/commands/wallet.go
View file @
e8a09f64
...
@@ -14,7 +14,7 @@ import (
...
@@ -14,7 +14,7 @@ import (
"github.com/33cn/chain33/rpc/jsonclient"
"github.com/33cn/chain33/rpc/jsonclient"
rpctypes
"github.com/33cn/chain33/rpc/types"
rpctypes
"github.com/33cn/chain33/rpc/types"
.
"github.com/33cn/chain33/system/dapp/commands/types"
commandtypes
"github.com/33cn/chain33/system/dapp/commands/types"
"github.com/33cn/chain33/types"
"github.com/33cn/chain33/types"
"github.com/spf13/cobra"
"github.com/spf13/cobra"
)
)
...
@@ -57,7 +57,7 @@ func LockCmd() *cobra.Command {
...
@@ -57,7 +57,7 @@ func LockCmd() *cobra.Command {
func
lock
(
cmd
*
cobra
.
Command
,
args
[]
string
)
{
func
lock
(
cmd
*
cobra
.
Command
,
args
[]
string
)
{
rpcLaddr
,
_
:=
cmd
.
Flags
()
.
GetString
(
"rpc_laddr"
)
rpcLaddr
,
_
:=
cmd
.
Flags
()
.
GetString
(
"rpc_laddr"
)
var
res
rpctypes
.
Reply
var
res
rpctypes
.
Reply
ctx
:=
jsonclient
.
NewR
pc
Ctx
(
rpcLaddr
,
"Chain33.Lock"
,
nil
,
&
res
)
ctx
:=
jsonclient
.
NewR
PC
Ctx
(
rpcLaddr
,
"Chain33.Lock"
,
nil
,
&
res
)
ctx
.
Run
()
ctx
.
Run
()
}
}
...
@@ -102,7 +102,7 @@ func unLock(cmd *cobra.Command, args []string) {
...
@@ -102,7 +102,7 @@ func unLock(cmd *cobra.Command, args []string) {
WalletOrTicket
:
walletOrTicket
,
WalletOrTicket
:
walletOrTicket
,
}
}
var
res
rpctypes
.
Reply
var
res
rpctypes
.
Reply
ctx
:=
jsonclient
.
NewR
pc
Ctx
(
rpcLaddr
,
"Chain33.UnLock"
,
params
,
&
res
)
ctx
:=
jsonclient
.
NewR
PC
Ctx
(
rpcLaddr
,
"Chain33.UnLock"
,
params
,
&
res
)
ctx
.
Run
()
ctx
.
Run
()
}
}
...
@@ -119,7 +119,7 @@ func WalletStatusCmd() *cobra.Command {
...
@@ -119,7 +119,7 @@ func WalletStatusCmd() *cobra.Command {
func
walletStatus
(
cmd
*
cobra
.
Command
,
args
[]
string
)
{
func
walletStatus
(
cmd
*
cobra
.
Command
,
args
[]
string
)
{
rpcLaddr
,
_
:=
cmd
.
Flags
()
.
GetString
(
"rpc_laddr"
)
rpcLaddr
,
_
:=
cmd
.
Flags
()
.
GetString
(
"rpc_laddr"
)
var
res
rpctypes
.
WalletStatus
var
res
rpctypes
.
WalletStatus
ctx
:=
jsonclient
.
NewR
pc
Ctx
(
rpcLaddr
,
"Chain33.GetWalletStatus"
,
nil
,
&
res
)
ctx
:=
jsonclient
.
NewR
PC
Ctx
(
rpcLaddr
,
"Chain33.GetWalletStatus"
,
nil
,
&
res
)
ctx
.
Run
()
ctx
.
Run
()
}
}
...
@@ -151,7 +151,7 @@ func setPwd(cmd *cobra.Command, args []string) {
...
@@ -151,7 +151,7 @@ func setPwd(cmd *cobra.Command, args []string) {
NewPass
:
newPwd
,
NewPass
:
newPwd
,
}
}
var
res
rpctypes
.
Reply
var
res
rpctypes
.
Reply
ctx
:=
jsonclient
.
NewR
pc
Ctx
(
rpcLaddr
,
"Chain33.SetPasswd"
,
params
,
&
res
)
ctx
:=
jsonclient
.
NewR
PC
Ctx
(
rpcLaddr
,
"Chain33.SetPasswd"
,
params
,
&
res
)
ctx
.
Run
()
ctx
.
Run
()
}
}
...
@@ -187,18 +187,18 @@ func walletListTxs(cmd *cobra.Command, args []string) {
...
@@ -187,18 +187,18 @@ func walletListTxs(cmd *cobra.Command, args []string) {
Direction
:
direction
,
Direction
:
direction
,
}
}
var
res
rpctypes
.
WalletTxDetails
var
res
rpctypes
.
WalletTxDetails
ctx
:=
jsonclient
.
NewR
pc
Ctx
(
rpcLaddr
,
"Chain33.WalletTxList"
,
params
,
&
res
)
ctx
:=
jsonclient
.
NewR
PC
Ctx
(
rpcLaddr
,
"Chain33.WalletTxList"
,
params
,
&
res
)
ctx
.
SetResultCb
(
parseWalletTxListRes
)
ctx
.
SetResultCb
(
parseWalletTxListRes
)
ctx
.
Run
()
ctx
.
Run
()
}
}
func
parseWalletTxListRes
(
arg
interface
{})
(
interface
{},
error
)
{
func
parseWalletTxListRes
(
arg
interface
{})
(
interface
{},
error
)
{
res
:=
arg
.
(
*
rpctypes
.
WalletTxDetails
)
res
:=
arg
.
(
*
rpctypes
.
WalletTxDetails
)
var
result
WalletTxDetailsResult
var
result
commandtypes
.
WalletTxDetailsResult
for
_
,
v
:=
range
res
.
TxDetails
{
for
_
,
v
:=
range
res
.
TxDetails
{
amountResult
:=
strconv
.
FormatFloat
(
float64
(
v
.
Amount
)
/
float64
(
types
.
Coin
),
'f'
,
4
,
64
)
amountResult
:=
strconv
.
FormatFloat
(
float64
(
v
.
Amount
)
/
float64
(
types
.
Coin
),
'f'
,
4
,
64
)
wtxd
:=
&
WalletTxDetailResult
{
wtxd
:=
&
commandtypes
.
WalletTxDetailResult
{
Tx
:
DecodeTransaction
(
v
.
Tx
),
Tx
:
commandtypes
.
DecodeTransaction
(
v
.
Tx
),
Receipt
:
v
.
Receipt
,
Receipt
:
v
.
Receipt
,
Height
:
v
.
Height
,
Height
:
v
.
Height
,
Index
:
v
.
Index
,
Index
:
v
.
Index
,
...
@@ -236,7 +236,7 @@ func mergeBalance(cmd *cobra.Command, args []string) {
...
@@ -236,7 +236,7 @@ func mergeBalance(cmd *cobra.Command, args []string) {
To
:
toAddr
,
To
:
toAddr
,
}
}
var
res
rpctypes
.
ReplyHashes
var
res
rpctypes
.
ReplyHashes
ctx
:=
jsonclient
.
NewR
pc
Ctx
(
rpcLaddr
,
"Chain33.MergeBalance"
,
params
,
&
res
)
ctx
:=
jsonclient
.
NewR
PC
Ctx
(
rpcLaddr
,
"Chain33.MergeBalance"
,
params
,
&
res
)
ctx
.
Run
()
ctx
.
Run
()
}
}
...
@@ -269,7 +269,7 @@ func autoMine(cmd *cobra.Command, args []string) {
...
@@ -269,7 +269,7 @@ func autoMine(cmd *cobra.Command, args []string) {
Flag
:
flag
,
Flag
:
flag
,
}
}
var
res
rpctypes
.
Reply
var
res
rpctypes
.
Reply
ctx
:=
jsonclient
.
NewR
pc
Ctx
(
rpcLaddr
,
"ticket.SetAutoMining"
,
params
,
&
res
)
ctx
:=
jsonclient
.
NewR
PC
Ctx
(
rpcLaddr
,
"ticket.SetAutoMining"
,
params
,
&
res
)
ctx
.
Run
()
ctx
.
Run
()
}
}
...
@@ -338,7 +338,7 @@ func noBalanceTx(cmd *cobra.Command, args []string) {
...
@@ -338,7 +338,7 @@ func noBalanceTx(cmd *cobra.Command, args []string) {
Expire
:
expire
,
Expire
:
expire
,
Privkey
:
privkey
,
Privkey
:
privkey
,
}
}
ctx
:=
jsonclient
.
NewR
pc
Ctx
(
rpcLaddr
,
"Chain33.CreateNoBalanceTransaction"
,
params
,
nil
)
ctx
:=
jsonclient
.
NewR
PC
Ctx
(
rpcLaddr
,
"Chain33.CreateNoBalanceTransaction"
,
params
,
nil
)
ctx
.
RunWithoutMarshal
()
ctx
.
RunWithoutMarshal
()
}
}
...
@@ -414,7 +414,7 @@ func signRawTx(cmd *cobra.Command, args []string) {
...
@@ -414,7 +414,7 @@ func signRawTx(cmd *cobra.Command, args []string) {
Expire
:
expire
,
Expire
:
expire
,
Index
:
index
,
Index
:
index
,
}
}
ctx
:=
jsonclient
.
NewR
pc
Ctx
(
rpcLaddr
,
"Chain33.SignRawTx"
,
params
,
nil
)
ctx
:=
jsonclient
.
NewR
PC
Ctx
(
rpcLaddr
,
"Chain33.SignRawTx"
,
params
,
nil
)
ctx
.
RunWithoutMarshal
()
ctx
.
RunWithoutMarshal
()
}
}
...
@@ -442,7 +442,7 @@ func setFee(cmd *cobra.Command, args []string) {
...
@@ -442,7 +442,7 @@ func setFee(cmd *cobra.Command, args []string) {
Amount
:
amountInt64
*
1e4
,
Amount
:
amountInt64
*
1e4
,
}
}
var
res
rpctypes
.
Reply
var
res
rpctypes
.
Reply
ctx
:=
jsonclient
.
NewR
pc
Ctx
(
rpcLaddr
,
"Chain33.SetTxFee"
,
params
,
&
res
)
ctx
:=
jsonclient
.
NewR
PC
Ctx
(
rpcLaddr
,
"Chain33.SetTxFee"
,
params
,
&
res
)
ctx
.
Run
()
ctx
.
Run
()
}
}
...
@@ -473,6 +473,6 @@ func sendTx(cmd *cobra.Command, args []string) {
...
@@ -473,6 +473,6 @@ func sendTx(cmd *cobra.Command, args []string) {
Data
:
data
,
Data
:
data
,
}
}
ctx
:=
jsonclient
.
NewR
pc
Ctx
(
rpcLaddr
,
"Chain33.SendTransaction"
,
params
,
nil
)
ctx
:=
jsonclient
.
NewR
PC
Ctx
(
rpcLaddr
,
"Chain33.SendTransaction"
,
params
,
nil
)
ctx
.
RunWithoutMarshal
()
ctx
.
RunWithoutMarshal
()
}
}
vendor/github.com/33cn/chain33/system/dapp/driver.go
View file @
e8a09f64
...
@@ -53,7 +53,7 @@ type Driver interface {
...
@@ -53,7 +53,7 @@ type Driver interface {
ExecDelLocal
(
tx
*
types
.
Transaction
,
receipt
*
types
.
ReceiptData
,
index
int
)
(
*
types
.
LocalDBSet
,
error
)
ExecDelLocal
(
tx
*
types
.
Transaction
,
receipt
*
types
.
ReceiptData
,
index
int
)
(
*
types
.
LocalDBSet
,
error
)
Query
(
funcName
string
,
params
[]
byte
)
(
types
.
Message
,
error
)
Query
(
funcName
string
,
params
[]
byte
)
(
types
.
Message
,
error
)
IsFree
()
bool
IsFree
()
bool
SetA
pi
(
client
.
QueueProtocolAPI
)
SetA
PI
(
client
.
QueueProtocolAPI
)
SetTxs
(
txs
[]
*
types
.
Transaction
)
SetTxs
(
txs
[]
*
types
.
Transaction
)
SetReceipt
(
receipts
[]
*
types
.
ReceiptData
)
SetReceipt
(
receipts
[]
*
types
.
ReceiptData
)
...
@@ -63,6 +63,7 @@ type Driver interface {
...
@@ -63,6 +63,7 @@ type Driver interface {
GetPayloadValue
()
types
.
Message
GetPayloadValue
()
types
.
Message
GetFuncMap
()
map
[
string
]
reflect
.
Method
GetFuncMap
()
map
[
string
]
reflect
.
Method
GetExecutorType
()
types
.
ExecutorType
GetExecutorType
()
types
.
ExecutorType
CheckReceiptExecOk
()
bool
}
}
// DriverBase defines driverbase type
// DriverBase defines driverbase type
...
@@ -105,13 +106,13 @@ func (d *DriverBase) GetFuncMap() map[string]reflect.Method {
...
@@ -105,13 +106,13 @@ func (d *DriverBase) GetFuncMap() map[string]reflect.Method {
return
d
.
ety
.
GetExecFuncMap
()
return
d
.
ety
.
GetExecFuncMap
()
}
}
// SetA
pi
set queue protocol api
// SetA
PI
set queue protocol api
func
(
d
*
DriverBase
)
SetA
pi
(
api
client
.
QueueProtocolAPI
)
{
func
(
d
*
DriverBase
)
SetA
PI
(
api
client
.
QueueProtocolAPI
)
{
d
.
api
=
api
d
.
api
=
api
}
}
// GetA
pi
return queue protocol api
// GetA
PI
return queue protocol api
func
(
d
*
DriverBase
)
GetA
pi
()
client
.
QueueProtocolAPI
{
func
(
d
*
DriverBase
)
GetA
PI
()
client
.
QueueProtocolAPI
{
return
d
.
api
return
d
.
api
}
}
...
@@ -177,6 +178,13 @@ func (d *DriverBase) callLocal(prefix string, tx *types.Transaction, receipt *ty
...
@@ -177,6 +178,13 @@ func (d *DriverBase) callLocal(prefix string, tx *types.Transaction, receipt *ty
if
d
.
ety
==
nil
{
if
d
.
ety
==
nil
{
return
nil
,
types
.
ErrActionNotSupport
return
nil
,
types
.
ErrActionNotSupport
}
}
if
d
.
child
.
CheckReceiptExecOk
()
{
if
receipt
.
GetTy
()
!=
types
.
ExecOk
{
return
&
types
.
LocalDBSet
{},
nil
}
}
defer
func
()
{
defer
func
()
{
if
r
:=
recover
();
r
!=
nil
{
if
r
:=
recover
();
r
!=
nil
{
blog
.
Error
(
"call localexec error"
,
"prefix"
,
prefix
,
"tx.exec"
,
tx
.
Execer
,
"info"
,
r
)
blog
.
Error
(
"call localexec error"
,
"prefix"
,
prefix
,
"tx.exec"
,
tx
.
Execer
,
"info"
,
r
)
...
@@ -416,3 +424,8 @@ func (d *DriverBase) GetTxs() []*types.Transaction {
...
@@ -416,3 +424,8 @@ func (d *DriverBase) GetTxs() []*types.Transaction {
func
(
d
*
DriverBase
)
SetTxs
(
txs
[]
*
types
.
Transaction
)
{
func
(
d
*
DriverBase
)
SetTxs
(
txs
[]
*
types
.
Transaction
)
{
d
.
txs
=
txs
d
.
txs
=
txs
}
}
// CheckReceiptExecOk default return true to check if receipt ty is ok, for specific plugin can overwrite it self
func
(
d
*
DriverBase
)
CheckReceiptExecOk
()
bool
{
return
false
}
vendor/github.com/33cn/chain33/system/dapp/manage/commands/config.go
View file @
e8a09f64
...
@@ -107,6 +107,6 @@ func queryConfig(cmd *cobra.Command, args []string) {
...
@@ -107,6 +107,6 @@ func queryConfig(cmd *cobra.Command, args []string) {
params
.
Payload
=
req
params
.
Payload
=
req
var
res
types
.
ReplyConfig
var
res
types
.
ReplyConfig
ctx
:=
jsonclient
.
NewR
pc
Ctx
(
rpcLaddr
,
"Chain33.Query"
,
params
,
&
res
)
ctx
:=
jsonclient
.
NewR
PC
Ctx
(
rpcLaddr
,
"Chain33.Query"
,
params
,
&
res
)
ctx
.
Run
()
ctx
.
Run
()
}
}
vendor/github.com/33cn/chain33/system/dapp/manage/executor/exec_del_local.go
View file @
e8a09f64
...
@@ -18,9 +18,6 @@ func localKey(key string) []byte {
...
@@ -18,9 +18,6 @@ func localKey(key string) []byte {
// ExecDelLocal_Modify defines execdellocal modify func
// ExecDelLocal_Modify defines execdellocal modify func
func
(
c
*
Manage
)
ExecDelLocal_Modify
(
transfer
*
types
.
ModifyConfig
,
tx
*
types
.
Transaction
,
receipt
*
types
.
ReceiptData
,
index
int
)
(
*
types
.
LocalDBSet
,
error
)
{
func
(
c
*
Manage
)
ExecDelLocal_Modify
(
transfer
*
types
.
ModifyConfig
,
tx
*
types
.
Transaction
,
receipt
*
types
.
ReceiptData
,
index
int
)
(
*
types
.
LocalDBSet
,
error
)
{
set
:=
&
types
.
LocalDBSet
{}
set
:=
&
types
.
LocalDBSet
{}
if
receipt
.
GetTy
()
!=
types
.
ExecOk
{
return
set
,
nil
}
for
i
:=
0
;
i
<
len
(
receipt
.
Logs
);
i
++
{
for
i
:=
0
;
i
<
len
(
receipt
.
Logs
);
i
++
{
item
:=
receipt
.
Logs
[
i
]
item
:=
receipt
.
Logs
[
i
]
...
...
vendor/github.com/33cn/chain33/system/dapp/manage/executor/exec_local.go
View file @
e8a09f64
...
@@ -12,10 +12,6 @@ import (
...
@@ -12,10 +12,6 @@ import (
// ExecLocal_Modify defines execlocal modify func
// ExecLocal_Modify defines execlocal modify func
func
(
c
*
Manage
)
ExecLocal_Modify
(
transfer
*
types
.
ModifyConfig
,
tx
*
types
.
Transaction
,
receipt
*
types
.
ReceiptData
,
index
int
)
(
*
types
.
LocalDBSet
,
error
)
{
func
(
c
*
Manage
)
ExecLocal_Modify
(
transfer
*
types
.
ModifyConfig
,
tx
*
types
.
Transaction
,
receipt
*
types
.
ReceiptData
,
index
int
)
(
*
types
.
LocalDBSet
,
error
)
{
set
:=
&
types
.
LocalDBSet
{}
set
:=
&
types
.
LocalDBSet
{}
if
receipt
.
GetTy
()
!=
types
.
ExecOk
{
return
set
,
nil
}
for
i
:=
0
;
i
<
len
(
receipt
.
Logs
);
i
++
{
for
i
:=
0
;
i
<
len
(
receipt
.
Logs
);
i
++
{
item
:=
receipt
.
Logs
[
i
]
item
:=
receipt
.
Logs
[
i
]
if
item
.
Ty
==
pty
.
ManageActionModifyConfig
{
if
item
.
Ty
==
pty
.
ManageActionModifyConfig
{
...
...
vendor/github.com/33cn/chain33/system/dapp/manage/executor/manage.go
View file @
e8a09f64
...
@@ -69,3 +69,8 @@ func IsSuperManager(addr string) bool {
...
@@ -69,3 +69,8 @@ func IsSuperManager(addr string) bool {
}
}
return
false
return
false
}
}
// CheckReceiptExecOk return true to check if receipt ty is ok
func
(
c
*
Manage
)
CheckReceiptExecOk
()
bool
{
return
true
}
vendor/github.com/33cn/chain33/system/store/mavl/db/prune.go
View file @
e8a09f64
This diff is collapsed.
Click to expand it.
vendor/github.com/33cn/chain33/system/store/mavl/mavl_test.go
View file @
e8a09f64
...
@@ -252,6 +252,7 @@ func TestIterateCallBack_Mode1(t *testing.T) {
...
@@ -252,6 +252,7 @@ func TestIterateCallBack_Mode1(t *testing.T) {
KV
:
accountdb
.
GetExecKVSet
(
execAddr1
,
acc
),
KV
:
accountdb
.
GetExecKVSet
(
execAddr1
,
acc
),
Height
:
0
}
Height
:
0
}
hash0
,
err
:=
store
.
Set
(
datas
,
true
)
hash0
,
err
:=
store
.
Set
(
datas
,
true
)
assert
.
Nil
(
t
,
err
)
execAddr2
:=
"26htvcBNSEA7fZhAdLJphDwQRQJaHpyHTp"
execAddr2
:=
"26htvcBNSEA7fZhAdLJphDwQRQJaHpyHTp"
datas
=
&
types
.
StoreSet
{
datas
=
&
types
.
StoreSet
{
...
@@ -259,6 +260,7 @@ func TestIterateCallBack_Mode1(t *testing.T) {
...
@@ -259,6 +260,7 @@ func TestIterateCallBack_Mode1(t *testing.T) {
KV
:
accountdb
.
GetExecKVSet
(
execAddr2
,
acc
),
KV
:
accountdb
.
GetExecKVSet
(
execAddr2
,
acc
),
Height
:
1
}
Height
:
1
}
hash1
,
err
:=
store
.
Set
(
datas
,
true
)
hash1
,
err
:=
store
.
Set
(
datas
,
true
)
assert
.
Nil
(
t
,
err
)
execAddr3
:=
"36htvcBNSEA7fZhAdLJphDwQRQJaHpyHTp"
execAddr3
:=
"36htvcBNSEA7fZhAdLJphDwQRQJaHpyHTp"
datas
=
&
types
.
StoreSet
{
datas
=
&
types
.
StoreSet
{
...
@@ -393,6 +395,7 @@ func TestIterateCallBack_Mode2(t *testing.T) {
...
@@ -393,6 +395,7 @@ func TestIterateCallBack_Mode2(t *testing.T) {
KV
:
accountdb
.
GetExecKVSet
(
execAddr1
,
acc
),
KV
:
accountdb
.
GetExecKVSet
(
execAddr1
,
acc
),
Height
:
0
}
Height
:
0
}
hash0
,
err
:=
store
.
Set
(
datas
,
true
)
hash0
,
err
:=
store
.
Set
(
datas
,
true
)
assert
.
Nil
(
t
,
err
)
execAddr2
:=
"26htvcBNSEA7fZhAdLJphDwQRQJaHpyHTp"
execAddr2
:=
"26htvcBNSEA7fZhAdLJphDwQRQJaHpyHTp"
datas
=
&
types
.
StoreSet
{
datas
=
&
types
.
StoreSet
{
...
@@ -400,6 +403,7 @@ func TestIterateCallBack_Mode2(t *testing.T) {
...
@@ -400,6 +403,7 @@ func TestIterateCallBack_Mode2(t *testing.T) {
KV
:
accountdb
.
GetExecKVSet
(
execAddr2
,
acc
),
KV
:
accountdb
.
GetExecKVSet
(
execAddr2
,
acc
),
Height
:
1
}
Height
:
1
}
hash1
,
err
:=
store
.
Set
(
datas
,
true
)
hash1
,
err
:=
store
.
Set
(
datas
,
true
)
assert
.
Nil
(
t
,
err
)
execAddr3
:=
"36htvcBNSEA7fZhAdLJphDwQRQJaHpyHTp"
execAddr3
:=
"36htvcBNSEA7fZhAdLJphDwQRQJaHpyHTp"
datas
=
&
types
.
StoreSet
{
datas
=
&
types
.
StoreSet
{
...
...
vendor/github.com/33cn/chain33/types/config.go
View file @
e8a09f64
...
@@ -443,7 +443,7 @@ func mergeCfgString(cfgstring, cfgdefault string) string {
...
@@ -443,7 +443,7 @@ func mergeCfgString(cfgstring, cfgdefault string) string {
panic
(
errstr
)
panic
(
errstr
)
}
}
buf
:=
new
(
bytes
.
Buffer
)
buf
:=
new
(
bytes
.
Buffer
)
err
=
tml
.
NewEncoder
(
buf
)
.
Encode
(
conf
)
tml
.
NewEncoder
(
buf
)
.
Encode
(
conf
)
return
buf
.
String
()
return
buf
.
String
()
}
}
...
...
vendor/github.com/33cn/chain33/types/types.go
View file @
e8a09f64
...
@@ -369,7 +369,7 @@ func (r *ReceiptData) DecodeReceiptLog(execer []byte) (*ReceiptDataResult, error
...
@@ -369,7 +369,7 @@ func (r *ReceiptData) DecodeReceiptLog(execer []byte) (*ReceiptDataResult, error
return
nil
,
ErrLogType
return
nil
,
ErrLogType
}
}
logIns
,
err
=
logType
.
Decode
(
lLog
)
logIns
,
_
=
logType
.
Decode
(
lLog
)
lTy
=
logType
.
Name
()
lTy
=
logType
.
Name
()
result
.
Logs
=
append
(
result
.
Logs
,
&
ReceiptLogResult
{
Ty
:
l
.
Ty
,
TyName
:
lTy
,
Log
:
logIns
,
RawLog
:
common
.
ToHex
(
l
.
GetLog
())})
result
.
Logs
=
append
(
result
.
Logs
,
&
ReceiptLogResult
{
Ty
:
l
.
Ty
,
TyName
:
lTy
,
Log
:
logIns
,
RawLog
:
common
.
ToHex
(
l
.
GetLog
())})
...
...
vendor/github.com/33cn/chain33/util/cli/cli.go
View file @
e8a09f64
...
@@ -36,7 +36,7 @@ var closeCmd = &cobra.Command{
...
@@ -36,7 +36,7 @@ var closeCmd = &cobra.Command{
// rpc, _ := jsonrpc.NewJSONClient(rpcLaddr)
// rpc, _ := jsonrpc.NewJSONClient(rpcLaddr)
// rpc.Call("Chain33.CloseQueue", nil, nil)
// rpc.Call("Chain33.CloseQueue", nil, nil)
var
res
rpctypes
.
Reply
var
res
rpctypes
.
Reply
ctx
:=
jsonclient
.
NewR
pc
Ctx
(
rpcLaddr
,
"Chain33.CloseQueue"
,
nil
,
&
res
)
ctx
:=
jsonclient
.
NewR
PC
Ctx
(
rpcLaddr
,
"Chain33.CloseQueue"
,
nil
,
&
res
)
ctx
.
Run
()
ctx
.
Run
()
},
},
}
}
...
...
vendor/github.com/33cn/chain33/util/exec.go
View file @
e8a09f64
...
@@ -74,6 +74,7 @@ func ExecKVSetCommit(client queue.Client, hash []byte) error {
...
@@ -74,6 +74,7 @@ func ExecKVSetCommit(client queue.Client, hash []byte) error {
return
err
return
err
}
}
hash
=
msg
.
GetData
()
.
(
*
types
.
ReplyHash
)
.
GetHash
()
hash
=
msg
.
GetData
()
.
(
*
types
.
ReplyHash
)
.
GetHash
()
_
=
hash
return
nil
return
nil
}
}
...
@@ -87,6 +88,7 @@ func ExecKVSetRollback(client queue.Client, hash []byte) error {
...
@@ -87,6 +88,7 @@ func ExecKVSetRollback(client queue.Client, hash []byte) error {
return
err
return
err
}
}
hash
=
msg
.
GetData
()
.
(
*
types
.
ReplyHash
)
.
GetHash
()
hash
=
msg
.
GetData
()
.
(
*
types
.
ReplyHash
)
.
GetHash
()
_
=
hash
return
nil
return
nil
}
}
...
...
vendor/github.com/33cn/chain33/util/util_test.go
View file @
e8a09f64
...
@@ -20,7 +20,7 @@ func TestMakeStringUpper(t *testing.T) {
...
@@ -20,7 +20,7 @@ func TestMakeStringUpper(t *testing.T) {
assert
.
NoError
(
t
,
err
)
assert
.
NoError
(
t
,
err
)
assert
.
Equal
(
t
,
"abCDefg"
,
destStr
)
assert
.
Equal
(
t
,
"abCDefg"
,
destStr
)
destStr
,
err
=
MakeStringToUpper
(
originStr
,
-
1
,
2
)
_
,
err
=
MakeStringToUpper
(
originStr
,
-
1
,
2
)
assert
.
Error
(
t
,
err
)
assert
.
Error
(
t
,
err
)
}
}
...
@@ -34,6 +34,6 @@ func TestMakeStringLower(t *testing.T) {
...
@@ -34,6 +34,6 @@ func TestMakeStringLower(t *testing.T) {
assert
.
NoError
(
t
,
err
)
assert
.
NoError
(
t
,
err
)
assert
.
Equal
(
t
,
"ABcdEFG"
,
destStr
)
assert
.
Equal
(
t
,
"ABcdEFG"
,
destStr
)
destStr
,
err
=
MakeStringToLower
(
originStr
,
-
1
,
2
)
_
,
err
=
MakeStringToLower
(
originStr
,
-
1
,
2
)
assert
.
Error
(
t
,
err
)
assert
.
Error
(
t
,
err
)
}
}
vendor/github.com/33cn/chain33/wallet/wallet_proc.go
View file @
e8a09f64
...
@@ -258,7 +258,7 @@ func (wallet *Wallet) ProcCreateNewAccount(Label *types.ReqNewAccount) (*types.W
...
@@ -258,7 +258,7 @@ func (wallet *Wallet) ProcCreateNewAccount(Label *types.ReqNewAccount) (*types.W
}
}
//首先校验label是否已被使用
//首先校验label是否已被使用
WalletAccStores
,
err
:=
wallet
.
walletStore
.
GetAccountByLabel
(
Label
.
GetLabel
())
WalletAccStores
,
_
:=
wallet
.
walletStore
.
GetAccountByLabel
(
Label
.
GetLabel
())
if
WalletAccStores
!=
nil
{
if
WalletAccStores
!=
nil
{
walletlog
.
Error
(
"ProcCreateNewAccount Label is exist in wallet!"
)
walletlog
.
Error
(
"ProcCreateNewAccount Label is exist in wallet!"
)
return
nil
,
types
.
ErrLabelHasUsed
return
nil
,
types
.
ErrLabelHasUsed
...
@@ -310,7 +310,7 @@ func (wallet *Wallet) ProcCreateNewAccount(Label *types.ReqNewAccount) (*types.W
...
@@ -310,7 +310,7 @@ func (wallet *Wallet) ProcCreateNewAccount(Label *types.ReqNewAccount) (*types.W
}
}
//通过新生成的账户地址查询钱包数据库,如果查询返回的账户信息是空,
//通过新生成的账户地址查询钱包数据库,如果查询返回的账户信息是空,
//说明新生成的账户没有被使用,否则继续使用下一个index生成私钥对
//说明新生成的账户没有被使用,否则继续使用下一个index生成私钥对
account
,
err
:=
wallet
.
walletStore
.
GetAccountByAddr
(
addr
)
account
,
_
:=
wallet
.
walletStore
.
GetAccountByAddr
(
addr
)
if
account
==
nil
{
if
account
==
nil
{
break
break
}
}
...
@@ -417,7 +417,7 @@ func (wallet *Wallet) ProcImportPrivKey(PrivKey *types.ReqWalletImportPrivkey) (
...
@@ -417,7 +417,7 @@ func (wallet *Wallet) ProcImportPrivKey(PrivKey *types.ReqWalletImportPrivkey) (
}
}
//校验label是否已经被使用
//校验label是否已经被使用
Account
,
err
:=
wallet
.
walletStore
.
GetAccountByLabel
(
PrivKey
.
GetLabel
())
Account
,
_
:=
wallet
.
walletStore
.
GetAccountByLabel
(
PrivKey
.
GetLabel
())
if
Account
!=
nil
{
if
Account
!=
nil
{
walletlog
.
Error
(
"ProcImportPrivKey Label is exist in wallet!"
)
walletlog
.
Error
(
"ProcImportPrivKey Label is exist in wallet!"
)
return
nil
,
types
.
ErrLabelHasUsed
return
nil
,
types
.
ErrLabelHasUsed
...
@@ -453,7 +453,7 @@ func (wallet *Wallet) ProcImportPrivKey(PrivKey *types.ReqWalletImportPrivkey) (
...
@@ -453,7 +453,7 @@ func (wallet *Wallet) ProcImportPrivKey(PrivKey *types.ReqWalletImportPrivkey) (
Encryptered
:=
wcom
.
CBCEncrypterPrivkey
([]
byte
(
wallet
.
Password
),
privkeybyte
)
Encryptered
:=
wcom
.
CBCEncrypterPrivkey
([]
byte
(
wallet
.
Password
),
privkeybyte
)
Encrypteredstr
:=
common
.
ToHex
(
Encryptered
)
Encrypteredstr
:=
common
.
ToHex
(
Encryptered
)
//校验PrivKey对应的addr是否已经存在钱包中
//校验PrivKey对应的addr是否已经存在钱包中
Account
,
err
=
wallet
.
walletStore
.
GetAccountByAddr
(
addr
)
Account
,
_
=
wallet
.
walletStore
.
GetAccountByAddr
(
addr
)
if
Account
!=
nil
{
if
Account
!=
nil
{
if
Account
.
Privkey
==
Encrypteredstr
{
if
Account
.
Privkey
==
Encrypteredstr
{
walletlog
.
Error
(
"ProcImportPrivKey Privkey is exist in wallet!"
)
walletlog
.
Error
(
"ProcImportPrivKey Privkey is exist in wallet!"
)
...
@@ -613,13 +613,13 @@ func (wallet *Wallet) ProcWalletSetLabel(SetLabel *types.ReqWalletSetLabel) (*ty
...
@@ -613,13 +613,13 @@ func (wallet *Wallet) ProcWalletSetLabel(SetLabel *types.ReqWalletSetLabel) (*ty
return
nil
,
types
.
ErrInvalidParam
return
nil
,
types
.
ErrInvalidParam
}
}
//校验label是否已经被使用
//校验label是否已经被使用
Account
,
err
:=
wallet
.
walletStore
.
GetAccountByLabel
(
SetLabel
.
GetLabel
())
Account
,
_
:=
wallet
.
walletStore
.
GetAccountByLabel
(
SetLabel
.
GetLabel
())
if
Account
!=
nil
{
if
Account
!=
nil
{
walletlog
.
Error
(
"ProcWalletSetLabel Label is exist in wallet!"
)
walletlog
.
Error
(
"ProcWalletSetLabel Label is exist in wallet!"
)
return
nil
,
types
.
ErrLabelHasUsed
return
nil
,
types
.
ErrLabelHasUsed
}
}
//获取地址对应的账户信息从钱包中,然后修改label
//获取地址对应的账户信息从钱包中,然后修改label
Account
,
err
=
wallet
.
walletStore
.
GetAccountByAddr
(
SetLabel
.
Addr
)
Account
,
err
:
=
wallet
.
walletStore
.
GetAccountByAddr
(
SetLabel
.
Addr
)
if
err
==
nil
&&
Account
!=
nil
{
if
err
==
nil
&&
Account
!=
nil
{
oldLabel
:=
Account
.
Label
oldLabel
:=
Account
.
Label
Account
.
Label
=
SetLabel
.
GetLabel
()
Account
.
Label
=
SetLabel
.
GetLabel
()
...
@@ -1177,7 +1177,7 @@ func (wallet *Wallet) SaveSeed(password string, seed string) (bool, error) {
...
@@ -1177,7 +1177,7 @@ func (wallet *Wallet) SaveSeed(password string, seed string) (bool, error) {
func
(
wallet
*
Wallet
)
saveSeed
(
password
string
,
seed
string
)
(
bool
,
error
)
{
func
(
wallet
*
Wallet
)
saveSeed
(
password
string
,
seed
string
)
(
bool
,
error
)
{
//首先需要判断钱包是否已经设置seed,如果已经设置提示不需要再设置,一个钱包只能保存一个seed
//首先需要判断钱包是否已经设置seed,如果已经设置提示不需要再设置,一个钱包只能保存一个seed
exit
,
err
:=
wallet
.
walletStore
.
HasSeed
()
exit
,
_
:=
wallet
.
walletStore
.
HasSeed
()
if
exit
{
if
exit
{
return
false
,
types
.
ErrSeedExist
return
false
,
types
.
ErrSeedExist
}
}
...
...
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