Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
G
Geth-Modification
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
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
张蕾
Geth-Modification
Commits
85b6823d
Commit
85b6823d
authored
Apr 16, 2019
by
Felföldi Zsolt
Committed by
Péter Szilágyi
Apr 16, 2019
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
les: check required message types in cost table (#19454)
parent
78d90c47
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
20 additions
and
5 deletions
+20
-5
peer.go
les/peer.go
+18
-3
peer_test.go
les/peer_test.go
+2
-2
No files found.
les/peer.go
View file @
85b6823d
...
@@ -232,7 +232,11 @@ func (p *peer) GetRequestCost(msgcode uint64, amount int) uint64 {
...
@@ -232,7 +232,11 @@ func (p *peer) GetRequestCost(msgcode uint64, amount int) uint64 {
p
.
lock
.
RLock
()
p
.
lock
.
RLock
()
defer
p
.
lock
.
RUnlock
()
defer
p
.
lock
.
RUnlock
()
cost
:=
p
.
fcCosts
[
msgcode
]
.
baseCost
+
p
.
fcCosts
[
msgcode
]
.
reqCost
*
uint64
(
amount
)
costs
:=
p
.
fcCosts
[
msgcode
]
if
costs
==
nil
{
return
0
}
cost
:=
costs
.
baseCost
+
costs
.
reqCost
*
uint64
(
amount
)
if
cost
>
p
.
fcParams
.
BufLimit
{
if
cost
>
p
.
fcParams
.
BufLimit
{
cost
=
p
.
fcParams
.
BufLimit
cost
=
p
.
fcParams
.
BufLimit
}
}
...
@@ -243,8 +247,12 @@ func (p *peer) GetTxRelayCost(amount, size int) uint64 {
...
@@ -243,8 +247,12 @@ func (p *peer) GetTxRelayCost(amount, size int) uint64 {
p
.
lock
.
RLock
()
p
.
lock
.
RLock
()
defer
p
.
lock
.
RUnlock
()
defer
p
.
lock
.
RUnlock
()
cost
:=
p
.
fcCosts
[
SendTxV2Msg
]
.
baseCost
+
p
.
fcCosts
[
SendTxV2Msg
]
.
reqCost
*
uint64
(
amount
)
costs
:=
p
.
fcCosts
[
SendTxV2Msg
]
sizeCost
:=
p
.
fcCosts
[
SendTxV2Msg
]
.
baseCost
+
p
.
fcCosts
[
SendTxV2Msg
]
.
reqCost
*
uint64
(
size
)
/
txSizeCostLimit
if
costs
==
nil
{
return
0
}
cost
:=
costs
.
baseCost
+
costs
.
reqCost
*
uint64
(
amount
)
sizeCost
:=
costs
.
baseCost
+
costs
.
reqCost
*
uint64
(
size
)
/
txSizeCostLimit
if
sizeCost
>
cost
{
if
sizeCost
>
cost
{
cost
=
sizeCost
cost
=
sizeCost
}
}
...
@@ -564,6 +572,13 @@ func (p *peer) Handshake(td *big.Int, head common.Hash, headNum uint64, genesis
...
@@ -564,6 +572,13 @@ func (p *peer) Handshake(td *big.Int, head common.Hash, headNum uint64, genesis
p
.
fcParams
=
params
p
.
fcParams
=
params
p
.
fcServer
=
flowcontrol
.
NewServerNode
(
params
,
&
mclock
.
System
{})
p
.
fcServer
=
flowcontrol
.
NewServerNode
(
params
,
&
mclock
.
System
{})
p
.
fcCosts
=
MRC
.
decode
()
p
.
fcCosts
=
MRC
.
decode
()
if
!
p
.
isOnlyAnnounce
{
for
msgCode
:=
range
reqAvgTimeCost
{
if
p
.
fcCosts
[
msgCode
]
==
nil
{
return
errResp
(
ErrUselessPeer
,
"peer does not support message %d"
,
msgCode
)
}
}
}
}
}
p
.
headInfo
=
&
announceData
{
Td
:
rTd
,
Hash
:
rHash
,
Number
:
rNum
}
p
.
headInfo
=
&
announceData
{
Td
:
rTd
,
Hash
:
rHash
,
Number
:
rNum
}
return
nil
return
nil
...
...
les/peer_test.go
View file @
85b6823d
...
@@ -54,7 +54,7 @@ func TestPeerHandshakeSetAnnounceTypeToAnnounceTypeSignedForTrustedPeer(t *testi
...
@@ -54,7 +54,7 @@ func TestPeerHandshakeSetAnnounceTypeToAnnounceTypeSignedForTrustedPeer(t *testi
l
=
l
.
add
(
"txRelay"
,
nil
)
l
=
l
.
add
(
"txRelay"
,
nil
)
l
=
l
.
add
(
"flowControl/BL"
,
uint64
(
0
))
l
=
l
.
add
(
"flowControl/BL"
,
uint64
(
0
))
l
=
l
.
add
(
"flowControl/MRR"
,
uint64
(
0
))
l
=
l
.
add
(
"flowControl/MRR"
,
uint64
(
0
))
l
=
l
.
add
(
"flowControl/MRC"
,
RequestCostList
{}
)
l
=
l
.
add
(
"flowControl/MRC"
,
testCostList
()
)
return
l
return
l
},
},
...
@@ -99,7 +99,7 @@ func TestPeerHandshakeAnnounceTypeSignedForTrustedPeersPeerNotInTrusted(t *testi
...
@@ -99,7 +99,7 @@ func TestPeerHandshakeAnnounceTypeSignedForTrustedPeersPeerNotInTrusted(t *testi
l
=
l
.
add
(
"txRelay"
,
nil
)
l
=
l
.
add
(
"txRelay"
,
nil
)
l
=
l
.
add
(
"flowControl/BL"
,
uint64
(
0
))
l
=
l
.
add
(
"flowControl/BL"
,
uint64
(
0
))
l
=
l
.
add
(
"flowControl/MRR"
,
uint64
(
0
))
l
=
l
.
add
(
"flowControl/MRR"
,
uint64
(
0
))
l
=
l
.
add
(
"flowControl/MRC"
,
RequestCostList
{}
)
l
=
l
.
add
(
"flowControl/MRC"
,
testCostList
()
)
return
l
return
l
},
},
...
...
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