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
8fa8f27b
Commit
8fa8f27b
authored
Nov 27, 2018
by
vipwzw
Committed by
33cn
Nov 27, 2018
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
update chain33 to master
parent
33922ee8
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 @
8fa8f27b
BSD
2
-Clause License
BSD
3
-Clause License
Copyright (c) 2018, 33.cn
All rights reserved.
...
...
@@ -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
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"
AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
...
...
vendor/github.com/33cn/chain33/Makefile
View file @
8fa8f27b
...
...
@@ -16,6 +16,7 @@ SRC_AUTOTEST := github.com/33cn/chain33/cmd/autotest
LDFLAGS
:=
-ldflags
"-w -s"
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_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"
`
BUILD_FLAGS
=
-ldflags
"-X github.com/33cn/chain33/common/version.GitCommit=
`
git rev-parse
--short
=
8 HEAD
`
"
MKPATH
=
$
(
abspath
$
(
lastword
$(MAKEFILE_LIST)
))
...
...
@@ -87,7 +88,7 @@ build_ci: depends ## Build the binary file for CI
@
go build
$(BUILD_FLAGS)
-v
-o
$(APP)
$(SRC)
@
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"
@
find
.
-name
'*.sh'
-not
-path
"./vendor/*"
| xargs shellcheck
...
...
@@ -101,6 +102,9 @@ race: ## Run data race detector
vet
:
@
go vet
${
PKG_LIST_VET
}
ineffassign
:
@
ineffassign
-n
${
PKG_LIST_INEFFASSIGN
}
test
:
##
Run unittests
@
go
test
-race
$(PKG_LIST)
...
...
vendor/github.com/33cn/chain33/blockchain/chain_test.go
View file @
8fa8f27b
...
...
@@ -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
{
t
.
Error
(
"testGetSeqByHash only para chain GetSeqByHash "
)
}
...
...
vendor/github.com/33cn/chain33/cmd/miner_accounts/accounts/show.go
View file @
8fa8f27b
...
...
@@ -102,7 +102,6 @@ func (show *ShowMinerAccount) Get(in *TimeAt, out *interface{}) error {
miner
=
calcIncrease
(
miner
,
curAcc
,
lastAcc
,
header
)
*
out
=
&
miner
seconds
=
seconds
-
statInterval
//}
return
nil
...
...
vendor/github.com/33cn/chain33/cmd/write/write.go
View file @
8fa8f27b
...
...
@@ -195,12 +195,12 @@ func scanWrite() {
Expire
:
"0"
,
}
var
signed
string
err
=
rpc
.
Call
(
"Chain33.SignRawTx"
,
paramsReqSignRawTx
,
&
signed
)
rpc
.
Call
(
"Chain33.SignRawTx"
,
paramsReqSignRawTx
,
&
signed
)
paramsRaw
:=
rpctypes
.
RawParm
{
Data
:
signed
,
}
var
sent
string
err
=
rpc
.
Call
(
"Chain33.SendTransaction"
,
paramsRaw
,
&
sent
)
rpc
.
Call
(
"Chain33.SendTransaction"
,
paramsRaw
,
&
sent
)
f
,
_
:=
os
.
OpenFile
(
heightFile
,
os
.
O_RDWR
,
0666
)
height
:=
strconv
.
FormatInt
(
currentHeight
,
10
)
index
:=
strconv
.
FormatInt
(
currentIndex
,
10
)
...
...
vendor/github.com/33cn/chain33/common/db/go_pegasus.go
View file @
8fa8f27b
...
...
@@ -372,8 +372,7 @@ func (dbit *PegasusIt) findInPage(key []byte) int {
//Seek 查找
func
(
dbit
*
PegasusIt
)
Seek
(
key
[]
byte
)
bool
{
pos
:=
-
1
pos
=
dbit
.
findInPage
(
key
)
pos
:=
dbit
.
findInPage
(
key
)
// 如果第一页已经找到,不会走入此逻辑
for
pos
==
-
1
&&
dbit
.
nextPage
{
...
...
vendor/github.com/33cn/chain33/common/db/go_ssdb.go
View file @
8fa8f27b
...
...
@@ -378,8 +378,7 @@ func (dbit *ssDBIt) findInPage(key string) int {
func
(
dbit
*
ssDBIt
)
Seek
(
key
[]
byte
)
bool
{
keyStr
:=
string
(
key
)
pos
:=
-
1
pos
=
dbit
.
findInPage
(
keyStr
)
pos
:=
dbit
.
findInPage
(
keyStr
)
// 如果第一页已经找到,不会走入此逻辑
for
pos
==
-
1
&&
dbit
.
nextPage
{
...
...
vendor/github.com/33cn/chain33/common/db/go_ssdb_util.go
View file @
8fa8f27b
...
...
@@ -336,7 +336,6 @@ func (c *SDBClient) send(args []interface{}) error {
return
nil
}
func
(
c
*
SDBClient
)
recv
()
(
resp
[]
string
,
err
error
)
{
bufSize
:=
0
packetBuf
:=
[]
byte
{}
//设置读取数据超时,
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) {
//数据包分解,发现长度,找到结尾,循环发现,发现空行,结束
readBuf
:=
make
([]
byte
,
ReadBufSize
)
for
{
bufSize
,
err
=
c
.
sock
.
Read
(
readBuf
)
bufSize
,
err
:
=
c
.
sock
.
Read
(
readBuf
)
if
err
!=
nil
{
return
nil
,
newErrorf
(
err
,
"client socket read error"
)
}
...
...
@@ -359,7 +358,7 @@ func (c *SDBClient) recv() (resp []string, err error) {
if
n
==
-
1
{
break
}
else
if
n
==
-
2
{
return
return
nil
,
newErrorf
(
err
,
"parse error"
)
}
else
{
resp
=
append
(
resp
,
rsp
)
packetBuf
=
packetBuf
[
n
+
1
:
]
...
...
@@ -370,7 +369,6 @@ func (c *SDBClient) recv() (resp []string, err error) {
func
(
c
*
SDBClient
)
parse
(
buf
[]
byte
)
(
resp
string
,
size
int
)
{
n
:=
bytes
.
IndexByte
(
buf
,
ENDN
)
blockSize
:=
-
1
size
=
-
1
if
n
!=
-
1
{
if
n
==
0
||
n
==
1
&&
buf
[
0
]
==
ENDR
{
//空行,说明一个数据包结束
...
...
@@ -378,7 +376,7 @@ func (c *SDBClient) parse(buf []byte) (resp string, size int) {
return
}
//数据包开始,包长度解析
blockSize
=
ToNum
(
buf
[
:
n
])
blockSize
:
=
ToNum
(
buf
[
:
n
])
bufSize
:=
len
(
buf
)
if
n
+
blockSize
<
bufSize
{
...
...
vendor/github.com/33cn/chain33/common/db/mvcc_test.go
View file @
8fa8f27b
...
...
@@ -150,7 +150,7 @@ func TestVersionSetAndGet(t *testing.T) {
assert
.
Equal
(
t
,
v
,
[]
byte
(
"v03"
))
m
.
Trash
(
3
)
v
,
err
=
m
.
GetV
([]
byte
(
"k0"
),
0
)
_
,
err
=
m
.
GetV
([]
byte
(
"k0"
),
0
)
assert
.
Equal
(
t
,
err
,
types
.
ErrNotFound
)
v
,
err
=
m
.
GetV
([]
byte
(
"k3"
),
4
)
...
...
@@ -192,23 +192,23 @@ func TestAddDelMVCC(t *testing.T) {
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
)
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
)
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
)
maxv
,
err
:=
m
.
GetMaxVersion
()
assert
.
Nil
(
t
,
err
)
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
)
kvlist
,
err
=
m
.
DelMVCC
(
hashN
(
0
),
0
,
true
)
_
,
err
=
m
.
DelMVCC
(
hashN
(
0
),
0
,
true
)
assert
.
Equal
(
t
,
err
,
types
.
ErrCanOnlyDelTopVersion
)
kvlist
,
err
=
m
.
DelMVCC
(
hashN
(
1
),
1
,
true
)
...
...
vendor/github.com/33cn/chain33/common/ntp.go
View file @
8fa8f27b
...
...
@@ -190,8 +190,6 @@ func abs(t time.Duration) time.Duration {
}
func
maxSubList
(
list
[]
time
.
Duration
)
(
sub
[]
time
.
Duration
)
{
start
:=
0
end
:=
0
if
len
(
list
)
==
0
{
return
list
}
...
...
@@ -202,6 +200,8 @@ func maxSubList(list []time.Duration) (sub []time.Duration) {
}
else
{
nextheight
=
list
[
i
+
1
]
}
var
start
int
var
end
int
if
abs
(
nextheight
-
list
[
i
])
>
time
.
Millisecond
*
100
{
end
=
i
+
1
if
len
(
sub
)
<
(
end
-
start
)
{
...
...
vendor/github.com/33cn/chain33/common/pubsub/pubsub_test.go
View file @
8fa8f27b
...
...
@@ -98,11 +98,11 @@ func (s *Suite) TestUnsubAll(c *check.C) {
ps
.
Unsub
(
ch1
)
m
,
ok
:=
<-
ch1
_
,
ok
:=
<-
ch1
c
.
Check
(
ok
,
check
.
Equals
,
false
)
ps
.
Pub
(
"hi"
,
"t1"
)
m
,
ok
=
<-
ch2
m
:
=
<-
ch2
c
.
Check
(
m
,
check
.
Equals
,
"hi"
)
ps
.
Shutdown
()
...
...
vendor/github.com/33cn/chain33/executor/execenv.go
View file @
8fa8f27b
...
...
@@ -136,7 +136,7 @@ func (e *executor) setEnv(exec drivers.Driver) {
exec
.
SetStateDB
(
e
.
stateDB
)
exec
.
SetLocalDB
(
e
.
localDB
)
exec
.
SetEnv
(
e
.
height
,
e
.
blocktime
,
e
.
difficulty
)
exec
.
SetA
pi
(
e
.
api
)
exec
.
SetA
PI
(
e
.
api
)
exec
.
SetTxs
(
e
.
txs
)
exec
.
SetReceipt
(
e
.
receipts
)
}
...
...
vendor/github.com/33cn/chain33/executor/executor_test.go
View file @
8fa8f27b
...
...
@@ -185,4 +185,5 @@ func TestKeyLocalAllow(t *testing.T) {
err
=
isAllowLocalKey
([]
byte
(
"exec"
),
[]
byte
(
"-exec------aa"
))
assert
.
Equal
(
t
,
err
,
types
.
ErrLocalPrefix
)
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 @
8fa8f27b
...
...
@@ -513,7 +513,7 @@ func (mem *Mempool) getSync() {
panic
(
"client not bind message queue."
)
}
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
)
if
err
!=
nil
{
time
.
Sleep
(
time
.
Second
)
...
...
vendor/github.com/33cn/chain33/mempool/mempool_test.go
View file @
8fa8f27b
...
...
@@ -517,7 +517,7 @@ func TestAddBlockedTx(t *testing.T) {
t
.
Error
(
err
)
return
}
msg1
,
err
=
mem
.
client
.
Wait
(
msg1
)
_
,
err
=
mem
.
client
.
Wait
(
msg1
)
if
err
!=
nil
{
t
.
Error
(
err
)
return
...
...
vendor/github.com/33cn/chain33/p2p/addrbook.go
View file @
8fa8f27b
...
...
@@ -34,7 +34,7 @@ func (a *AddrBook) Close() {
type
AddrBook
struct
{
mtx
sync
.
Mutex
ourAddrs
map
[
string
]
*
NetAddress
addrPeer
map
[
string
]
*
k
nownAddress
addrPeer
map
[
string
]
*
K
nownAddress
cfg
*
types
.
P2P
keymtx
sync
.
Mutex
privkey
string
...
...
@@ -43,7 +43,8 @@ type AddrBook struct {
Quit
chan
struct
{}
}
type
knownAddress
struct
{
// KnownAddress defines known address type
type
KnownAddress
struct
{
kmtx
sync
.
Mutex
Addr
*
NetAddress
`json:"addr"`
Attempts
uint
`json:"attempts"`
...
...
@@ -52,7 +53,7 @@ type knownAddress struct {
}
// GetPeerStat get peer stat
func
(
a
*
AddrBook
)
GetPeerStat
(
addr
string
)
*
k
nownAddress
{
func
(
a
*
AddrBook
)
GetPeerStat
(
addr
string
)
*
K
nownAddress
{
a
.
mtx
.
Lock
()
defer
a
.
mtx
.
Unlock
()
if
peer
,
ok
:=
a
.
addrPeer
[
addr
];
ok
{
...
...
@@ -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
()
defer
a
.
mtx
.
Unlock
()
if
peer
,
ok
:=
a
.
addrPeer
[
addr
];
ok
{
...
...
@@ -82,7 +83,7 @@ func NewAddrBook(cfg *types.P2P) *AddrBook {
a
:=
&
AddrBook
{
ourAddrs
:
make
(
map
[
string
]
*
NetAddress
),
addrPeer
:
make
(
map
[
string
]
*
k
nownAddress
),
addrPeer
:
make
(
map
[
string
]
*
K
nownAddress
),
cfg
:
cfg
,
Quit
:
make
(
chan
struct
{},
1
),
}
...
...
@@ -90,8 +91,8 @@ func NewAddrBook(cfg *types.P2P) *AddrBook {
return
a
}
func
newKnownAddress
(
addr
*
NetAddress
)
*
k
nownAddress
{
return
&
k
nownAddress
{
func
newKnownAddress
(
addr
*
NetAddress
)
*
K
nownAddress
{
return
&
K
nownAddress
{
kmtx
:
sync
.
Mutex
{},
Addr
:
addr
,
Attempts
:
0
,
...
...
@@ -99,7 +100,7 @@ func newKnownAddress(addr *NetAddress) *knownAddress {
}
}
func
(
ka
*
k
nownAddress
)
markGood
()
{
func
(
ka
*
K
nownAddress
)
markGood
()
{
ka
.
kmtx
.
Lock
()
defer
ka
.
kmtx
.
Unlock
()
now
:=
types
.
Now
()
...
...
@@ -109,10 +110,10 @@ func (ka *knownAddress) markGood() {
}
// Copy a KnownAddress
func
(
ka
*
knownAddress
)
Copy
()
*
k
nownAddress
{
func
(
ka
*
KnownAddress
)
Copy
()
*
K
nownAddress
{
ka
.
kmtx
.
Lock
()
ret
:=
k
nownAddress
{
ret
:=
K
nownAddress
{
Addr
:
ka
.
Addr
.
Copy
(),
Attempts
:
ka
.
Attempts
,
LastAttempt
:
ka
.
LastAttempt
,
...
...
@@ -122,7 +123,7 @@ func (ka *knownAddress) Copy() *knownAddress {
return
&
ret
}
func
(
ka
*
k
nownAddress
)
markAttempt
()
{
func
(
ka
*
K
nownAddress
)
markAttempt
()
{
ka
.
kmtx
.
Lock
()
defer
ka
.
kmtx
.
Unlock
()
...
...
@@ -133,7 +134,7 @@ func (ka *knownAddress) markAttempt() {
}
// GetAttempts return attempts
func
(
ka
*
k
nownAddress
)
GetAttempts
()
uint
{
func
(
ka
*
K
nownAddress
)
GetAttempts
()
uint
{
ka
.
kmtx
.
Lock
()
defer
ka
.
kmtx
.
Unlock
()
return
ka
.
Attempts
...
...
@@ -176,13 +177,13 @@ func (a *AddrBook) Size() int {
}
type
addrBookJSON
struct
{
Addrs
[]
*
k
nownAddress
`json:"addrs"`
Addrs
[]
*
K
nownAddress
`json:"addrs"`
}
func
(
a
*
AddrBook
)
saveToDb
()
{
a
.
mtx
.
Lock
()
defer
a
.
mtx
.
Unlock
()
addrs
:=
[]
*
k
nownAddress
{}
addrs
:=
[]
*
K
nownAddress
{}
seeds
:=
a
.
cfg
.
Seeds
seedsMap
:=
make
(
map
[
string
]
int
)
...
...
@@ -294,7 +295,7 @@ out:
// AddAddress add a address for ours
// 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
()
defer
a
.
mtx
.
Unlock
()
...
...
vendor/github.com/33cn/chain33/p2p/downloadblocks.go
View file @
8fa8f27b
...
...
@@ -16,7 +16,8 @@ import (
"google.golang.org/grpc"
)
type
downloadJob
struct
{
// DownloadJob defines download job type
type
DownloadJob
struct
{
wg
sync
.
WaitGroup
retryList
*
list
.
List
p2pcli
*
Cli
...
...
@@ -32,8 +33,8 @@ type peerJob struct {
}
// NewDownloadJob create a downloadjob object
func
NewDownloadJob
(
p2pcli
*
Cli
,
peers
[]
*
Peer
)
*
d
ownloadJob
{
job
:=
new
(
d
ownloadJob
)
func
NewDownloadJob
(
p2pcli
*
Cli
,
peers
[]
*
Peer
)
*
D
ownloadJob
{
job
:=
new
(
D
ownloadJob
)
job
.
retryList
=
list
.
New
()
job
.
p2pcli
=
p2pcli
job
.
busyPeer
=
make
(
map
[
string
]
*
peerJob
)
...
...
@@ -41,7 +42,7 @@ func NewDownloadJob(p2pcli *Cli, peers []*Peer) *downloadJob {
return
job
}
func
(
d
*
d
ownloadJob
)
isBusyPeer
(
pid
string
)
bool
{
func
(
d
*
D
ownloadJob
)
isBusyPeer
(
pid
string
)
bool
{
d
.
mtx
.
Lock
()
defer
d
.
mtx
.
Unlock
()
if
pjob
,
ok
:=
d
.
busyPeer
[
pid
];
ok
{
...
...
@@ -50,7 +51,7 @@ func (d *downloadJob) isBusyPeer(pid string) bool {
return
false
}
func
(
d
*
d
ownloadJob
)
setBusyPeer
(
peer
*
pb
.
Peer
)
{
func
(
d
*
D
ownloadJob
)
setBusyPeer
(
peer
*
pb
.
Peer
)
{
d
.
mtx
.
Lock
()
defer
d
.
mtx
.
Unlock
()
if
pjob
,
ok
:=
d
.
busyPeer
[
peer
.
GetName
()];
ok
{
...
...
@@ -62,7 +63,7 @@ func (d *downloadJob) setBusyPeer(peer *pb.Peer) {
d
.
busyPeer
[
peer
.
GetName
()]
=
&
peerJob
{
peer
,
1
}
}
func
(
d
*
d
ownloadJob
)
setFreePeer
(
pid
string
)
{
func
(
d
*
D
ownloadJob
)
setFreePeer
(
pid
string
)
{
d
.
mtx
.
Lock
()
defer
d
.
mtx
.
Unlock
()
...
...
@@ -76,7 +77,7 @@ func (d *downloadJob) setFreePeer(pid string) {
}
// 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
()
for
_
,
peer
:=
range
d
.
downloadPeers
{
pbpeer
,
ok
:=
infos
[
peer
.
Addr
()]
...
...
@@ -99,16 +100,16 @@ func (d *downloadJob) GetFreePeer(joblimit int64) *Peer {
}
// CancelJob cancel the downloadjob object
func
(
d
*
d
ownloadJob
)
CancelJob
()
{
func
(
d
*
D
ownloadJob
)
CancelJob
()
{
atomic
.
StoreInt32
(
&
d
.
canceljob
,
1
)
}
func
(
d
*
d
ownloadJob
)
isCancel
()
bool
{
func
(
d
*
D
ownloadJob
)
isCancel
()
bool
{
return
atomic
.
LoadInt32
(
&
d
.
canceljob
)
==
1
}
// 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
{
var
errinvs
[]
*
pb
.
Inventory
if
d
.
isCancel
()
{
...
...
@@ -140,7 +141,7 @@ func (d *downloadJob) DownloadBlock(invs []*pb.Inventory,
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
if
d
.
isCancel
()
{
return
errinvs
...
...
@@ -166,7 +167,7 @@ func (d *downloadJob) restOfInvs(bchan chan *pb.BlockPid) []*pb.Inventory {
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返回上层
if
peer
==
nil
{
return
fmt
.
Errorf
(
"peer is not exist"
)
...
...
vendor/github.com/33cn/chain33/rpc/http.go
View file @
8fa8f27b
...
...
@@ -64,7 +64,7 @@ func (j *JSONRPCServer) Listen() (int, error) {
return
}
if
!
checkI
p
Whitelist
(
ip
)
{
if
!
checkI
P
Whitelist
(
ip
)
{
writeError
(
w
,
r
,
0
,
fmt
.
Sprintf
(
`The %s Address is not authorized!`
,
ip
))
return
}
...
...
@@ -75,7 +75,7 @@ func (j *JSONRPCServer) Listen() (int, error) {
return
}
//格式做一个检查
client
,
err
:=
parseJ
son
RpcParams
(
data
)
client
,
err
:=
parseJ
SON
RpcParams
(
data
)
errstr
:=
"nil"
if
err
!=
nil
{
errstr
=
err
.
Error
()
...
...
@@ -90,7 +90,7 @@ func (j *JSONRPCServer) Listen() (int, error) {
if
!
ipaddr
.
IsLoopback
()
{
funcName
:=
strings
.
Split
(
client
.
Method
,
"."
)[
len
(
strings
.
Split
(
client
.
Method
,
"."
))
-
1
]
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
}
}
...
...
@@ -114,7 +114,7 @@ func (j *JSONRPCServer) Listen() (int, error) {
}
type
serverResponse
struct
{
I
d
uint64
`json:"id"`
I
D
uint64
`json:"id"`
Result
interface
{}
`json:"result"`
Error
interface
{}
`json:"error"`
}
...
...
@@ -161,7 +161,7 @@ func auth(ctx context.Context, info *grpc.UnaryServerInfo) error {
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
)
}
...
...
@@ -177,10 +177,10 @@ func auth(ctx context.Context, info *grpc.UnaryServerInfo) error {
type
clientRequest
struct
{
Method
string
`json:"method"`
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
err
:=
json
.
Unmarshal
(
data
,
&
req
)
if
err
!=
nil
{
...
...
vendor/github.com/33cn/chain33/rpc/jrpchandler.go
View file @
8fa8f27b
...
...
@@ -422,7 +422,7 @@ func (c *Chain33) WalletTxList(in rpctypes.ReqWalletTransactionList, result *int
}
{
var
txdetails
rpctypes
.
WalletTxDetails
rpctypes
.
ConvertWalletTxDetailToJ
son
(
reply
,
&
txdetails
)
rpctypes
.
ConvertWalletTxDetailToJ
SON
(
reply
,
&
txdetails
)
*
result
=
&
txdetails
}
return
nil
...
...
vendor/github.com/33cn/chain33/rpc/jsonclient/jsonclient.go
View file @
8fa8f27b
...
...
@@ -42,11 +42,11 @@ func New(prefix, url string) (*JSONClient, error) {
type
clientRequest
struct
{
Method
string
`json:"method"`
Params
[
1
]
interface
{}
`json:"params"`
I
d
uint64
`json:"id"`
I
D
uint64
`json:"id"`
}
type
clientResponse
struct
{
I
d
uint64
`json:"id"`
I
D
uint64
`json:"id"`
Result
*
json
.
RawMessage
`json:"result"`
Error
interface
{}
`json:"error"`
}
...
...
vendor/github.com/33cn/chain33/rpc/jsonclient/rpc_ctx.go
View file @
8fa8f27b
...
...
@@ -10,9 +10,9 @@ import (
"os"
)
// R
pc
Ctx rpc ctx interface
// R
PC
Ctx rpc ctx interface
// TODO: SetPostRunCb()
type
R
pc
Ctx
struct
{
type
R
PC
Ctx
struct
{
Addr
string
Method
string
Params
interface
{}
...
...
@@ -23,9 +23,9 @@ type RpcCtx struct {
// Callback a callback function
type
Callback
func
(
res
interface
{})
(
interface
{},
error
)
// NewR
pc
Ctx produce a object of rpcctx
func
NewR
pcCtx
(
laddr
,
method
string
,
params
,
res
interface
{})
*
Rpc
Ctx
{
return
&
R
pc
Ctx
{
// NewR
PC
Ctx produce a object of rpcctx
func
NewR
PCCtx
(
laddr
,
method
string
,
params
,
res
interface
{})
*
RPC
Ctx
{
return
&
R
PC
Ctx
{
Addr
:
laddr
,
Method
:
method
,
Params
:
params
,
...
...
@@ -34,12 +34,12 @@ func NewRpcCtx(laddr, method string, params, res interface{}) *RpcCtx {
}
// SetResultCb rpcctx callback
func
(
c
*
R
pc
Ctx
)
SetResultCb
(
cb
Callback
)
{
func
(
c
*
R
PC
Ctx
)
SetResultCb
(
cb
Callback
)
{
c
.
cb
=
cb
}
// 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
)
if
err
!=
nil
{
return
nil
,
err
...
...
@@ -63,7 +63,7 @@ func (c *RpcCtx) RunResult() (interface{}, error) {
}
// Run rpcctx to runresult
func
(
c
*
R
pc
Ctx
)
Run
()
{
func
(
c
*
R
PC
Ctx
)
Run
()
{
result
,
err
:=
c
.
RunResult
()
if
err
!=
nil
{
fmt
.
Fprintln
(
os
.
Stderr
,
err
)
...
...
@@ -78,7 +78,7 @@ func (c *RpcCtx) Run() {
}
// RunWithoutMarshal return source result of string
func
(
c
*
R
pc
Ctx
)
RunWithoutMarshal
()
{
func
(
c
*
R
PC
Ctx
)
RunWithoutMarshal
()
{
var
res
string
rpc
,
err
:=
NewJSONClient
(
c
.
Addr
)
if
err
!=
nil
{
...
...
vendor/github.com/33cn/chain33/rpc/server.go
View file @
8fa8f27b
...
...
@@ -20,7 +20,7 @@ import (
)
var
(
remoteI
p
Whitelist
=
make
(
map
[
string
]
bool
)
remoteI
P
Whitelist
=
make
(
map
[
string
]
bool
)
rpcCfg
*
types
.
RPC
jrpcFuncWhitelist
=
make
(
map
[
string
]
bool
)
grpcFuncWhitelist
=
make
(
map
[
string
]
bool
)
...
...
@@ -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
)
if
ip
.
IsLoopback
()
{
...
...
@@ -77,10 +77,10 @@ func checkIpWhitelist(addr string) bool {
if
ipv4
!=
nil
{
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
}
if
_
,
ok
:=
remoteI
p
Whitelist
[
addr
];
ok
{
if
_
,
ok
:=
remoteI
P
Whitelist
[
addr
];
ok
{
return
true
}
return
false
...
...
@@ -177,7 +177,7 @@ type RPC struct {
// InitCfg interfaces
func
InitCfg
(
cfg
*
types
.
RPC
)
{
rpcCfg
=
cfg
InitI
p
Whitelist
(
cfg
)
InitI
P
Whitelist
(
cfg
)
InitJrpcFuncWhitelist
(
cfg
)
InitGrpcFuncWhitelist
(
cfg
)
InitJrpcFuncBlacklist
(
cfg
)
...
...
@@ -265,29 +265,29 @@ func (r *RPC) Close() {
}
}
// InitI
p
Whitelist init ip whitelist
func
InitI
p
Whitelist
(
cfg
*
types
.
RPC
)
{
// InitI
P
Whitelist init ip whitelist
func
InitI
P
Whitelist
(
cfg
*
types
.
RPC
)
{
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
}
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
}
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
}
if
len
(
cfg
.
Whitelist
)
!=
0
{
for
_
,
addr
:=
range
cfg
.
Whitelist
{
remoteI
p
Whitelist
[
addr
]
=
true
remoteI
P
Whitelist
[
addr
]
=
true
}
return
}
if
len
(
cfg
.
Whitlist
)
!=
0
{
for
_
,
addr
:=
range
cfg
.
Whitlist
{
remoteI
p
Whitelist
[
addr
]
=
true
remoteI
P
Whitelist
[
addr
]
=
true
}
return
}
...
...
vendor/github.com/33cn/chain33/rpc/server_test.go
View file @
8fa8f27b
...
...
@@ -22,18 +22,18 @@ import (
func
TestCheckIpWhitelist
(
t
*
testing
.
T
)
{
address
:=
"127.0.0.1"
assert
.
True
(
t
,
checkI
p
Whitelist
(
address
))
assert
.
True
(
t
,
checkI
P
Whitelist
(
address
))
address
=
"::1"
assert
.
True
(
t
,
checkI
p
Whitelist
(
address
))
assert
.
True
(
t
,
checkI
P
Whitelist
(
address
))
address
=
"192.168.3.1"
remoteI
p
Whitelist
[
address
]
=
true
assert
.
False
(
t
,
checkI
p
Whitelist
(
"192.168.3.2"
))
remoteI
P
Whitelist
[
address
]
=
true
assert
.
False
(
t
,
checkI
P
Whitelist
(
"192.168.3.2"
))
remoteI
p
Whitelist
[
"0.0.0.0"
]
=
true
assert
.
True
(
t
,
checkI
p
Whitelist
(
address
))
assert
.
True
(
t
,
checkI
p
Whitelist
(
"192.168.3.2"
))
remoteI
P
Whitelist
[
"0.0.0.0"
]
=
true
assert
.
True
(
t
,
checkI
P
Whitelist
(
address
))
assert
.
True
(
t
,
checkI
P
Whitelist
(
"192.168.3.2"
))
}
...
...
vendor/github.com/33cn/chain33/rpc/types/code.go
View file @
8fa8f27b
...
...
@@ -47,8 +47,8 @@ func DecodeLog(execer []byte, rlog *ReceiptData) (*ReceiptDataResult, error) {
return
rd
,
nil
}
// ConvertWalletTxDetailToJ
son
conver the wallet tx detail to json
func
ConvertWalletTxDetailToJ
son
(
in
*
types
.
WalletTxDetails
,
out
*
WalletTxDetails
)
error
{
// ConvertWalletTxDetailToJ
SON
conver the wallet tx detail to json
func
ConvertWalletTxDetailToJ
SON
(
in
*
types
.
WalletTxDetails
,
out
*
WalletTxDetails
)
error
{
if
in
==
nil
||
out
==
nil
{
return
types
.
ErrInvalidParam
}
...
...
vendor/github.com/33cn/chain33/system/dapp/coins/autotest/coins.go
View file @
8fa8f27b
...
...
@@ -7,18 +7,18 @@ package autotest
import
(
"reflect"
.
"github.com/33cn/chain33/cmd/autotest/types"
"github.com/33cn/chain33/cmd/autotest/types"
)
type
coinsAutoTest
struct
{
SimpleCaseArr
[]
SimpleCase
`toml:"SimpleCase,omitempty"`
TransferCaseArr
[]
TransferCase
`toml:"TransferCase,omitempty"`
WithdrawCaseArr
[]
WithdrawCase
`toml:"WithdrawCase,omitempty"`
SimpleCaseArr
[]
types
.
SimpleCase
`toml:"SimpleCase,omitempty"`
TransferCaseArr
[]
TransferCase
`toml:"TransferCase,omitempty"`
WithdrawCaseArr
[]
WithdrawCase
`toml:"WithdrawCase,omitempty"`
}
func
init
()
{
RegisterAutoTest
(
coinsAutoTest
{})
types
.
RegisterAutoTest
(
coinsAutoTest
{})
}
...
...
vendor/github.com/33cn/chain33/system/dapp/coins/autotest/transferCase.go
View file @
8fa8f27b
...
...
@@ -7,12 +7,12 @@ package autotest
import
(
"strconv"
.
"github.com/33cn/chain33/cmd/autotest/types"
"github.com/33cn/chain33/cmd/autotest/types"
)
// TransferCase transfer case
type
TransferCase
struct
{
BaseCase
types
.
BaseCase
From
string
`toml:"from"`
To
string
`toml:"to"`
Amount
string
`toml:"amount"`
...
...
@@ -20,19 +20,19 @@ type TransferCase struct {
// TransferPack transfer pack
type
TransferPack
struct
{
BaseCasePack
types
.
BaseCasePack
}
// 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
func
(
pack
*
TransferPack
)
GetCheckHandlerMap
()
interface
{}
{
funcMap
:=
make
(
CheckHandlerMapDiscard
,
2
)
funcMap
:=
make
(
types
.
CheckHandlerMapDiscard
,
2
)
funcMap
[
"balance"
]
=
pack
.
checkBalance
return
funcMap
...
...
@@ -61,10 +61,10 @@ func (pack *TransferPack) checkBalance(txInfo map[string]interface{}) bool {
//transfer to contract, deposit
if
len
(
logArr
)
==
4
{
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
)
&&
CheckBalanceDeltaWithAddr
(
logSend
,
interCase
.
From
,
-
Amount
)
&&
CheckBalanceDeltaWithAddr
(
logRecv
,
interCase
.
To
,
Amount
)
&&
depositCheck
return
types
.
CheckBalanceDeltaWithAddr
(
logFee
,
interCase
.
From
,
-
fee
)
&&
types
.
CheckBalanceDeltaWithAddr
(
logSend
,
interCase
.
From
,
-
Amount
)
&&
types
.
CheckBalanceDeltaWithAddr
(
logRecv
,
interCase
.
To
,
Amount
)
&&
depositCheck
}
vendor/github.com/33cn/chain33/system/dapp/coins/autotest/withdrawCase.go
View file @
8fa8f27b
...
...
@@ -7,31 +7,31 @@ package autotest
import
(
"strconv"
.
"github.com/33cn/chain33/cmd/autotest/types"
"github.com/33cn/chain33/cmd/autotest/types"
)
// WithdrawCase defines the withdraw case
type
WithdrawCase
struct
{
BaseCase
types
.
BaseCase
Addr
string
`toml:"addr"`
Amount
string
`toml:"amount"`
}
// WithdrawPack defines the withdraw pack
type
WithdrawPack
struct
{
BaseCasePack
types
.
BaseCasePack
}
// 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
func
(
pack
*
WithdrawPack
)
GetCheckHandlerMap
()
interface
{}
{
funcMap
:=
make
(
CheckHandlerMapDiscard
,
1
)
funcMap
:=
make
(
types
.
CheckHandlerMapDiscard
,
1
)
funcMap
[
"balance"
]
=
pack
.
checkBalance
return
funcMap
...
...
@@ -62,8 +62,8 @@ func (pack *WithdrawPack) checkBalance(txInfo map[string]interface{}) bool {
"ToPrev"
,
logRecv
[
"prev"
]
.
(
map
[
string
]
interface
{})[
"balance"
]
.
(
string
),
"ToCurr"
,
logRecv
[
"current"
]
.
(
map
[
string
]
interface
{})[
"balance"
]
.
(
string
))
return
CheckBalanceDeltaWithAddr
(
logFee
,
interCase
.
Addr
,
-
fee
)
&&
CheckBalanceDeltaWithAddr
(
logWithdraw
,
interCase
.
Addr
,
-
Amount
)
&&
CheckBalanceDeltaWithAddr
(
logSend
,
withdrawFrom
,
-
Amount
)
&&
CheckBalanceDeltaWithAddr
(
logRecv
,
interCase
.
Addr
,
Amount
)
return
types
.
CheckBalanceDeltaWithAddr
(
logFee
,
interCase
.
Addr
,
-
fee
)
&&
types
.
CheckBalanceDeltaWithAddr
(
logWithdraw
,
interCase
.
Addr
,
-
Amount
)
&&
types
.
CheckBalanceDeltaWithAddr
(
logSend
,
withdrawFrom
,
-
Amount
)
&&
types
.
CheckBalanceDeltaWithAddr
(
logRecv
,
interCase
.
Addr
,
Amount
)
}
vendor/github.com/33cn/chain33/system/dapp/coins/executor/coins.go
View file @
8fa8f27b
...
...
@@ -59,8 +59,16 @@ func (c *Coins) GetDriverName() string {
return
driverName
}
// CheckTx check transaction
// CheckTx check transaction
amount 必须不能为负数
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
}
...
...
@@ -76,3 +84,8 @@ func (c *Coins) IsFriend(myexec, writekey []byte, othertx *types.Transaction) bo
}
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 @
8fa8f27b
...
...
@@ -10,9 +10,6 @@ import (
// 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
)
{
if
receipt
.
GetTy
()
!=
types
.
ExecOk
{
return
&
types
.
LocalDBSet
{},
nil
}
kv
,
err
:=
updateAddrReciver
(
c
.
GetLocalDB
(),
tx
.
GetRealToAddr
(),
transfer
.
Amount
,
false
)
if
err
!=
nil
{
return
nil
,
err
...
...
@@ -22,9 +19,6 @@ func (c *Coins) ExecDelLocal_Transfer(transfer *types.AssetsTransfer, tx *types.
// 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
)
{
if
receipt
.
GetTy
()
!=
types
.
ExecOk
{
return
&
types
.
LocalDBSet
{},
nil
}
kv
,
err
:=
updateAddrReciver
(
c
.
GetLocalDB
(),
tx
.
GetRealToAddr
(),
transfer
.
Amount
,
false
)
if
err
!=
nil
{
return
nil
,
err
...
...
@@ -34,9 +28,6 @@ func (c *Coins) ExecDelLocal_TransferToExec(transfer *types.AssetsTransferToExec
// 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
)
{
if
receipt
.
GetTy
()
!=
types
.
ExecOk
{
return
&
types
.
LocalDBSet
{},
nil
}
from
:=
tx
.
From
()
kv
,
err
:=
updateAddrReciver
(
c
.
GetLocalDB
(),
from
,
withdraw
.
Amount
,
false
)
if
err
!=
nil
{
...
...
vendor/github.com/33cn/chain33/system/dapp/coins/executor/exec_local.go
View file @
8fa8f27b
...
...
@@ -10,9 +10,6 @@ import (
// 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
)
{
if
receipt
.
GetTy
()
!=
types
.
ExecOk
{
return
&
types
.
LocalDBSet
{},
nil
}
kv
,
err
:=
updateAddrReciver
(
c
.
GetLocalDB
(),
tx
.
GetRealToAddr
(),
transfer
.
Amount
,
true
)
if
err
!=
nil
{
return
nil
,
err
...
...
@@ -22,9 +19,6 @@ func (c *Coins) ExecLocal_Transfer(transfer *types.AssetsTransfer, tx *types.Tra
// 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
)
{
if
receipt
.
GetTy
()
!=
types
.
ExecOk
{
return
&
types
.
LocalDBSet
{},
nil
}
kv
,
err
:=
updateAddrReciver
(
c
.
GetLocalDB
(),
tx
.
GetRealToAddr
(),
transfer
.
Amount
,
true
)
if
err
!=
nil
{
return
nil
,
err
...
...
@@ -34,9 +28,6 @@ func (c *Coins) ExecLocal_TransferToExec(transfer *types.AssetsTransferToExec, t
// ExecLocal_Withdraw withdraw local exec
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
()
kv
,
err
:=
updateAddrReciver
(
c
.
GetLocalDB
(),
from
,
withdraw
.
Amount
,
true
)
if
err
!=
nil
{
...
...
@@ -47,9 +38,6 @@ func (c *Coins) ExecLocal_Withdraw(withdraw *types.AssetsWithdraw, tx *types.Tra
// 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
)
{
if
receipt
.
GetTy
()
!=
types
.
ExecOk
{
return
&
types
.
LocalDBSet
{},
nil
}
kv
,
err
:=
updateAddrReciver
(
c
.
GetLocalDB
(),
tx
.
GetRealToAddr
(),
gen
.
Amount
,
true
)
if
err
!=
nil
{
return
nil
,
err
...
...
vendor/github.com/33cn/chain33/system/dapp/commands/account.go
View file @
8fa8f27b
...
...
@@ -12,7 +12,7 @@ import (
"github.com/33cn/chain33/common/address"
"github.com/33cn/chain33/rpc/jsonclient"
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/spf13/cobra"
)
...
...
@@ -60,7 +60,7 @@ func dumpKey(cmd *cobra.Command, args []string) {
Data
:
addr
,
}
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
()
}
...
...
@@ -77,24 +77,24 @@ func GetAccountListCmd() *cobra.Command {
func
listAccount
(
cmd
*
cobra
.
Command
,
args
[]
string
)
{
rpcLaddr
,
_
:=
cmd
.
Flags
()
.
GetString
(
"rpc_laddr"
)
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
.
Run
()
}
func
parseListAccountRes
(
arg
interface
{})
(
interface
{},
error
)
{
res
:=
arg
.
(
*
rpctypes
.
WalletAccounts
)
var
result
AccountsResult
var
result
commandtypes
.
AccountsResult
for
_
,
r
:=
range
res
.
Wallets
{
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
)
accResult
:=
&
AccountResult
{
accResult
:=
&
commandtypes
.
AccountResult
{
Currency
:
r
.
Acc
.
Currency
,
Addr
:
r
.
Acc
.
Addr
,
Balance
:
balanceResult
,
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
}
...
...
@@ -144,7 +144,7 @@ func balance(cmd *cobra.Command, args []string) {
if
execer
==
""
{
req
:=
types
.
ReqAddr
{
Addr
:
addr
}
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
.
Run
()
return
...
...
@@ -161,7 +161,7 @@ func balance(cmd *cobra.Command, args []string) {
IsDetail
:
false
,
}
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
()
if
err
!=
nil
{
fmt
.
Fprintln
(
os
.
Stderr
,
err
)
...
...
@@ -179,7 +179,7 @@ func balance(cmd *cobra.Command, args []string) {
StateHash
:
stateHash
,
}
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
.
Run
()
}
...
...
@@ -188,7 +188,7 @@ func parseGetBalanceRes(arg interface{}) (interface{}, error) {
res
:=
*
arg
.
(
*
[]
*
rpctypes
.
Account
)
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
)
result
:=
&
AccountResult
{
result
:=
&
commandtypes
.
AccountResult
{
Addr
:
res
[
0
]
.
Addr
,
Currency
:
res
[
0
]
.
Currency
,
Balance
:
balanceResult
,
...
...
@@ -200,16 +200,16 @@ func parseGetBalanceRes(arg interface{}) (interface{}, error) {
func
parseGetAllBalanceRes
(
arg
interface
{})
(
interface
{},
error
)
{
res
:=
*
arg
.
(
*
rpctypes
.
AllExecBalance
)
accs
:=
res
.
ExecAccount
result
:=
AllExecBalance
{
Addr
:
res
.
Addr
}
result
:=
commandtypes
.
AllExecBalance
{
Addr
:
res
.
Addr
}
for
_
,
acc
:=
range
accs
{
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
)
ar
:=
&
AccountResult
{
ar
:=
&
commandtypes
.
AccountResult
{
Currency
:
acc
.
Account
.
Currency
,
Balance
:
balanceResult
,
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
}
...
...
@@ -242,15 +242,15 @@ func importKey(cmd *cobra.Command, args []string) {
Label
:
label
,
}
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
.
Run
()
}
func
parseImportKeyRes
(
arg
interface
{})
(
interface
{},
error
)
{
res
:=
arg
.
(
*
types
.
WalletAccount
)
accResult
:=
DecodeAccount
(
res
.
GetAcc
(),
types
.
Coin
)
result
:=
WalletResult
{
accResult
:=
commandtypes
.
DecodeAccount
(
res
.
GetAcc
(),
types
.
Coin
)
result
:=
commandtypes
.
WalletResult
{
Acc
:
accResult
,
Label
:
res
.
GetLabel
(),
}
...
...
@@ -280,15 +280,15 @@ func createAccount(cmd *cobra.Command, args []string) {
Label
:
label
,
}
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
.
Run
()
}
func
parseCreateAccountRes
(
arg
interface
{})
(
interface
{},
error
)
{
res
:=
arg
.
(
*
types
.
WalletAccount
)
accResult
:=
DecodeAccount
(
res
.
GetAcc
(),
types
.
Coin
)
result
:=
WalletResult
{
accResult
:=
commandtypes
.
DecodeAccount
(
res
.
GetAcc
(),
types
.
Coin
)
result
:=
commandtypes
.
WalletResult
{
Acc
:
accResult
,
Label
:
res
.
GetLabel
(),
}
...
...
@@ -323,15 +323,15 @@ func setLabel(cmd *cobra.Command, args []string) {
Label
:
label
,
}
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
.
Run
()
}
func
parseSetLabelRes
(
arg
interface
{})
(
interface
{},
error
)
{
res
:=
arg
.
(
*
types
.
WalletAccount
)
accResult
:=
DecodeAccount
(
res
.
GetAcc
(),
types
.
Coin
)
result
:=
WalletResult
{
accResult
:=
commandtypes
.
DecodeAccount
(
res
.
GetAcc
(),
types
.
Coin
)
result
:=
commandtypes
.
WalletResult
{
Acc
:
accResult
,
Label
:
res
.
GetLabel
(),
}
...
...
vendor/github.com/33cn/chain33/system/dapp/commands/block.go
View file @
8fa8f27b
...
...
@@ -12,7 +12,7 @@ import (
"github.com/33cn/chain33/rpc/jsonclient"
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/spf13/cobra"
)
...
...
@@ -77,15 +77,15 @@ func blockBodyCmd(cmd *cobra.Command, args []string) {
Isdetail
:
detailBool
,
}
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
.
Run
()
}
func
parseBlockDetail
(
res
interface
{})
(
interface
{},
error
)
{
var
result
BlockDetailsResult
var
result
commandtypes
.
BlockDetailsResult
for
_
,
vItem
:=
range
res
.
(
*
rpctypes
.
BlockDetails
)
.
Items
{
b
:=
&
BlockResult
{
b
:=
&
commandtypes
.
BlockResult
{
Version
:
vItem
.
Block
.
Version
,
ParentHash
:
vItem
.
Block
.
ParentHash
,
TxHash
:
vItem
.
Block
.
TxHash
,
...
...
@@ -94,9 +94,9 @@ func parseBlockDetail(res interface{}) (interface{}, error) {
BlockTime
:
vItem
.
Block
.
BlockTime
,
}
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
)
}
return
result
,
nil
...
...
@@ -125,7 +125,7 @@ func blockHeightHash(cmd *cobra.Command, args []string) {
Height
:
height
,
}
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
()
}
...
...
@@ -152,7 +152,7 @@ func blockViewByHash(cmd *cobra.Command, args []string) {
Hash
:
blockHash
,
}
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
()
}
...
...
@@ -193,7 +193,7 @@ func blockHeader(cmd *cobra.Command, args []string) {
IsDetail
:
detailBool
,
}
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
()
}
...
...
@@ -210,7 +210,7 @@ func GetLastHeaderCmd() *cobra.Command {
func
lastHeader
(
cmd
*
cobra
.
Command
,
args
[]
string
)
{
rpcLaddr
,
_
:=
cmd
.
Flags
()
.
GetString
(
"rpc_laddr"
)
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
()
}
...
...
@@ -227,7 +227,7 @@ func GetLastBlockSequenceCmd() *cobra.Command {
func
lastSequence
(
cmd
*
cobra
.
Command
,
args
[]
string
)
{
rpcLaddr
,
_
:=
cmd
.
Flags
()
.
GetString
(
"rpc_laddr"
)
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
()
}
...
...
@@ -253,7 +253,7 @@ func getsequences(cmd *cobra.Command, args []string) {
Isdetail
:
false
,
}
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
.
Run
()
}
...
...
@@ -291,7 +291,7 @@ func getblockbyhashs(cmd *cobra.Command, args []string) {
}
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
.
Run
()
}
vendor/github.com/33cn/chain33/system/dapp/commands/bty.go
View file @
8fa8f27b
...
...
@@ -14,7 +14,7 @@ import (
"time"
"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/spf13/cobra"
)
...
...
@@ -86,7 +86,7 @@ func createTransfer(cmd *cobra.Command, args []string) {
toAddr
,
_
:=
cmd
.
Flags
()
.
GetString
(
"to"
)
amount
,
_
:=
cmd
.
Flags
()
.
GetFloat64
(
"amount"
)
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
{
fmt
.
Fprintln
(
os
.
Stderr
,
err
)
return
...
...
@@ -119,12 +119,12 @@ func createWithdraw(cmd *cobra.Command, args []string) {
exec
,
_
:=
cmd
.
Flags
()
.
GetString
(
"exec"
)
amount
,
_
:=
cmd
.
Flags
()
.
GetFloat64
(
"amount"
)
note
,
_
:=
cmd
.
Flags
()
.
GetString
(
"note"
)
execAddr
,
err
:=
GetExecAddr
(
exec
)
execAddr
,
err
:=
commandtypes
.
GetExecAddr
(
exec
)
if
err
!=
nil
{
fmt
.
Fprintln
(
os
.
Stderr
,
err
)
return
}
txHex
,
err
:=
CreateRawTx
(
cmd
,
execAddr
,
amount
,
note
,
true
,
""
,
exec
)
txHex
,
err
:=
commandtypes
.
CreateRawTx
(
cmd
,
execAddr
,
amount
,
note
,
true
,
""
,
exec
)
if
err
!=
nil
{
fmt
.
Fprintln
(
os
.
Stderr
,
err
)
return
...
...
@@ -157,12 +157,12 @@ func sendToExec(cmd *cobra.Command, args []string) {
exec
,
_
:=
cmd
.
Flags
()
.
GetString
(
"exec"
)
amount
,
_
:=
cmd
.
Flags
()
.
GetFloat64
(
"amount"
)
note
,
_
:=
cmd
.
Flags
()
.
GetString
(
"note"
)
execAddr
,
err
:=
GetExecAddr
(
exec
)
execAddr
,
err
:=
commandtypes
.
GetExecAddr
(
exec
)
if
err
!=
nil
{
fmt
.
Fprintln
(
os
.
Stderr
,
err
)
return
}
txHex
,
err
:=
CreateRawTx
(
cmd
,
execAddr
,
amount
,
note
,
false
,
""
,
exec
)
txHex
,
err
:=
commandtypes
.
CreateRawTx
(
cmd
,
execAddr
,
amount
,
note
,
false
,
""
,
exec
)
if
err
!=
nil
{
fmt
.
Fprintln
(
os
.
Stderr
,
err
)
return
...
...
@@ -201,7 +201,7 @@ func transfer(cmd *cobra.Command, args []string) {
amount
,
_
:=
cmd
.
Flags
()
.
GetFloat64
(
"amount"
)
note
,
_
:=
cmd
.
Flags
()
.
GetString
(
"note"
)
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
...
...
@@ -234,13 +234,13 @@ func withdraw(cmd *cobra.Command, args []string) {
exec
,
_
:=
cmd
.
Flags
()
.
GetString
(
"exec"
)
amount
,
_
:=
cmd
.
Flags
()
.
GetFloat64
(
"amount"
)
note
,
_
:=
cmd
.
Flags
()
.
GetString
(
"note"
)
execAddr
,
err
:=
GetExecAddr
(
exec
)
execAddr
,
err
:=
commandtypes
.
GetExecAddr
(
exec
)
if
err
!=
nil
{
fmt
.
Fprintln
(
os
.
Stderr
,
err
)
return
}
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
...
...
@@ -348,7 +348,7 @@ func createPub2PrivTxFlags(cmd *cobra.Command) {
func
createPub2PrivTx
(
cmd
*
cobra
.
Command
,
args
[]
string
)
{
rpcLaddr
,
_
:=
cmd
.
Flags
()
.
GetString
(
"rpc_laddr"
)
pubkeypair
,
_
:=
cmd
.
Flags
()
.
GetString
(
"pubkeypair"
)
amount
:=
GetAmountValue
(
cmd
,
"amount"
)
amount
:=
commandtypes
.
GetAmountValue
(
cmd
,
"amount"
)
tokenname
,
_
:=
cmd
.
Flags
()
.
GetString
(
"tokenname"
)
note
,
_
:=
cmd
.
Flags
()
.
GetString
(
"note"
)
expire
,
_
:=
cmd
.
Flags
()
.
GetInt64
(
"expire"
)
...
...
@@ -375,7 +375,7 @@ func createPub2PrivTx(cmd *cobra.Command, args []string) {
Pubkeypair
:
pubkeypair
,
Expire
:
expire
,
}
ctx
:=
jsonclient
.
NewR
pc
Ctx
(
rpcLaddr
,
"privacy.CreateRawTransaction"
,
params
,
nil
)
ctx
:=
jsonclient
.
NewR
PC
Ctx
(
rpcLaddr
,
"privacy.CreateRawTransaction"
,
params
,
nil
)
ctx
.
RunWithoutMarshal
()
}
...
...
@@ -407,7 +407,7 @@ func createPriv2PrivTxFlags(cmd *cobra.Command) {
func
createPriv2PrivTx
(
cmd
*
cobra
.
Command
,
args
[]
string
)
{
rpcLaddr
,
_
:=
cmd
.
Flags
()
.
GetString
(
"rpc_laddr"
)
pubkeypair
,
_
:=
cmd
.
Flags
()
.
GetString
(
"pubkeypair"
)
amount
:=
GetAmountValue
(
cmd
,
"amount"
)
amount
:=
commandtypes
.
GetAmountValue
(
cmd
,
"amount"
)
tokenname
,
_
:=
cmd
.
Flags
()
.
GetString
(
"tokenname"
)
note
,
_
:=
cmd
.
Flags
()
.
GetString
(
"note"
)
sender
,
_
:=
cmd
.
Flags
()
.
GetString
(
"sender"
)
...
...
@@ -437,7 +437,7 @@ func createPriv2PrivTx(cmd *cobra.Command, args []string) {
Mixcount
:
defaultPrivacyMixCount
,
Expire
:
expire
,
}
ctx
:=
jsonclient
.
NewR
pc
Ctx
(
rpcLaddr
,
"privacy.CreateRawTransaction"
,
params
,
nil
)
ctx
:=
jsonclient
.
NewR
PC
Ctx
(
rpcLaddr
,
"privacy.CreateRawTransaction"
,
params
,
nil
)
ctx
.
RunWithoutMarshal
()
}
...
...
@@ -468,7 +468,7 @@ func createPriv2PubTxFlags(cmd *cobra.Command) {
func
createPriv2PubTx
(
cmd
*
cobra
.
Command
,
args
[]
string
)
{
rpcLaddr
,
_
:=
cmd
.
Flags
()
.
GetString
(
"rpc_laddr"
)
amount
:=
GetAmountValue
(
cmd
,
"amount"
)
amount
:=
commandtypes
.
GetAmountValue
(
cmd
,
"amount"
)
tokenname
,
_
:=
cmd
.
Flags
()
.
GetString
(
"tokenname"
)
from
,
_
:=
cmd
.
Flags
()
.
GetString
(
"from"
)
to
,
_
:=
cmd
.
Flags
()
.
GetString
(
"to"
)
...
...
@@ -499,6 +499,6 @@ func createPriv2PubTx(cmd *cobra.Command, args []string) {
Mixcount
:
defaultPrivacyMixCount
,
Expire
:
expire
,
}
ctx
:=
jsonclient
.
NewR
pc
Ctx
(
rpcLaddr
,
"privacy.CreateRawTransaction"
,
params
,
nil
)
ctx
:=
jsonclient
.
NewR
PC
Ctx
(
rpcLaddr
,
"privacy.CreateRawTransaction"
,
params
,
nil
)
ctx
.
RunWithoutMarshal
()
}
vendor/github.com/33cn/chain33/system/dapp/commands/mempool.go
View file @
8fa8f27b
...
...
@@ -7,7 +7,7 @@ package commands
import
(
"github.com/33cn/chain33/rpc/jsonclient"
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"
)
...
...
@@ -40,16 +40,16 @@ func GetMempoolCmd() *cobra.Command {
func
listMempoolTxs
(
cmd
*
cobra
.
Command
,
args
[]
string
)
{
rpcLaddr
,
_
:=
cmd
.
Flags
()
.
GetString
(
"rpc_laddr"
)
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
.
Run
()
}
func
parseListMempoolTxsRes
(
arg
interface
{})
(
interface
{},
error
)
{
res
:=
arg
.
(
*
rpctypes
.
ReplyTxList
)
var
result
TxListResult
var
result
types
.
TxListResult
for
_
,
v
:=
range
res
.
Txs
{
result
.
Txs
=
append
(
result
.
Txs
,
DecodeTransaction
(
v
))
result
.
Txs
=
append
(
result
.
Txs
,
types
.
DecodeTransaction
(
v
))
}
return
result
,
nil
}
...
...
@@ -67,16 +67,16 @@ func GetLastMempoolCmd() *cobra.Command {
func
lastMempoolTxs
(
cmd
*
cobra
.
Command
,
args
[]
string
)
{
rpcLaddr
,
_
:=
cmd
.
Flags
()
.
GetString
(
"rpc_laddr"
)
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
.
Run
()
}
func
parselastMempoolTxsRes
(
arg
interface
{})
(
interface
{},
error
)
{
res
:=
arg
.
(
*
rpctypes
.
ReplyTxList
)
var
result
TxListResult
var
result
types
.
TxListResult
for
_
,
v
:=
range
res
.
Txs
{
result
.
Txs
=
append
(
result
.
Txs
,
DecodeTransaction
(
v
))
result
.
Txs
=
append
(
result
.
Txs
,
types
.
DecodeTransaction
(
v
))
}
return
result
,
nil
}
vendor/github.com/33cn/chain33/system/dapp/commands/net.go
View file @
8fa8f27b
...
...
@@ -44,7 +44,7 @@ func GetPeerInfoCmd() *cobra.Command {
func
peerInfo
(
cmd
*
cobra
.
Command
,
args
[]
string
)
{
rpcLaddr
,
_
:=
cmd
.
Flags
()
.
GetString
(
"rpc_laddr"
)
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
()
}
...
...
@@ -61,7 +61,7 @@ func IsClockSyncCmd() *cobra.Command {
func
isClockSync
(
cmd
*
cobra
.
Command
,
args
[]
string
)
{
rpcLaddr
,
_
:=
cmd
.
Flags
()
.
GetString
(
"rpc_laddr"
)
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
()
}
...
...
@@ -78,7 +78,7 @@ func IsSyncCmd() *cobra.Command {
func
isSync
(
cmd
*
cobra
.
Command
,
args
[]
string
)
{
rpcLaddr
,
_
:=
cmd
.
Flags
()
.
GetString
(
"rpc_laddr"
)
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
()
}
...
...
@@ -95,7 +95,7 @@ func GetNetInfoCmd() *cobra.Command {
func
netInfo
(
cmd
*
cobra
.
Command
,
args
[]
string
)
{
rpcLaddr
,
_
:=
cmd
.
Flags
()
.
GetString
(
"rpc_laddr"
)
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
()
}
...
...
@@ -112,7 +112,7 @@ func GetFatalFailureCmd() *cobra.Command {
func
fatalFailure
(
cmd
*
cobra
.
Command
,
args
[]
string
)
{
rpcLaddr
,
_
:=
cmd
.
Flags
()
.
GetString
(
"rpc_laddr"
)
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
()
}
...
...
@@ -129,6 +129,6 @@ func GetTimeStausCmd() *cobra.Command {
func
timestatus
(
cmd
*
cobra
.
Command
,
args
[]
string
)
{
rpcLaddr
,
_
:=
cmd
.
Flags
()
.
GetString
(
"rpc_laddr"
)
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
()
}
vendor/github.com/33cn/chain33/system/dapp/commands/seed.go
View file @
8fa8f27b
...
...
@@ -51,7 +51,7 @@ func genSeed(cmd *cobra.Command, args []string) {
Lang
:
lang
,
}
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
()
}
...
...
@@ -78,7 +78,7 @@ func getSeed(cmd *cobra.Command, args []string) {
Passwd
:
pwd
,
}
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
()
}
...
...
@@ -110,6 +110,6 @@ func saveSeed(cmd *cobra.Command, args []string) {
Passwd
:
pwd
,
}
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
()
}
vendor/github.com/33cn/chain33/system/dapp/commands/stat.go
View file @
8fa8f27b
...
...
@@ -19,7 +19,7 @@ import (
"github.com/33cn/chain33/common"
"github.com/33cn/chain33/common/difficulty"
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/spf13/cobra"
)
...
...
@@ -111,7 +111,7 @@ func totalCoins(cmd *cobra.Command, args []string) {
// 查询高度哈希对应数据
var
totalAmount
int64
resp
:=
GetTotalCoinsResult
{}
resp
:=
commandtypes
.
GetTotalCoinsResult
{}
if
symbol
==
"bty"
{
//查询高度blockhash
...
...
@@ -249,7 +249,7 @@ func ticketStat(cmd *cobra.Command, args []string) {
return
}
var
resp
GetTicketStatisticResult
var
resp
commandtypes
.
GetTicketStatisticResult
resp
.
CurrentOpenCount
=
res
.
CurrentOpenCount
resp
.
TotalMinerCount
=
res
.
TotalMinerCount
resp
.
TotalCloseCount
=
res
.
TotalCancleCount
...
...
@@ -281,7 +281,7 @@ func addTicketInfoCmdFlags(cmd *cobra.Command) {
func
ticketInfo
(
cmd
*
cobra
.
Command
,
args
[]
string
)
{
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
)
if
err
!=
nil
{
...
...
@@ -289,7 +289,7 @@ func ticketInfo(cmd *cobra.Command, args []string) {
return
}
key
:=
[]
byte
(
"Statistics:TicketInfo:TicketId:"
+
ticketI
d
)
key
:=
[]
byte
(
"Statistics:TicketInfo:TicketId:"
+
ticketI
D
)
fmt
.
Println
(
string
(
key
))
params
:=
types
.
LocalDBGet
{
Keys
:
[][]
byte
{
key
}}
var
res
types
.
TicketMinerInfo
...
...
@@ -299,8 +299,8 @@ func ticketInfo(cmd *cobra.Command, args []string) {
return
}
var
resp
GetTicketMinerInfoResult
resp
.
TicketI
d
=
res
.
TicketId
var
resp
commandtypes
.
GetTicketMinerInfoResult
resp
.
TicketI
D
=
res
.
TicketId
switch
res
.
Status
{
case
1
:
resp
.
Status
=
"openTicket"
...
...
@@ -360,7 +360,7 @@ func ticketInfoList(cmd *cobra.Command, args []string) {
count
,
_
:=
cmd
.
Flags
()
.
GetInt32
(
"count"
)
direction
,
_
:=
cmd
.
Flags
()
.
GetInt32
(
"direction"
)
createTime
,
_
:=
cmd
.
Flags
()
.
GetString
(
"create_time"
)
ticketI
d
,
_
:=
cmd
.
Flags
()
.
GetString
(
"ticket_id"
)
ticketI
D
,
_
:=
cmd
.
Flags
()
.
GetString
(
"ticket_id"
)
if
count
<=
0
{
fmt
.
Fprintln
(
os
.
Stderr
,
fmt
.
Errorf
(
"input err, count:%v"
,
count
))
...
...
@@ -375,8 +375,8 @@ func ticketInfoList(cmd *cobra.Command, args []string) {
var
key
[]
byte
prefix
:=
[]
byte
(
"Statistics:TicketInfoOrder:Addr:"
+
addr
)
if
ticketI
d
!=
""
&&
createTime
!=
""
{
key
=
[]
byte
(
"Statistics:TicketInfoOrder:Addr:"
+
addr
+
":CreateTime:"
+
createTime
+
":TicketId:"
+
ticketI
d
)
if
ticketI
D
!=
""
&&
createTime
!=
""
{
key
=
[]
byte
(
"Statistics:TicketInfoOrder:Addr:"
+
addr
+
":CreateTime:"
+
createTime
+
":TicketId:"
+
ticketI
D
)
}
fmt
.
Println
(
string
(
prefix
))
fmt
.
Println
(
string
(
key
))
...
...
@@ -388,10 +388,10 @@ func ticketInfoList(cmd *cobra.Command, args []string) {
return
}
var
resp
[]
GetTicketMinerInfoResult
var
resp
[]
commandtypes
.
GetTicketMinerInfoResult
for
_
,
v
:=
range
res
{
var
ticket
GetTicketMinerInfoResult
ticket
.
TicketI
d
=
v
.
TicketId
var
ticket
commandtypes
.
GetTicketMinerInfoResult
ticket
.
TicketI
D
=
v
.
TicketId
switch
v
.
Status
{
case
1
:
...
...
@@ -714,7 +714,7 @@ func execBalance(cmd *cobra.Command, args []string) {
return
}
resp
:=
GetExecBalanceResult
{}
resp
:=
commandtypes
.
GetExecBalanceResult
{}
if
symbol
==
"bty"
{
exec
=
"coins"
...
...
@@ -787,13 +787,13 @@ func execBalance(cmd *cobra.Command, args []string) {
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
.
AmountFrozen
=
strconv
.
FormatFloat
(
float64
(
reply
.
AmountFrozen
)
/
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
++
{
item
:=
&
ExecBalance
{}
item
:=
&
commandtypes
.
ExecBalance
{}
item
.
ExecAddr
=
string
(
reply
.
Items
[
i
]
.
ExecAddr
)
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
)
...
...
vendor/github.com/33cn/chain33/system/dapp/commands/tx.go
View file @
8fa8f27b
...
...
@@ -15,7 +15,7 @@ import (
"github.com/33cn/chain33/common"
"github.com/33cn/chain33/rpc/jsonclient"
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/spf13/cobra"
)
...
...
@@ -79,7 +79,7 @@ func queryTxByAddr(cmd *cobra.Command, args []string) {
Index
:
index
,
}
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
()
}
...
...
@@ -110,7 +110,7 @@ func queryTx(cmd *cobra.Command, args []string) {
Hash
:
hash
,
}
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
.
Run
()
}
...
...
@@ -118,8 +118,8 @@ func queryTx(cmd *cobra.Command, args []string) {
func
parseQueryTxRes
(
arg
interface
{})
(
interface
{},
error
)
{
res
:=
arg
.
(
*
rpctypes
.
TransactionDetail
)
amountResult
:=
strconv
.
FormatFloat
(
float64
(
res
.
Amount
)
/
float64
(
types
.
Coin
),
'f'
,
4
,
64
)
result
:=
TxDetailResult
{
Tx
:
DecodeTransaction
(
res
.
Tx
),
result
:=
commandtypes
.
TxDetailResult
{
Tx
:
commandtypes
.
DecodeTransaction
(
res
.
Tx
),
Receipt
:
res
.
Receipt
,
Proofs
:
res
.
Proofs
,
Height
:
res
.
Height
,
...
...
@@ -158,21 +158,21 @@ func getTxsByHashes(cmd *cobra.Command, args []string) {
}
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
.
Run
()
}
func
parseQueryTxsByHashesRes
(
arg
interface
{})
(
interface
{},
error
)
{
var
result
TxDetailsResult
var
result
commandtypes
.
TxDetailsResult
for
_
,
v
:=
range
arg
.
(
*
rpctypes
.
TransactionDetails
)
.
Txs
{
if
v
==
nil
{
result
.
Txs
=
append
(
result
.
Txs
,
nil
)
continue
}
amountResult
:=
strconv
.
FormatFloat
(
float64
(
v
.
Amount
)
/
float64
(
types
.
Coin
),
'f'
,
4
,
64
)
td
:=
TxDetailResult
{
Tx
:
DecodeTransaction
(
v
.
Tx
),
td
:=
commandtypes
.
TxDetailResult
{
Tx
:
commandtypes
.
DecodeTransaction
(
v
.
Tx
),
Receipt
:
v
.
Receipt
,
Proofs
:
v
.
Proofs
,
Height
:
v
.
Height
,
...
...
@@ -211,7 +211,7 @@ func getTxHexByHash(cmd *cobra.Command, args []string) {
Hash
:
txHash
,
}
ctx
:=
jsonclient
.
NewR
pc
Ctx
(
rpcLaddr
,
"Chain33.GetHexTxByHash"
,
params
,
nil
)
ctx
:=
jsonclient
.
NewR
PC
Ctx
(
rpcLaddr
,
"Chain33.GetHexTxByHash"
,
params
,
nil
)
ctx
.
RunWithoutMarshal
()
}
...
...
@@ -252,7 +252,7 @@ func decodeTx(cmd *cobra.Command, args []string) {
return
}
txResult
:=
DecodeTransaction
(
res
)
txResult
:=
commandtypes
.
DecodeTransaction
(
res
)
result
,
err
:=
json
.
MarshalIndent
(
txResult
,
""
,
" "
)
if
err
!=
nil
{
...
...
@@ -287,7 +287,7 @@ func viewAddress(cmd *cobra.Command, args []string) {
}
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
.
Run
()
}
...
...
@@ -296,7 +296,7 @@ func parseAddrOverview(view interface{}) (interface{}, error) {
res
:=
view
.
(
*
types
.
AddrOverview
)
balance
:=
strconv
.
FormatFloat
(
float64
(
res
.
GetBalance
())
/
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
,
Receiver
:
receiver
,
TxCount
:
res
.
GetTxCount
(),
...
...
vendor/github.com/33cn/chain33/system/dapp/commands/types/types.go
View file @
8fa8f27b
...
...
@@ -156,7 +156,7 @@ type GetTicketStatisticResult struct {
// GetTicketMinerInfoResult defines ticker minerinformation result rpc command
type
GetTicketMinerInfoResult
struct
{
TicketI
d
string
`json:"ticketId"`
TicketI
D
string
`json:"ticketId"`
Status
string
`json:"status"`
PrevStatus
string
`json:"prevStatus"`
IsGenesis
bool
`json:"isGenesis"`
...
...
@@ -256,7 +256,7 @@ type HashlockLockCLI struct {
type
TicketMinerCLI
struct
{
Bits
uint32
`json:"bits,omitempty"`
Reward
string
`json:"reward,omitempty"`
TicketI
d
string
`json:"ticketId,omitempty"`
TicketI
D
string
`json:"ticketId,omitempty"`
Modify
[]
byte
`json:"modify,omitempty"`
}
...
...
vendor/github.com/33cn/chain33/system/dapp/commands/types/utils.go
View file @
8fa8f27b
...
...
@@ -71,7 +71,7 @@ func SendToAddress(rpcAddr string, from string, to string, amount int64, note st
}
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
()
}
...
...
vendor/github.com/33cn/chain33/system/dapp/commands/version.go
View file @
8fa8f27b
...
...
@@ -23,6 +23,6 @@ func VersionCmd() *cobra.Command {
func
version
(
cmd
*
cobra
.
Command
,
args
[]
string
)
{
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
()
}
vendor/github.com/33cn/chain33/system/dapp/commands/wallet.go
View file @
8fa8f27b
...
...
@@ -14,7 +14,7 @@ import (
"github.com/33cn/chain33/rpc/jsonclient"
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/spf13/cobra"
)
...
...
@@ -57,7 +57,7 @@ func LockCmd() *cobra.Command {
func
lock
(
cmd
*
cobra
.
Command
,
args
[]
string
)
{
rpcLaddr
,
_
:=
cmd
.
Flags
()
.
GetString
(
"rpc_laddr"
)
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
()
}
...
...
@@ -102,7 +102,7 @@ func unLock(cmd *cobra.Command, args []string) {
WalletOrTicket
:
walletOrTicket
,
}
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
()
}
...
...
@@ -119,7 +119,7 @@ func WalletStatusCmd() *cobra.Command {
func
walletStatus
(
cmd
*
cobra
.
Command
,
args
[]
string
)
{
rpcLaddr
,
_
:=
cmd
.
Flags
()
.
GetString
(
"rpc_laddr"
)
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
()
}
...
...
@@ -151,7 +151,7 @@ func setPwd(cmd *cobra.Command, args []string) {
NewPass
:
newPwd
,
}
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
()
}
...
...
@@ -187,18 +187,18 @@ func walletListTxs(cmd *cobra.Command, args []string) {
Direction
:
direction
,
}
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
.
Run
()
}
func
parseWalletTxListRes
(
arg
interface
{})
(
interface
{},
error
)
{
res
:=
arg
.
(
*
rpctypes
.
WalletTxDetails
)
var
result
WalletTxDetailsResult
var
result
commandtypes
.
WalletTxDetailsResult
for
_
,
v
:=
range
res
.
TxDetails
{
amountResult
:=
strconv
.
FormatFloat
(
float64
(
v
.
Amount
)
/
float64
(
types
.
Coin
),
'f'
,
4
,
64
)
wtxd
:=
&
WalletTxDetailResult
{
Tx
:
DecodeTransaction
(
v
.
Tx
),
wtxd
:=
&
commandtypes
.
WalletTxDetailResult
{
Tx
:
commandtypes
.
DecodeTransaction
(
v
.
Tx
),
Receipt
:
v
.
Receipt
,
Height
:
v
.
Height
,
Index
:
v
.
Index
,
...
...
@@ -236,7 +236,7 @@ func mergeBalance(cmd *cobra.Command, args []string) {
To
:
toAddr
,
}
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
()
}
...
...
@@ -269,7 +269,7 @@ func autoMine(cmd *cobra.Command, args []string) {
Flag
:
flag
,
}
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
()
}
...
...
@@ -338,7 +338,7 @@ func noBalanceTx(cmd *cobra.Command, args []string) {
Expire
:
expire
,
Privkey
:
privkey
,
}
ctx
:=
jsonclient
.
NewR
pc
Ctx
(
rpcLaddr
,
"Chain33.CreateNoBalanceTransaction"
,
params
,
nil
)
ctx
:=
jsonclient
.
NewR
PC
Ctx
(
rpcLaddr
,
"Chain33.CreateNoBalanceTransaction"
,
params
,
nil
)
ctx
.
RunWithoutMarshal
()
}
...
...
@@ -414,7 +414,7 @@ func signRawTx(cmd *cobra.Command, args []string) {
Expire
:
expire
,
Index
:
index
,
}
ctx
:=
jsonclient
.
NewR
pc
Ctx
(
rpcLaddr
,
"Chain33.SignRawTx"
,
params
,
nil
)
ctx
:=
jsonclient
.
NewR
PC
Ctx
(
rpcLaddr
,
"Chain33.SignRawTx"
,
params
,
nil
)
ctx
.
RunWithoutMarshal
()
}
...
...
@@ -442,7 +442,7 @@ func setFee(cmd *cobra.Command, args []string) {
Amount
:
amountInt64
*
1e4
,
}
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
()
}
...
...
@@ -473,6 +473,6 @@ func sendTx(cmd *cobra.Command, args []string) {
Data
:
data
,
}
ctx
:=
jsonclient
.
NewR
pc
Ctx
(
rpcLaddr
,
"Chain33.SendTransaction"
,
params
,
nil
)
ctx
:=
jsonclient
.
NewR
PC
Ctx
(
rpcLaddr
,
"Chain33.SendTransaction"
,
params
,
nil
)
ctx
.
RunWithoutMarshal
()
}
vendor/github.com/33cn/chain33/system/dapp/driver.go
View file @
8fa8f27b
...
...
@@ -53,7 +53,7 @@ type Driver interface {
ExecDelLocal
(
tx
*
types
.
Transaction
,
receipt
*
types
.
ReceiptData
,
index
int
)
(
*
types
.
LocalDBSet
,
error
)
Query
(
funcName
string
,
params
[]
byte
)
(
types
.
Message
,
error
)
IsFree
()
bool
SetA
pi
(
client
.
QueueProtocolAPI
)
SetA
PI
(
client
.
QueueProtocolAPI
)
SetTxs
(
txs
[]
*
types
.
Transaction
)
SetReceipt
(
receipts
[]
*
types
.
ReceiptData
)
...
...
@@ -63,6 +63,7 @@ type Driver interface {
GetPayloadValue
()
types
.
Message
GetFuncMap
()
map
[
string
]
reflect
.
Method
GetExecutorType
()
types
.
ExecutorType
CheckReceiptExecOk
()
bool
}
// DriverBase defines driverbase type
...
...
@@ -105,13 +106,13 @@ func (d *DriverBase) GetFuncMap() map[string]reflect.Method {
return
d
.
ety
.
GetExecFuncMap
()
}
// SetA
pi
set queue protocol api
func
(
d
*
DriverBase
)
SetA
pi
(
api
client
.
QueueProtocolAPI
)
{
// SetA
PI
set queue protocol api
func
(
d
*
DriverBase
)
SetA
PI
(
api
client
.
QueueProtocolAPI
)
{
d
.
api
=
api
}
// GetA
pi
return queue protocol api
func
(
d
*
DriverBase
)
GetA
pi
()
client
.
QueueProtocolAPI
{
// GetA
PI
return queue protocol api
func
(
d
*
DriverBase
)
GetA
PI
()
client
.
QueueProtocolAPI
{
return
d
.
api
}
...
...
@@ -177,6 +178,13 @@ func (d *DriverBase) callLocal(prefix string, tx *types.Transaction, receipt *ty
if
d
.
ety
==
nil
{
return
nil
,
types
.
ErrActionNotSupport
}
if
d
.
child
.
CheckReceiptExecOk
()
{
if
receipt
.
GetTy
()
!=
types
.
ExecOk
{
return
&
types
.
LocalDBSet
{},
nil
}
}
defer
func
()
{
if
r
:=
recover
();
r
!=
nil
{
blog
.
Error
(
"call localexec error"
,
"prefix"
,
prefix
,
"tx.exec"
,
tx
.
Execer
,
"info"
,
r
)
...
...
@@ -416,3 +424,8 @@ func (d *DriverBase) GetTxs() []*types.Transaction {
func
(
d
*
DriverBase
)
SetTxs
(
txs
[]
*
types
.
Transaction
)
{
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 @
8fa8f27b
...
...
@@ -107,6 +107,6 @@ func queryConfig(cmd *cobra.Command, args []string) {
params
.
Payload
=
req
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
()
}
vendor/github.com/33cn/chain33/system/dapp/manage/executor/exec_del_local.go
View file @
8fa8f27b
...
...
@@ -18,9 +18,6 @@ func localKey(key string) []byte {
// 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
)
{
set
:=
&
types
.
LocalDBSet
{}
if
receipt
.
GetTy
()
!=
types
.
ExecOk
{
return
set
,
nil
}
for
i
:=
0
;
i
<
len
(
receipt
.
Logs
);
i
++
{
item
:=
receipt
.
Logs
[
i
]
...
...
vendor/github.com/33cn/chain33/system/dapp/manage/executor/exec_local.go
View file @
8fa8f27b
...
...
@@ -12,10 +12,6 @@ import (
// 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
)
{
set
:=
&
types
.
LocalDBSet
{}
if
receipt
.
GetTy
()
!=
types
.
ExecOk
{
return
set
,
nil
}
for
i
:=
0
;
i
<
len
(
receipt
.
Logs
);
i
++
{
item
:=
receipt
.
Logs
[
i
]
if
item
.
Ty
==
pty
.
ManageActionModifyConfig
{
...
...
vendor/github.com/33cn/chain33/system/dapp/manage/executor/manage.go
View file @
8fa8f27b
...
...
@@ -69,3 +69,8 @@ func IsSuperManager(addr string) bool {
}
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 @
8fa8f27b
...
...
@@ -9,6 +9,7 @@ import (
"fmt"
"sync"
"sort"
"sync/atomic"
"time"
...
...
@@ -20,15 +21,22 @@ import (
)
const
(
leafKeyCountPrefix
=
"..mk.."
delMapPoolPrefix
=
"_..md.._"
blockHeightStrLen
=
10
pruningStateStart
=
1
pruningStateEnd
=
0
leafKeyCountPrefix
=
"..mk.."
oldLeafKeyCountPrefix
=
"..mok.."
secLvlPruningHeightKey
=
"_..mslphk.._"
delMapPoolPrefix
=
"_..md.._"
blockHeightStrLen
=
10
pruningStateStart
=
1
pruningStateEnd
=
0
//删除节点pool以hash的首字母为key因此有256个
delNodeCacheSize
=
256
+
1
//每个del Pool下存放默认4096个hash
perDelNodePoolSize
=
4096
//二级裁剪高度,达到此高度未裁剪则放入该处
secondLevelPruningHeight
=
1000000
//三级裁剪高度,达到此高度还没有裁剪,则不进行裁剪
threeLevelPruningHeight
=
1500000
onceScanCount
=
100000
)
var
(
...
...
@@ -37,10 +45,11 @@ var (
// 每个10000裁剪一次
pruneHeight
=
10000
// 裁剪状态
pruningState
int32
delPoolCache
*
lru
.
Cache
wg
sync
.
WaitGroup
quit
bool
pruningState
int32
delPoolCache
*
lru
.
Cache
wg
sync
.
WaitGroup
quit
bool
secLvlPruningH
int64
)
func
init
()
{
...
...
@@ -108,6 +117,31 @@ func getKeyFromLeafCountKey(hashkey []byte, hashlen int) ([]byte, error) {
return
k
,
nil
}
func
genOldLeafCountKey
(
key
,
hash
[]
byte
,
height
int64
)
(
hashkey
[]
byte
)
{
hashkey
=
[]
byte
(
fmt
.
Sprintf
(
"%s%s%010d%s"
,
oldLeafKeyCountPrefix
,
string
(
key
),
height
,
string
(
hash
)))
return
hashkey
}
func
getKeyFromOldLeafCountKey
(
hashkey
[]
byte
,
hashlen
int
)
([]
byte
,
error
)
{
if
len
(
hashkey
)
<=
len
(
oldLeafKeyCountPrefix
)
+
hashlen
+
blockHeightStrLen
{
return
nil
,
types
.
ErrSize
}
if
!
bytes
.
Contains
(
hashkey
,
[]
byte
(
oldLeafKeyCountPrefix
))
{
return
nil
,
types
.
ErrSize
}
k
:=
bytes
.
TrimPrefix
(
hashkey
,
[]
byte
(
oldLeafKeyCountPrefix
))
k
=
k
[
:
len
(
k
)
-
hashlen
-
blockHeightStrLen
]
return
k
,
nil
}
func
genOldLeafCountKeyFromKey
(
hashk
[]
byte
)
(
oldhashk
[]
byte
)
{
if
len
(
hashk
)
<
len
(
leafKeyCountPrefix
)
{
return
hashk
}
oldhashk
=
[]
byte
(
fmt
.
Sprintf
(
"%s%s"
,
oldLeafKeyCountPrefix
,
string
(
hashk
[
len
(
leafKeyCountPrefix
)
:
])))
return
oldhashk
}
func
genDeletePoolKey
(
hash
[]
byte
)
(
key
,
value
[]
byte
)
{
if
len
(
hash
)
<
32
{
panic
(
"genDeletePoolKey error hash len illegal"
)
...
...
@@ -131,25 +165,55 @@ func setPruning(state int32) {
atomic
.
StoreInt32
(
&
pruningState
,
state
)
}
func
getSecLvlPruningHeight
(
db
dbm
.
DB
)
int64
{
value
,
err
:=
db
.
Get
([]
byte
(
secLvlPruningHeightKey
))
if
len
(
value
)
==
0
||
err
!=
nil
{
return
0
}
h
:=
&
types
.
Int64
{}
err
=
proto
.
Unmarshal
(
value
,
h
)
if
err
!=
nil
{
return
0
}
return
h
.
Data
}
func
setSecLvlPruningHeight
(
db
dbm
.
DB
,
height
int64
)
error
{
h
:=
&
types
.
Int64
{}
h
.
Data
=
height
value
,
err
:=
proto
.
Marshal
(
h
)
if
err
!=
nil
{
return
err
}
return
db
.
Set
([]
byte
(
secLvlPruningHeightKey
),
value
)
}
func
pruningTree
(
db
dbm
.
DB
,
curHeight
int64
)
{
wg
.
Add
(
1
)
defer
wg
.
Add
(
-
1
)
setPruning
(
pruningStateStart
)
treelog
.
Info
(
"pruningTree"
,
"start curHeight:"
,
curHeight
)
// 一级遍历
pruningFirstLevel
(
db
,
curHeight
)
// 二级遍历
pruningSecondLevel
(
db
,
curHeight
)
setPruning
(
pruningStateEnd
)
}
func
pruningFirstLevel
(
db
dbm
.
DB
,
curHeight
int64
)
{
treelog
.
Info
(
"pruningTree pruningFirstLevel"
,
"start curHeight:"
,
curHeight
)
start
:=
time
.
Now
()
pruning
TreeLeaf
Node
(
db
,
curHeight
)
pruning
FirstLevel
Node
(
db
,
curHeight
)
end
:=
time
.
Now
()
treelog
.
Info
(
"pruningTree"
,
"curHeight:"
,
curHeight
,
"pruning leafNode cost time:"
,
end
.
Sub
(
start
))
setPruning
(
pruningStateEnd
)
treelog
.
Info
(
"pruningTree pruningFirstLevel"
,
"curHeight:"
,
curHeight
,
"pruning leafNode cost time:"
,
end
.
Sub
(
start
))
}
func
pruning
TreeLeaf
Node
(
db
dbm
.
DB
,
curHeight
int64
)
{
func
pruning
FirstLevel
Node
(
db
dbm
.
DB
,
curHeight
int64
)
{
prefix
:=
[]
byte
(
leafKeyCountPrefix
)
it
:=
db
.
Iterator
(
prefix
,
nil
,
true
)
defer
it
.
Close
()
const
onceScanCount
=
100000
mp
:=
make
(
map
[
string
][]
hashData
)
var
kvs
[]
*
types
.
KeyValue
count
:=
0
for
it
.
Rewind
();
it
.
Valid
();
it
.
Next
()
{
if
quit
{
...
...
@@ -166,24 +230,47 @@ func pruningTreeLeafNode(db dbm.DB, curHeight int64) {
if
err
!=
nil
{
panic
(
"Unmarshal mavl leafCountKey fail"
)
}
hashLen
:=
int
(
pData
.
Lenth
)
key
,
err
:=
getKeyFromLeafCountKey
(
hashK
,
hashLen
)
if
err
==
nil
{
data
:=
hashData
{
height
:
pData
.
Height
,
hash
:
hashK
[
len
(
hashK
)
-
hashLen
:
],
}
mp
[
string
(
key
)]
=
append
(
mp
[
string
(
key
)],
data
)
count
++
if
count
>=
onceScanCount
{
deleteNode
(
db
,
mp
,
curHeight
,
key
)
count
=
0
var
key
[]
byte
if
curHeight
<
pData
.
Height
+
secondLevelPruningHeight
{
hashLen
:=
int
(
pData
.
Lenth
)
key
,
err
=
getKeyFromLeafCountKey
(
hashK
,
hashLen
)
if
err
==
nil
{
data
:=
hashData
{
height
:
pData
.
Height
,
hash
:
hashK
[
len
(
hashK
)
-
hashLen
:
],
}
mp
[
string
(
key
)]
=
append
(
mp
[
string
(
key
)],
data
)
count
++
}
}
else
{
value
:=
make
([]
byte
,
len
(
it
.
Value
()))
copy
(
value
,
it
.
Value
())
kvs
=
append
(
kvs
,
&
types
.
KeyValue
{
Key
:
hashK
,
Value
:
value
})
}
if
count
>=
onceScanCount
{
deleteNode
(
db
,
mp
,
curHeight
,
key
)
count
=
0
}
if
len
(
kvs
)
>=
onceScanCount
/
2
{
addLeafCountKeyToSecondLevel
(
db
,
kvs
)
kvs
=
kvs
[
:
0
]
}
}
if
count
>
0
{
deleteNode
(
db
,
mp
,
curHeight
,
nil
)
}
if
len
(
kvs
)
>
0
{
addLeafCountKeyToSecondLevel
(
db
,
kvs
)
}
}
func
addLeafCountKeyToSecondLevel
(
db
dbm
.
DB
,
kvs
[]
*
types
.
KeyValue
)
{
batch
:=
db
.
NewBatch
(
true
)
for
_
,
kv
:=
range
kvs
{
batch
.
Delete
(
kv
.
Key
)
batch
.
Set
(
genOldLeafCountKeyFromKey
(
kv
.
Key
),
kv
.
Value
)
}
batch
.
Write
()
}
func
deleteNode
(
db
dbm
.
DB
,
mp
map
[
string
][]
hashData
,
curHeight
int64
,
lastKey
[]
byte
)
{
...
...
@@ -229,9 +316,15 @@ func pruningHashNode(db dbm.DB, mp map[string]bool) {
if
len
(
mp
)
==
0
{
return
}
//对mp排序
sortKeys
:=
make
([]
string
,
len
(
mp
)
+
1
)
for
key
:=
range
mp
{
sortKeys
=
append
(
sortKeys
,
key
)
}
sort
.
Strings
(
sortKeys
)
ndb
:=
newMarkNodeDB
(
db
,
1024
*
10
)
var
delNodeStrs
[]
string
for
key
:=
range
mp
{
for
_
,
key
:=
range
sortKeys
{
mNode
,
err
:=
ndb
.
LoadLeaf
([]
byte
(
key
))
if
err
==
nil
{
delNodeStrs
=
append
(
delNodeStrs
,
mNode
.
getHashNode
(
ndb
)
...
)
...
...
@@ -375,7 +468,7 @@ type MarkNode struct {
}
type
markNodeDB
struct
{
mtx
sync
.
Mutex
//
mtx sync.Mutex
cache
*
lru
.
Cache
// 缓存当前批次已经删除的节点,
delPoolCache
*
lru
.
Cache
// 缓存全部的已经删除的节点
db
dbm
.
DB
...
...
@@ -415,8 +508,8 @@ func (ndb *markNodeDB) fetchNode(hash []byte) (*MarkNode, error) {
if
len
(
hash
)
==
0
{
return
nil
,
ErrNodeNotExist
}
ndb
.
mtx
.
Lock
()
defer
ndb
.
mtx
.
Unlock
()
//
ndb.mtx.Lock()
//
defer ndb.mtx.Unlock()
var
mNode
*
MarkNode
// cache
...
...
@@ -460,7 +553,111 @@ func (ndb *markNodeDB) fetchNode(hash []byte) (*MarkNode, error) {
return
mNode
,
nil
}
// PruningTreePrintDB 打印统计数据库中节点数据
func
pruningSecondLevel
(
db
dbm
.
DB
,
curHeight
int64
)
{
if
secLvlPruningH
==
0
{
secLvlPruningH
=
getSecLvlPruningHeight
(
db
)
}
if
curHeight
/
secondLevelPruningHeight
>
1
&&
curHeight
/
secondLevelPruningHeight
!=
secLvlPruningH
/
secondLevelPruningHeight
{
treelog
.
Info
(
"pruningTree pruningSecondLevel"
,
"start curHeight:"
,
curHeight
)
start
:=
time
.
Now
()
pruningSecondLevelNode
(
db
,
curHeight
)
end
:=
time
.
Now
()
treelog
.
Info
(
"pruningTree pruningSecondLevel"
,
"curHeight:"
,
curHeight
,
"pruning leafNode cost time:"
,
end
.
Sub
(
start
))
setSecLvlPruningHeight
(
db
,
curHeight
)
secLvlPruningH
=
curHeight
}
}
func
pruningSecondLevelNode
(
db
dbm
.
DB
,
curHeight
int64
)
{
prefix
:=
[]
byte
(
oldLeafKeyCountPrefix
)
it
:=
db
.
Iterator
(
prefix
,
nil
,
true
)
defer
it
.
Close
()
mp
:=
make
(
map
[
string
][]
hashData
)
count
:=
0
for
it
.
Rewind
();
it
.
Valid
();
it
.
Next
()
{
if
quit
{
//该处退出
return
}
//copy key
hashK
:=
make
([]
byte
,
len
(
it
.
Key
()))
copy
(
hashK
,
it
.
Key
())
value
:=
it
.
Value
()
var
pData
types
.
PruneData
err
:=
proto
.
Unmarshal
(
value
,
&
pData
)
if
err
!=
nil
{
panic
(
"Unmarshal mavl leafCountKey fail"
)
}
hashLen
:=
int
(
pData
.
Lenth
)
key
,
err
:=
getKeyFromOldLeafCountKey
(
hashK
,
hashLen
)
if
err
==
nil
{
data
:=
hashData
{
height
:
pData
.
Height
,
hash
:
hashK
[
len
(
hashK
)
-
hashLen
:
],
}
mp
[
string
(
key
)]
=
append
(
mp
[
string
(
key
)],
data
)
count
++
if
count
>=
onceScanCount
{
deleteOldNode
(
db
,
mp
,
curHeight
,
key
)
count
=
0
}
}
}
if
count
>
0
{
deleteOldNode
(
db
,
mp
,
curHeight
,
nil
)
}
}
func
deleteOldNode
(
db
dbm
.
DB
,
mp
map
[
string
][]
hashData
,
curHeight
int64
,
lastKey
[]
byte
)
{
if
len
(
mp
)
==
0
{
return
}
var
tmp
[]
hashData
//del
if
lastKey
!=
nil
{
if
_
,
ok
:=
mp
[
string
(
lastKey
)];
ok
{
tmp
=
mp
[
string
(
lastKey
)]
delete
(
mp
,
string
(
lastKey
))
}
}
delMp
:=
make
(
map
[
string
]
bool
)
batch
:=
db
.
NewBatch
(
true
)
for
key
,
vals
:=
range
mp
{
if
len
(
vals
)
>
1
{
if
vals
[
1
]
.
height
!=
vals
[
0
]
.
height
{
//防止相同高度时候出现的误删除
for
_
,
val
:=
range
vals
[
1
:
]
{
//从第二个开始判断
if
curHeight
>=
val
.
height
+
int64
(
pruneHeight
)
{
batch
.
Delete
(
genOldLeafCountKey
([]
byte
(
key
),
val
.
hash
,
val
.
height
))
delMp
[
string
(
val
.
hash
)]
=
true
}
}
}
else
{
// 删除第三层存储索引key
for
_
,
val
:=
range
vals
{
if
curHeight
>=
val
.
height
+
threeLevelPruningHeight
{
batch
.
Delete
(
genOldLeafCountKey
([]
byte
(
key
),
val
.
hash
,
val
.
height
))
}
}
}
}
else
if
len
(
vals
)
==
1
&&
curHeight
>=
vals
[
0
]
.
height
+
threeLevelPruningHeight
{
// 删除第三层存储索引key
batch
.
Delete
(
genLeafCountKey
([]
byte
(
key
),
vals
[
0
]
.
hash
,
vals
[
0
]
.
height
))
}
delete
(
mp
,
key
)
}
batch
.
Write
()
//add
if
lastKey
!=
nil
{
if
_
,
ok
:=
mp
[
string
(
lastKey
)];
ok
{
mp
[
string
(
lastKey
)]
=
tmp
}
}
//裁剪hashNode
pruningHashNode
(
db
,
delMp
)
}
func
PruningTreePrintDB
(
db
dbm
.
DB
,
prefix
[]
byte
)
{
it
:=
db
.
Iterator
(
prefix
,
nil
,
true
)
defer
it
.
Close
()
...
...
vendor/github.com/33cn/chain33/system/store/mavl/mavl_test.go
View file @
8fa8f27b
...
...
@@ -252,6 +252,7 @@ func TestIterateCallBack_Mode1(t *testing.T) {
KV
:
accountdb
.
GetExecKVSet
(
execAddr1
,
acc
),
Height
:
0
}
hash0
,
err
:=
store
.
Set
(
datas
,
true
)
assert
.
Nil
(
t
,
err
)
execAddr2
:=
"26htvcBNSEA7fZhAdLJphDwQRQJaHpyHTp"
datas
=
&
types
.
StoreSet
{
...
...
@@ -259,6 +260,7 @@ func TestIterateCallBack_Mode1(t *testing.T) {
KV
:
accountdb
.
GetExecKVSet
(
execAddr2
,
acc
),
Height
:
1
}
hash1
,
err
:=
store
.
Set
(
datas
,
true
)
assert
.
Nil
(
t
,
err
)
execAddr3
:=
"36htvcBNSEA7fZhAdLJphDwQRQJaHpyHTp"
datas
=
&
types
.
StoreSet
{
...
...
@@ -393,6 +395,7 @@ func TestIterateCallBack_Mode2(t *testing.T) {
KV
:
accountdb
.
GetExecKVSet
(
execAddr1
,
acc
),
Height
:
0
}
hash0
,
err
:=
store
.
Set
(
datas
,
true
)
assert
.
Nil
(
t
,
err
)
execAddr2
:=
"26htvcBNSEA7fZhAdLJphDwQRQJaHpyHTp"
datas
=
&
types
.
StoreSet
{
...
...
@@ -400,6 +403,7 @@ func TestIterateCallBack_Mode2(t *testing.T) {
KV
:
accountdb
.
GetExecKVSet
(
execAddr2
,
acc
),
Height
:
1
}
hash1
,
err
:=
store
.
Set
(
datas
,
true
)
assert
.
Nil
(
t
,
err
)
execAddr3
:=
"36htvcBNSEA7fZhAdLJphDwQRQJaHpyHTp"
datas
=
&
types
.
StoreSet
{
...
...
vendor/github.com/33cn/chain33/types/config.go
View file @
8fa8f27b
...
...
@@ -443,7 +443,7 @@ func mergeCfgString(cfgstring, cfgdefault string) string {
panic
(
errstr
)
}
buf
:=
new
(
bytes
.
Buffer
)
err
=
tml
.
NewEncoder
(
buf
)
.
Encode
(
conf
)
tml
.
NewEncoder
(
buf
)
.
Encode
(
conf
)
return
buf
.
String
()
}
...
...
vendor/github.com/33cn/chain33/types/types.go
View file @
8fa8f27b
...
...
@@ -369,7 +369,7 @@ func (r *ReceiptData) DecodeReceiptLog(execer []byte) (*ReceiptDataResult, error
return
nil
,
ErrLogType
}
logIns
,
err
=
logType
.
Decode
(
lLog
)
logIns
,
_
=
logType
.
Decode
(
lLog
)
lTy
=
logType
.
Name
()
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 @
8fa8f27b
...
...
@@ -36,7 +36,7 @@ var closeCmd = &cobra.Command{
// rpc, _ := jsonrpc.NewJSONClient(rpcLaddr)
// rpc.Call("Chain33.CloseQueue", nil, nil)
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
()
},
}
...
...
vendor/github.com/33cn/chain33/util/exec.go
View file @
8fa8f27b
...
...
@@ -74,6 +74,7 @@ func ExecKVSetCommit(client queue.Client, hash []byte) error {
return
err
}
hash
=
msg
.
GetData
()
.
(
*
types
.
ReplyHash
)
.
GetHash
()
_
=
hash
return
nil
}
...
...
@@ -87,6 +88,7 @@ func ExecKVSetRollback(client queue.Client, hash []byte) error {
return
err
}
hash
=
msg
.
GetData
()
.
(
*
types
.
ReplyHash
)
.
GetHash
()
_
=
hash
return
nil
}
...
...
vendor/github.com/33cn/chain33/util/util_test.go
View file @
8fa8f27b
...
...
@@ -20,7 +20,7 @@ func TestMakeStringUpper(t *testing.T) {
assert
.
NoError
(
t
,
err
)
assert
.
Equal
(
t
,
"abCDefg"
,
destStr
)
destStr
,
err
=
MakeStringToUpper
(
originStr
,
-
1
,
2
)
_
,
err
=
MakeStringToUpper
(
originStr
,
-
1
,
2
)
assert
.
Error
(
t
,
err
)
}
...
...
@@ -34,6 +34,6 @@ func TestMakeStringLower(t *testing.T) {
assert
.
NoError
(
t
,
err
)
assert
.
Equal
(
t
,
"ABcdEFG"
,
destStr
)
destStr
,
err
=
MakeStringToLower
(
originStr
,
-
1
,
2
)
_
,
err
=
MakeStringToLower
(
originStr
,
-
1
,
2
)
assert
.
Error
(
t
,
err
)
}
vendor/github.com/33cn/chain33/wallet/wallet_proc.go
View file @
8fa8f27b
...
...
@@ -258,7 +258,7 @@ func (wallet *Wallet) ProcCreateNewAccount(Label *types.ReqNewAccount) (*types.W
}
//首先校验label是否已被使用
WalletAccStores
,
err
:=
wallet
.
walletStore
.
GetAccountByLabel
(
Label
.
GetLabel
())
WalletAccStores
,
_
:=
wallet
.
walletStore
.
GetAccountByLabel
(
Label
.
GetLabel
())
if
WalletAccStores
!=
nil
{
walletlog
.
Error
(
"ProcCreateNewAccount Label is exist in wallet!"
)
return
nil
,
types
.
ErrLabelHasUsed
...
...
@@ -310,7 +310,7 @@ func (wallet *Wallet) ProcCreateNewAccount(Label *types.ReqNewAccount) (*types.W
}
//通过新生成的账户地址查询钱包数据库,如果查询返回的账户信息是空,
//说明新生成的账户没有被使用,否则继续使用下一个index生成私钥对
account
,
err
:=
wallet
.
walletStore
.
GetAccountByAddr
(
addr
)
account
,
_
:=
wallet
.
walletStore
.
GetAccountByAddr
(
addr
)
if
account
==
nil
{
break
}
...
...
@@ -417,7 +417,7 @@ func (wallet *Wallet) ProcImportPrivKey(PrivKey *types.ReqWalletImportPrivkey) (
}
//校验label是否已经被使用
Account
,
err
:=
wallet
.
walletStore
.
GetAccountByLabel
(
PrivKey
.
GetLabel
())
Account
,
_
:=
wallet
.
walletStore
.
GetAccountByLabel
(
PrivKey
.
GetLabel
())
if
Account
!=
nil
{
walletlog
.
Error
(
"ProcImportPrivKey Label is exist in wallet!"
)
return
nil
,
types
.
ErrLabelHasUsed
...
...
@@ -453,7 +453,7 @@ func (wallet *Wallet) ProcImportPrivKey(PrivKey *types.ReqWalletImportPrivkey) (
Encryptered
:=
wcom
.
CBCEncrypterPrivkey
([]
byte
(
wallet
.
Password
),
privkeybyte
)
Encrypteredstr
:=
common
.
ToHex
(
Encryptered
)
//校验PrivKey对应的addr是否已经存在钱包中
Account
,
err
=
wallet
.
walletStore
.
GetAccountByAddr
(
addr
)
Account
,
_
=
wallet
.
walletStore
.
GetAccountByAddr
(
addr
)
if
Account
!=
nil
{
if
Account
.
Privkey
==
Encrypteredstr
{
walletlog
.
Error
(
"ProcImportPrivKey Privkey is exist in wallet!"
)
...
...
@@ -613,13 +613,13 @@ func (wallet *Wallet) ProcWalletSetLabel(SetLabel *types.ReqWalletSetLabel) (*ty
return
nil
,
types
.
ErrInvalidParam
}
//校验label是否已经被使用
Account
,
err
:=
wallet
.
walletStore
.
GetAccountByLabel
(
SetLabel
.
GetLabel
())
Account
,
_
:=
wallet
.
walletStore
.
GetAccountByLabel
(
SetLabel
.
GetLabel
())
if
Account
!=
nil
{
walletlog
.
Error
(
"ProcWalletSetLabel Label is exist in wallet!"
)
return
nil
,
types
.
ErrLabelHasUsed
}
//获取地址对应的账户信息从钱包中,然后修改label
Account
,
err
=
wallet
.
walletStore
.
GetAccountByAddr
(
SetLabel
.
Addr
)
Account
,
err
:
=
wallet
.
walletStore
.
GetAccountByAddr
(
SetLabel
.
Addr
)
if
err
==
nil
&&
Account
!=
nil
{
oldLabel
:=
Account
.
Label
Account
.
Label
=
SetLabel
.
GetLabel
()
...
...
@@ -1177,7 +1177,7 @@ func (wallet *Wallet) SaveSeed(password string, seed string) (bool, error) {
func
(
wallet
*
Wallet
)
saveSeed
(
password
string
,
seed
string
)
(
bool
,
error
)
{
//首先需要判断钱包是否已经设置seed,如果已经设置提示不需要再设置,一个钱包只能保存一个seed
exit
,
err
:=
wallet
.
walletStore
.
HasSeed
()
exit
,
_
:=
wallet
.
walletStore
.
HasSeed
()
if
exit
{
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