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
ab6c58e7
Unverified
Commit
ab6c58e7
authored
Oct 28, 2019
by
lyh169
Committed by
GitHub
Oct 28, 2019
Browse files
Options
Browse Files
Download
Plain Diff
Merge branch 'master' into mod_global_config
parents
0c014439
2366eb92
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
51 additions
and
17 deletions
+51
-17
go.sum
go.sum
+0
-3
test-rpc.sh
plugin/dapp/paracross/cmd/test/test-rpc.sh
+18
-4
cache.go
plugin/mempool/price/cache.go
+14
-4
cache_test.go
plugin/mempool/price/cache_test.go
+19
-6
No files found.
go.sum
View file @
ab6c58e7
cloud.google.com/go v0.26.0/go.mod h1:aQUYkXzVsufM+DwF1aE+0xfcU+56JwCaLick0ClmMTw=
github.com/33cn/chain33 v0.0.0-20191017025459-6d5c61c7d134 h1:uglc+qoZXRLxsLn9TdwLV5YDzjnRbLV0QjaxqvVFh4M=
github.com/33cn/chain33 v0.0.0-20191017025459-6d5c61c7d134/go.mod h1:4I8n+Zyf3t0UKM5jjpqJY627Tub62oXkLsdzIv4r6rQ=
github.com/33cn/chain33 v0.0.0-20191017084333-edce70d31ccc h1:ZE5zFLMdGTiHF7fZcVk+uOT16Q5gwmT4p01MSz/9ZBQ=
github.com/33cn/chain33 v0.0.0-20191028082607-ea7ecac59540 h1:4m9EV1D3KdhY84QJhhhWCVgGsVa/Hb91sjWQdpg5ItE=
github.com/33cn/chain33 v0.0.0-20191028082607-ea7ecac59540/go.mod h1:4I8n+Zyf3t0UKM5jjpqJY627Tub62oXkLsdzIv4r6rQ=
github.com/AndreasBriese/bbloom v0.0.0-20180913140656-343706a395b7 h1:PqzgE6kAMi81xWQA2QIVxjWkFHptGgC547vchpUbtFo=
...
...
plugin/dapp/paracross/cmd/test/test-rpc.sh
View file @
ab6c58e7
...
...
@@ -324,12 +324,26 @@ function paracross_testTxGroup() {
#curl -ksd '{"method":"Chain33.CreateTransaction","params":[{"execer":"user.p.para.paracross","actionName":"ParacrossAssetTransfer","payload":{"execName":"user.p.para.paracross","to":"1MAuE8QSbbech3bVKK2JPJJxYxNtT95oSU","amount":100000000}}]}' http://172.20.0.5:8901
# 资产从平行链转移到平行链合约
tx_hash_transferExec
=
$(
curl
-ksd
'{"method":"Chain33.CreateTransaction","params":[{"execer":"'
"
${
paracross_execer_name
}
"
'","actionName":"TransferToExec","payload":{"execName":"'
"
${
paracross_execer_name
}
"
'","to":"'
"
${
trade_exec_addr
}
"
'","amount":'
${
amount_trade
}
', "cointoken":"coins.bty"}}]}'
"
${
para_ip
}
"
| jq
-r
".result"
)
#curl -ksd '{"method":"Chain33.CreateTransaction","params":[{"execer":"user.p.para.paracross","actionName":"TransferToExec","payload":{"execName":"user.p.para.paracross","to":"12bihjzbaYWjcpDiiy9SuAWeqNksQdiN13","amount":10000000, "cointoken":"coins.bty"}}]}' http://172.20.0.5:8901
req
=
'"method":"Chain33.CreateTransaction","params":[{"execer":"'
"
${
paracross_execer_name
}
"
'","actionName":"TransferToExec","payload":{"execName":"'
"
${
paracross_execer_name
}
"
'","to":"'
"
${
trade_exec_addr
}
"
'","amount":'
${
amount_trade
}
', "cointoken":"coins.bty"}}]'
echo
"
$req
"
resp
=
$(
curl
-ksd
"{
$req
}"
"
${
para_ip
}
"
)
echo
"
$resp
"
err
=
$(
jq
'(.error)'
<<<
"
$resp
"
)
if
[
"
$err
"
!=
null
]
;
then
echo
"
$resp
"
exit
1
fi
tx_hash_transferExec
=
$(
jq
-r
".result"
<<<
"
$resp
"
)
#create tx group with none
tx_hash_group
=
$(
curl
-ksd
'{"method":"Chain33.CreateNoBlanaceTxs","params":[{"txHexs":["'
"
${
tx_hash_asset
}
"
'","'
"
${
tx_hash_transferExec
}
"
'"],"privkey":"'
"
${
test_prikey
}
"
'","expire":"120"}]}'
"
${
para_ip
}
"
| jq
-r
".result"
)
#curl -ksd '{"method":"Chain33.CreateNoBlanaceTxs","params":[{"txHexs":["0a15757365722e702e706172612e7061726163726f7373122e10904e22291080c2d72f2222314d41754538515362626563683362564b4b324a504a4a7859784e745439356f535520a08d0630d195faf7d3a1ec9a4c3a223139574a4a7639366e4b4155347348465771476d7371666a786433376a617a716969","0a15757365722e702e706172612e7061726163726f7373124f1004424b0a09636f696e732e6274791080ade2042215757365722e702e706172612e7061726163726f73732a2231326269686a7a626159576a637044696979395375415765714e6b735164694e313320a08d0630a8c984ebb2bb90a5613a223139574a4a7639366e4b4155347348465771476d7371666a786433376a617a716969"],"privkey":"4257D8692EF7FE13C68B65D6A52F03933DB2FA5CE8FAF210B5B8B80C721CED01","expire":"120"}]}' http://172.20.0.5:8901
req
=
'"method":"Chain33.CreateNoBlanaceTxs","params":[{"txHexs":["'
"
${
tx_hash_asset
}
"
'","'
"
${
tx_hash_transferExec
}
"
'"],"privkey":"'
"
${
test_prikey
}
"
'","expire":"120s"}]'
resp
=
$(
curl
-ksd
"{
$req
}"
"
${
para_ip
}
"
)
err
=
$(
jq
'(.error)'
<<<
"
$resp
"
)
if
[
"
$err
"
!=
null
]
;
then
echo
"
$resp
"
exit
1
fi
tx_hash_group
=
$(
jq
-r
".result"
<<<
"
$resp
"
)
#sign 1
tx_sign
=
$(
curl
-ksd
'{"method":"Chain33.SignRawTx","params":[{"privkey":"'
"
$test_prikey
"
'","txHex":"'
"
$tx_hash_group
"
'","index":2,"expire":"120s"}]}'
"
${
para_ip
}
"
| jq
-r
".result"
)
...
...
plugin/mempool/price/cache.go
View file @
ab6c58e7
...
...
@@ -70,15 +70,25 @@ func (cache *Queue) Walk(count int, cb func(tx *mempool.Item) bool) {
func
(
cache
*
Queue
)
GetProperFee
()
int64
{
var
sumFeeRate
int64
var
properFeeRate
int64
if
cache
.
Size
()
==
0
{
if
cache
.
Size
()
<
10
0
{
return
cache
.
subConfig
.
ProperFee
}
i
:=
0
var
txSize
int
var
feeRate
int64
cache
.
Walk
(
100
,
func
(
item
*
mempool
.
Item
)
bool
{
txSize
=
proto
.
Size
(
item
.
Value
)
feeRate
=
item
.
Value
.
Fee
/
int64
(
txSize
/
1000
+
1
)
//总单元费率的个数, 单个交易根据txsize/1000 + 1计算
unitFeeNum
:=
proto
.
Size
(
item
.
Value
)
/
1000
+
1
//交易组计算
if
count
:=
item
.
Value
.
GetGroupCount
();
count
>
0
{
unitFeeNum
=
int
(
count
)
txs
,
err
:=
item
.
Value
.
GetTxGroup
()
if
err
!=
nil
{
for
_
,
tx
:=
range
txs
.
GetTxs
()
{
unitFeeNum
+=
proto
.
Size
(
tx
)
/
1000
}
}
}
feeRate
=
item
.
Value
.
Fee
/
int64
(
unitFeeNum
)
sumFeeRate
+=
feeRate
i
++
return
true
...
...
plugin/mempool/price/cache_test.go
View file @
ab6c58e7
...
...
@@ -41,7 +41,7 @@ var (
func
initEnv
(
size
int64
)
*
Queue
{
if
size
==
0
{
size
=
100
size
=
100
0
}
_
,
sub
:=
types
.
InitCfg
(
"chain33.test.toml"
)
var
subcfg
subConfig
...
...
@@ -158,13 +158,26 @@ func TestQueueDirection(t *testing.T) {
func
TestGetProperFee
(
t
*
testing
.
T
)
{
cache
:=
initEnv
(
0
)
assert
.
Equal
(
t
,
cache
.
subConfig
.
ProperFee
,
cache
.
GetProperFee
())
txs
,
err
:=
types
.
CreateTxGroup
([]
*
types
.
Transaction
{
tx2
,
tx3
,
tx5
},
1200000
)
assert
.
NoError
(
t
,
err
)
tx
:=
txs
.
Tx
()
groupItem
:=
&
drivers
.
Item
{
Value
:
tx
,
Priority
:
tx
.
Fee
,
EnterTime
:
item1
.
EnterTime
-
1
}
assert
.
Equal
(
t
,
cache
.
subConfig
.
ProperFee
,
cache
.
GetProperFee
())
cache
.
Push
(
item1
)
cache
.
Push
(
item4
)
cache
.
GetProperFee
()
txSize1
:=
proto
.
Size
(
item1
.
Value
)
txSize2
:=
proto
.
Size
(
item4
.
Value
)
assert
.
Equal
(
t
,
(
item1
.
Value
.
Fee
/
int64
(
txSize1
/
1000
+
1
)
+
item4
.
Value
.
Fee
/
int64
(
txSize2
/
1000
+
1
))
/
2
,
cache
.
GetProperFee
())
assert
.
NoError
(
t
,
cache
.
Push
(
groupItem
))
for
i
:=
0
;
i
<
97
;
i
++
{
item
:=
*
item1
tempTx
:=
*
item1
.
Value
item
.
Value
=
&
tempTx
item
.
Value
.
Nonce
=
int64
(
i
+
1
)
assert
.
NoError
(
t
,
cache
.
Push
(
&
item
))
}
properFee
:=
cache
.
GetProperFee
()
feeRate1
:=
item1
.
Value
.
Fee
/
int64
(
proto
.
Size
(
item1
.
Value
)
/
1000
+
1
)
feeRate2
:=
item4
.
Value
.
Fee
/
int64
(
proto
.
Size
(
item4
.
Value
)
/
1000
+
1
)
t
.
Log
(
feeRate1
,
feeRate2
)
assert
.
Equal
(
t
,
(
feeRate1
*
98
+
feeRate2
+
1200000
)
/
100
,
properFee
)
}
func
TestRealNodeMempool
(
t
*
testing
.
T
)
{
...
...
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