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
4c49bccd
Commit
4c49bccd
authored
Jun 06, 2019
by
vipwzw
Committed by
vipwzw
Jun 06, 2019
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
update chain33 06/06
parent
57150865
Hide whitespace changes
Inline
Side-by-side
Showing
12 changed files
with
76 additions
and
43 deletions
+76
-43
query_tx.go
vendor/github.com/33cn/chain33/blockchain/query_tx.go
+1
-6
const.go
vendor/github.com/33cn/chain33/p2p/const.go
+7
-9
p2pcli.go
vendor/github.com/33cn/chain33/p2p/p2pcli.go
+13
-6
jrpchandler.go
vendor/github.com/33cn/chain33/rpc/jrpchandler.go
+5
-0
jrpchandler_test.go
vendor/github.com/33cn/chain33/rpc/jrpchandler_test.go
+18
-0
code.go
vendor/github.com/33cn/chain33/rpc/types/code.go
+5
-0
types_test.go
vendor/github.com/33cn/chain33/rpc/types/types_test.go
+11
-0
base.go
vendor/github.com/33cn/chain33/system/mempool/base.go
+7
-5
check.go
vendor/github.com/33cn/chain33/system/mempool/check.go
+1
-1
util.go
vendor/github.com/33cn/chain33/util/util.go
+7
-2
store.go
vendor/github.com/33cn/chain33/wallet/common/store.go
+0
-6
wallet_proc.go
vendor/github.com/33cn/chain33/wallet/wallet_proc.go
+1
-8
No files found.
vendor/github.com/33cn/chain33/blockchain/query_tx.go
View file @
4c49bccd
...
...
@@ -191,12 +191,7 @@ func setTxDetailFromTxResult(TransactionDetail *types.TransactionDetail, txresul
TransactionDetail
.
ActionName
=
txresult
.
GetTx
()
.
ActionName
()
//获取from地址
addr
:=
txresult
.
GetTx
()
.
From
()
TransactionDetail
.
Fromaddr
=
addr
if
TransactionDetail
.
GetTx
()
.
IsWithdraw
()
{
//swap from and to
TransactionDetail
.
Fromaddr
,
TransactionDetail
.
Tx
.
To
=
TransactionDetail
.
Tx
.
To
,
TransactionDetail
.
Fromaddr
}
TransactionDetail
.
Fromaddr
=
txresult
.
GetTx
()
.
From
()
}
//ProcGetAddrOverview 获取addrOverview
...
...
vendor/github.com/33cn/chain33/p2p/const.go
View file @
4c49bccd
...
...
@@ -69,8 +69,6 @@ const (
var
TestNetSeeds
=
[]
string
{
"114.55.101.159:13802"
,
"47.104.125.151:13802"
,
"47.104.125.97:13802"
,
"47.104.125.177:13802"
,
}
// MainNetSeeds built-in list of seed
...
...
@@ -78,13 +76,6 @@ var MainNetSeeds = []string{
"39.107.234.240:13802"
,
"39.105.88.66:13802"
,
"39.105.87.114:13802"
,
"39.105.85.247:13802"
,
"39.105.87.106:13802"
,
"39.105.76.78:13802"
,
"39.105.82.4:13802"
,
"39.105.43.225:13802"
,
"39.107.239.248:13802"
,
"39.105.83.33:13802"
,
"120.27.234.254:13802"
,
"116.62.169.41:13802"
,
"47.97.169.229:13802"
,
...
...
@@ -125,4 +116,11 @@ var MainNetSeeds = []string{
"47.74.22.60:13802"
,
"47.74.22.86:13802"
,
"47.91.17.139:13802"
,
"49.4.51.190:13802"
,
"114.115.151.98:13802"
,
"114.116.6.132:13802"
,
"114.116.12.244:13802"
,
"114.116.114.77:13802"
,
"114.116.109.21:13802"
,
"114.116.50.182:13802"
,
}
vendor/github.com/33cn/chain33/p2p/p2pcli.go
View file @
4c49bccd
...
...
@@ -361,18 +361,21 @@ func (m *Cli) GetHeaders(msg *queue.Message, taskindex int64) {
req
:=
msg
.
GetData
()
.
(
*
pb
.
ReqBlocks
)
pid
:=
req
.
GetPid
()
if
len
(
pid
)
==
0
{
log
.
Debug
(
"GetHeaders:pid is nil"
)
msg
.
Reply
(
m
.
network
.
client
.
NewMessage
(
"blockchain"
,
pb
.
EventReply
,
pb
.
Reply
{
Msg
:
[]
byte
(
"no pid"
)}))
return
}
msg
.
Reply
(
m
.
network
.
client
.
NewMessage
(
"blockchain"
,
pb
.
EventReply
,
pb
.
Reply
{
IsOk
:
true
,
Msg
:
[]
byte
(
"ok"
)}))
peers
,
infos
:=
m
.
network
.
node
.
GetActivePeers
()
var
pidIsActivePeer
bool
for
paddr
,
info
:=
range
infos
{
if
info
.
GetName
()
==
pid
[
0
]
{
//匹配成功
peer
,
ok
:=
peers
[
paddr
]
if
ok
&&
peer
!=
nil
{
var
err
error
pidIsActivePeer
=
true
headers
,
err
:=
peer
.
mconn
.
gcli
.
GetHeaders
(
context
.
Background
(),
&
pb
.
P2PGetHeaders
{
StartHeight
:
req
.
GetStart
(),
EndHeight
:
req
.
GetEnd
(),
Version
:
m
.
network
.
node
.
nodeInfo
.
cfg
.
Version
},
grpc
.
FailFast
(
true
))
P2pComm
.
CollectPeerStat
(
err
,
peer
)
...
...
@@ -394,6 +397,10 @@ func (m *Cli) GetHeaders(msg *queue.Message, taskindex int64) {
}
}
}
//当请求的pid不是ActivePeer时需要打印日志方便问题定位
if
!
pidIsActivePeer
{
log
.
Debug
(
"GetHeaders"
,
"pid"
,
pid
[
0
],
"ActivePeers"
,
peers
,
"infos"
,
infos
)
}
}
// GetBlocks get blocks information
...
...
@@ -410,9 +417,9 @@ func (m *Cli) GetBlocks(msg *queue.Message, taskindex int64) {
}
req
:=
msg
.
GetData
()
.
(
*
pb
.
ReqBlocks
)
log
.
Info
(
"GetBlocks"
,
"start"
,
req
.
GetStart
(),
"end"
,
req
.
GetEnd
())
log
.
Debug
(
"GetBlocks"
,
"start"
,
req
.
GetStart
(),
"end"
,
req
.
GetEnd
())
pids
:=
req
.
GetPid
()
log
.
Info
(
"GetBlocks"
,
"pids"
,
pids
)
log
.
Debug
(
"GetBlocks"
,
"pids"
,
pids
)
var
Inventorys
=
make
([]
*
pb
.
Inventory
,
0
)
for
i
:=
req
.
GetStart
();
i
<=
req
.
GetEnd
();
i
++
{
var
inv
pb
.
Inventory
...
...
@@ -426,7 +433,7 @@ func (m *Cli) GetBlocks(msg *queue.Message, taskindex int64) {
var
downloadPeers
[]
*
Peer
peers
,
infos
:=
m
.
network
.
node
.
GetActivePeers
()
if
len
(
pids
)
>
0
&&
pids
[
0
]
!=
""
{
//指定Pid 下载数据
log
.
Info
(
"fetch from peer in pids"
,
"pids"
,
pids
)
log
.
Debug
(
"fetch from peer in pids"
,
"pids"
,
pids
)
var
pidmap
=
make
(
map
[
string
]
bool
)
for
_
,
pid
:=
range
pids
{
pidmap
[
pid
]
=
true
...
...
@@ -443,7 +450,7 @@ func (m *Cli) GetBlocks(msg *queue.Message, taskindex int64) {
}
}
else
{
log
.
Info
(
"fetch from all peers in pids"
)
log
.
Debug
(
"fetch from all peers in pids"
)
for
_
,
peer
:=
range
peers
{
peerinfo
,
ok
:=
infos
[
peer
.
Addr
()]
if
!
ok
{
...
...
@@ -458,7 +465,7 @@ func (m *Cli) GetBlocks(msg *queue.Message, taskindex int64) {
}
if
len
(
downloadPeers
)
==
0
{
log
.
Error
(
"GetBlocks"
,
"downloadPeers"
,
0
)
log
.
Error
(
"GetBlocks"
,
"downloadPeers"
,
0
,
"peers"
,
peers
,
"infos"
,
infos
)
msg
.
Reply
(
m
.
network
.
client
.
NewMessage
(
"blockchain"
,
pb
.
EventReply
,
pb
.
Reply
{
Msg
:
[]
byte
(
"no downloadPeers"
)}))
return
}
...
...
vendor/github.com/33cn/chain33/rpc/jrpchandler.go
View file @
4c49bccd
...
...
@@ -296,6 +296,11 @@ func fmtTxDetail(tx *types.TransactionDetail, disableDetail bool) (*rpctypes.Tra
log
.
Info
(
"GetTxByHashes"
,
"Failed to DecodeTx due to"
,
err
)
return
nil
,
err
}
// swap from with to
if
tx
.
GetTx
()
.
IsWithdraw
()
{
tx
.
Fromaddr
,
tx
.
Tx
.
To
=
tx
.
Tx
.
To
,
tx
.
Fromaddr
tran
.
To
=
tx
.
Tx
.
GetRealToAddr
()
}
return
&
rpctypes
.
TransactionDetail
{
Tx
:
tran
,
Height
:
tx
.
GetHeight
(),
...
...
vendor/github.com/33cn/chain33/rpc/jrpchandler_test.go
View file @
4c49bccd
...
...
@@ -1405,3 +1405,21 @@ func TestChain33_ConvertExectoAddr(t *testing.T) {
err
:=
client
.
ConvertExectoAddr
(
rpctypes
.
ExecNameParm
{
ExecName
:
"coins"
},
&
testResult
)
assert
.
NoError
(
t
,
err
)
}
func
Test_fmtTxDetail
(
t
*
testing
.
T
)
{
tx
:=
&
types
.
Transaction
{
Execer
:
[]
byte
(
"coins"
)}
log
:=
&
types
.
ReceiptLog
{
Ty
:
0
,
Log
:
[]
byte
(
"test"
)}
receipt
:=
&
types
.
ReceiptData
{
Ty
:
0
,
Logs
:
[]
*
types
.
ReceiptLog
{
log
}}
detail
:=
&
types
.
TransactionDetail
{
Tx
:
tx
,
Receipt
:
receipt
}
var
err
error
//test withdraw swap from to
detail
.
Fromaddr
=
"from"
detail
.
Tx
.
Payload
,
err
=
common
.
FromHex
(
"0x180322301080c2d72f2205636f696e732a22314761485970576d71414a7371527772706f4e6342385676674b7453776a63487174"
)
assert
.
NoError
(
t
,
err
)
tx
.
To
=
"to"
tran
,
err
:=
fmtTxDetail
(
detail
,
false
)
assert
.
NoError
(
t
,
err
)
assert
.
Equal
(
t
,
"to"
,
tran
.
Fromaddr
)
assert
.
Equal
(
t
,
"from"
,
tx
.
To
)
}
vendor/github.com/33cn/chain33/rpc/types/code.go
View file @
4c49bccd
...
...
@@ -70,6 +70,11 @@ func ConvertWalletTxDetailToJSON(in *types.WalletTxDetails, out *WalletTxDetails
if
err
!=
nil
{
continue
}
if
tx
.
Tx
.
IsWithdraw
()
{
//swap from and to
tx
.
Fromaddr
,
tx
.
Tx
.
To
=
tx
.
Tx
.
To
,
tx
.
Fromaddr
tran
.
To
=
tx
.
Tx
.
GetRealToAddr
()
}
out
.
TxDetails
=
append
(
out
.
TxDetails
,
&
WalletTxDetail
{
Tx
:
tran
,
Receipt
:
rd
,
...
...
vendor/github.com/33cn/chain33/rpc/types/types_test.go
View file @
4c49bccd
...
...
@@ -76,6 +76,17 @@ func TestConvertWalletTxDetailToJSON(t *testing.T) {
out
:=
&
WalletTxDetails
{}
err
:=
ConvertWalletTxDetailToJSON
(
in
,
out
)
assert
.
NoError
(
t
,
err
)
//test withdraw swap from to
detail
.
Fromaddr
=
"from"
detail
.
Tx
.
Payload
,
err
=
common
.
FromHex
(
"0x180322301080c2d72f2205636f696e732a22314761485970576d71414a7371527772706f4e6342385676674b7453776a63487174"
)
assert
.
NoError
(
t
,
err
)
tx
.
To
=
"to"
out
=
&
WalletTxDetails
{}
err
=
ConvertWalletTxDetailToJSON
(
in
,
out
)
assert
.
NoError
(
t
,
err
)
assert
.
Equal
(
t
,
"to"
,
out
.
TxDetails
[
0
]
.
FromAddr
)
assert
.
Equal
(
t
,
"from"
,
detail
.
Tx
.
To
)
}
func
TestServer
(
t
*
testing
.
T
)
{
...
...
vendor/github.com/33cn/chain33/system/mempool/base.go
View file @
4c49bccd
...
...
@@ -285,7 +285,10 @@ func (mem *Mempool) RemoveTxsOfBlock(block *types.Block) bool {
func
(
mem
*
Mempool
)
GetProperFeeRate
()
int64
{
baseFeeRate
:=
mem
.
cache
.
GetProperFee
()
if
mem
.
cfg
.
IsLevelFee
{
return
mem
.
getLevelFeeRate
(
baseFeeRate
)
levelFeeRate
:=
mem
.
getLevelFeeRate
(
mem
.
cfg
.
MinTxFee
)
if
levelFeeRate
>
baseFeeRate
{
return
levelFeeRate
}
}
return
baseFeeRate
}
...
...
@@ -296,13 +299,12 @@ func (mem *Mempool) getLevelFeeRate(baseFeeRate int64) int64 {
sumByte
:=
mem
.
cache
.
TotalByte
()
maxTxNumber
:=
types
.
GetP
(
mem
.
Height
())
.
MaxTxNumber
switch
{
case
(
sumByte
>
int64
(
types
.
MaxBlockSize
/
100
)
&&
sumByte
<
int64
(
types
.
MaxBlockSize
/
20
))
||
(
int64
(
mem
.
Size
())
>=
maxTxNumber
/
10
&&
int64
(
mem
.
Size
())
<
maxTxNumber
/
2
)
:
feeRate
=
10
*
baseFeeRate
case
sumByte
>=
int64
(
types
.
MaxBlockSize
/
20
)
||
int64
(
mem
.
Size
())
>=
maxTxNumber
/
2
:
feeRate
=
100
*
baseFeeRate
case
sumByte
>=
int64
(
types
.
MaxBlockSize
/
100
)
||
int64
(
mem
.
Size
())
>=
maxTxNumber
/
10
:
feeRate
=
10
*
baseFeeRate
default
:
return
baseFeeRate
feeRate
=
baseFeeRate
}
if
feeRate
>
10000000
{
feeRate
=
10000000
...
...
vendor/github.com/33cn/chain33/system/mempool/check.go
View file @
4c49bccd
...
...
@@ -124,7 +124,7 @@ func (mem *Mempool) checkTxs(msg *queue.Message) *queue.Message {
// checkLevelFee 检查阶梯手续费
func
(
mem
*
Mempool
)
checkLevelFee
(
tx
*
types
.
TransactionCache
)
error
{
//获取mempool里所有交易手续费总和
feeRate
:=
mem
.
GetProperFeeRate
(
)
feeRate
:=
mem
.
getLevelFeeRate
(
mem
.
cfg
.
MinTxFee
)
totalfee
,
err
:=
tx
.
GetTotalFee
(
feeRate
)
if
err
!=
nil
{
return
err
...
...
vendor/github.com/33cn/chain33/util/util.go
View file @
4c49bccd
...
...
@@ -13,7 +13,6 @@ import (
"os"
"os/user"
"path/filepath"
"testing"
"unicode"
"strings"
...
...
@@ -127,8 +126,14 @@ func CreateTxWithExecer(priv crypto.PrivKey, execer string) *types.Transaction {
return
tx
}
//TestingT 测试类型
type
TestingT
interface
{
Error
(
args
...
interface
{})
Log
(
args
...
interface
{})
}
// JSONPrint : print in json format
func
JSONPrint
(
t
*
testing
.
T
,
input
interface
{})
{
func
JSONPrint
(
t
Testing
T
,
input
interface
{})
{
data
,
err
:=
json
.
MarshalIndent
(
input
,
""
,
"
\t
"
)
if
err
!=
nil
{
t
.
Error
(
err
)
...
...
vendor/github.com/33cn/chain33/wallet/common/store.go
View file @
4c49bccd
...
...
@@ -227,12 +227,6 @@ func (store *Store) GetTxDetailByIter(TxList *types.ReqWalletTransactionList) (*
storelog
.
Error
(
"GetTxDetailByIter"
,
"proto.Unmarshal err:"
,
err
)
return
nil
,
types
.
ErrUnmarshal
}
if
string
(
txdetail
.
Tx
.
GetExecer
())
==
"coins"
&&
txdetail
.
Tx
.
ActionName
()
==
"withdraw"
{
//swap from and to
txdetail
.
Fromaddr
,
txdetail
.
Tx
.
To
=
txdetail
.
Tx
.
To
,
txdetail
.
Fromaddr
}
txhash
:=
txdetail
.
GetTx
()
.
Hash
()
txdetail
.
Txhash
=
txhash
txDetails
.
TxDetails
[
index
]
=
&
txdetail
}
return
&
txDetails
,
nil
...
...
vendor/github.com/33cn/chain33/wallet/wallet_proc.go
View file @
4c49bccd
...
...
@@ -1025,7 +1025,7 @@ func (wallet *Wallet) buildAndStoreWalletTxDetail(param *buildStoreWalletTxDetai
txdetail
.
Index
=
int64
(
param
.
index
)
txdetail
.
Receipt
=
param
.
block
.
Receipts
[
param
.
index
]
txdetail
.
Blocktime
=
param
.
block
.
Block
.
BlockTime
txdetail
.
Txhash
=
param
.
tx
.
Hash
()
txdetail
.
ActionName
=
txdetail
.
Tx
.
ActionName
()
txdetail
.
Amount
,
Err
=
param
.
tx
.
Amount
()
if
Err
!=
nil
{
...
...
@@ -1135,13 +1135,6 @@ func (wallet *Wallet) GetTxDetailByHashs(ReqHashes *types.ReqHashes) {
txdetail
.
Fromaddr
=
txdetal
.
GetFromaddr
()
txdetail
.
ActionName
=
txdetal
.
GetTx
()
.
ActionName
()
//由于Withdraw的交易在blockchain模块已经做了from和to地址的swap的操作。
//所以在此需要swap恢复回去。通过钱包的GetTxDetailByIter接口上送给前端时再做from和to地址的swap
//确保保存在数据库中是的最原始的数据,提供给上层显示时可以做swap方便客户理解
if
txdetail
.
GetTx
()
.
IsWithdraw
()
{
txdetail
.
Fromaddr
,
txdetail
.
Tx
.
To
=
txdetail
.
Tx
.
To
,
txdetail
.
Fromaddr
}
txdetailbyte
,
err
:=
proto
.
Marshal
(
&
txdetail
)
if
err
!=
nil
{
walletlog
.
Error
(
"GetTxDetailByHashs Marshal txdetail err"
,
"Height"
,
height
,
"index"
,
txindex
)
...
...
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