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
f4fb1a18
Commit
f4fb1a18
authored
May 13, 2019
by
Felföldi Zsolt
Committed by
Péter Szilágyi
May 13, 2019
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
les: fixed cost table update (#19546)
parent
751effa3
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
13 additions
and
8 deletions
+13
-8
costtracker.go
les/costtracker.go
+6
-4
peer.go
les/peer.go
+6
-3
peer_test.go
les/peer_test.go
+1
-1
No files found.
les/costtracker.go
View file @
f4fb1a18
...
@@ -346,12 +346,14 @@ func (table requestCostTable) getCost(code, amount uint64) uint64 {
...
@@ -346,12 +346,14 @@ func (table requestCostTable) getCost(code, amount uint64) uint64 {
}
}
// decode converts a cost list to a cost table
// decode converts a cost list to a cost table
func
(
list
RequestCostList
)
decode
()
requestCostTable
{
func
(
list
RequestCostList
)
decode
(
protocolLength
uint64
)
requestCostTable
{
table
:=
make
(
requestCostTable
)
table
:=
make
(
requestCostTable
)
for
_
,
e
:=
range
list
{
for
_
,
e
:=
range
list
{
table
[
e
.
MsgCode
]
=
&
requestCosts
{
if
e
.
MsgCode
<
protocolLength
{
baseCost
:
e
.
BaseCost
,
table
[
e
.
MsgCode
]
=
&
requestCosts
{
reqCost
:
e
.
ReqCost
,
baseCost
:
e
.
BaseCost
,
reqCost
:
e
.
ReqCost
,
}
}
}
}
}
return
table
return
table
...
...
les/peer.go
View file @
f4fb1a18
...
@@ -479,7 +479,7 @@ func (p *peer) Handshake(td *big.Int, head common.Hash, headNum uint64, genesis
...
@@ -479,7 +479,7 @@ func (p *peer) Handshake(td *big.Int, head common.Hash, headNum uint64, genesis
costList
=
testCostList
()
costList
=
testCostList
()
}
}
send
=
send
.
add
(
"flowControl/MRC"
,
costList
)
send
=
send
.
add
(
"flowControl/MRC"
,
costList
)
p
.
fcCosts
=
costList
.
decode
()
p
.
fcCosts
=
costList
.
decode
(
ProtocolLengths
[
uint
(
p
.
version
)]
)
p
.
fcParams
=
server
.
defParams
p
.
fcParams
=
server
.
defParams
}
else
{
}
else
{
//on client node
//on client node
...
@@ -571,7 +571,7 @@ func (p *peer) Handshake(td *big.Int, head common.Hash, headNum uint64, genesis
...
@@ -571,7 +571,7 @@ 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
(
ProtocolLengths
[
uint
(
p
.
version
)]
)
if
!
p
.
isOnlyAnnounce
{
if
!
p
.
isOnlyAnnounce
{
for
msgCode
:=
range
reqAvgTimeCost
{
for
msgCode
:=
range
reqAvgTimeCost
{
if
p
.
fcCosts
[
msgCode
]
==
nil
{
if
p
.
fcCosts
[
msgCode
]
==
nil
{
...
@@ -604,7 +604,10 @@ func (p *peer) updateFlowControl(update keyValueMap) {
...
@@ -604,7 +604,10 @@ func (p *peer) updateFlowControl(update keyValueMap) {
}
}
var
MRC
RequestCostList
var
MRC
RequestCostList
if
update
.
get
(
"flowControl/MRC"
,
&
MRC
)
==
nil
{
if
update
.
get
(
"flowControl/MRC"
,
&
MRC
)
==
nil
{
p
.
fcCosts
=
MRC
.
decode
()
costUpdate
:=
MRC
.
decode
(
ProtocolLengths
[
uint
(
p
.
version
)])
for
code
,
cost
:=
range
costUpdate
{
p
.
fcCosts
[
code
]
=
cost
}
}
}
}
}
...
...
les/peer_test.go
View file @
f4fb1a18
...
@@ -13,7 +13,7 @@ import (
...
@@ -13,7 +13,7 @@ import (
const
(
const
(
test_networkid
=
10
test_networkid
=
10
protocol_version
=
2123
protocol_version
=
lpv2
)
)
var
(
var
(
...
...
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