good morning!!!!
Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
B
bor
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Iterations
Wiki
Requirements
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Locked files
Build
Pipelines
Jobs
Pipeline schedules
Test cases
Artifacts
Deploy
Releases
Package Registry
Container Registry
Harbor Registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Code review analytics
Issue analytics
Insights
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
open
bor
Commits
c8130df1
Commit
c8130df1
authored
8 years ago
by
Zsolt Felföldi
Browse files
Options
Downloads
Patches
Plain Diff
les: using random request IDs
parent
af8a742d
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
les/fetcher.go
+1
-1
1 addition, 1 deletion
les/fetcher.go
les/handler.go
+2
-2
2 additions, 2 deletions
les/handler.go
les/odr.go
+7
-8
7 additions, 8 deletions
les/odr.go
with
10 additions
and
11 deletions
les/fetcher.go
+
1
−
1
View file @
c8130df1
...
@@ -350,7 +350,7 @@ func (f *lightFetcher) request(p *peer, n *fetcherTreeNode, amount uint64) (uint
...
@@ -350,7 +350,7 @@ func (f *lightFetcher) request(p *peer, n *fetcherTreeNode, amount uint64) (uint
return
0
,
false
return
0
,
false
}
}
reqID
:=
f
.
odr
.
getNextReqID
()
reqID
:=
getNextReqID
()
n
.
requested
=
true
n
.
requested
=
true
cost
:=
p
.
GetRequestCost
(
GetBlockHeadersMsg
,
int
(
amount
))
cost
:=
p
.
GetRequestCost
(
GetBlockHeadersMsg
,
int
(
amount
))
p
.
fcServer
.
SendRequest
(
reqID
,
cost
)
p
.
fcServer
.
SendRequest
(
reqID
,
cost
)
...
...
This diff is collapsed.
Click to expand it.
les/handler.go
+
2
−
2
View file @
c8130df1
...
@@ -338,13 +338,13 @@ func (pm *ProtocolManager) handle(p *peer) error {
...
@@ -338,13 +338,13 @@ func (pm *ProtocolManager) handle(p *peer) error {
glog
.
V
(
logger
.
Debug
)
.
Infof
(
"LES: register peer %v"
,
p
.
id
)
glog
.
V
(
logger
.
Debug
)
.
Infof
(
"LES: register peer %v"
,
p
.
id
)
if
pm
.
lightSync
{
if
pm
.
lightSync
{
requestHeadersByHash
:=
func
(
origin
common
.
Hash
,
amount
int
,
skip
int
,
reverse
bool
)
error
{
requestHeadersByHash
:=
func
(
origin
common
.
Hash
,
amount
int
,
skip
int
,
reverse
bool
)
error
{
reqID
:=
pm
.
odr
.
getNextReqID
()
reqID
:=
getNextReqID
()
cost
:=
p
.
GetRequestCost
(
GetBlockHeadersMsg
,
amount
)
cost
:=
p
.
GetRequestCost
(
GetBlockHeadersMsg
,
amount
)
p
.
fcServer
.
SendRequest
(
reqID
,
cost
)
p
.
fcServer
.
SendRequest
(
reqID
,
cost
)
return
p
.
RequestHeadersByHash
(
reqID
,
cost
,
origin
,
amount
,
skip
,
reverse
)
return
p
.
RequestHeadersByHash
(
reqID
,
cost
,
origin
,
amount
,
skip
,
reverse
)
}
}
requestHeadersByNumber
:=
func
(
origin
uint64
,
amount
int
,
skip
int
,
reverse
bool
)
error
{
requestHeadersByNumber
:=
func
(
origin
uint64
,
amount
int
,
skip
int
,
reverse
bool
)
error
{
reqID
:=
pm
.
odr
.
getNextReqID
()
reqID
:=
getNextReqID
()
cost
:=
p
.
GetRequestCost
(
GetBlockHeadersMsg
,
amount
)
cost
:=
p
.
GetRequestCost
(
GetBlockHeadersMsg
,
amount
)
p
.
fcServer
.
SendRequest
(
reqID
,
cost
)
p
.
fcServer
.
SendRequest
(
reqID
,
cost
)
return
p
.
RequestHeadersByNumber
(
reqID
,
cost
,
origin
,
amount
,
skip
,
reverse
)
return
p
.
RequestHeadersByNumber
(
reqID
,
cost
,
origin
,
amount
,
skip
,
reverse
)
...
...
This diff is collapsed.
Click to expand it.
les/odr.go
+
7
−
8
View file @
c8130df1
...
@@ -17,6 +17,8 @@
...
@@ -17,6 +17,8 @@
package
les
package
les
import
(
import
(
"crypto/rand"
"encoding/binary"
"sync"
"sync"
"time"
"time"
...
@@ -50,7 +52,6 @@ type LesOdr struct {
...
@@ -50,7 +52,6 @@ type LesOdr struct {
mlock
,
clock
sync
.
Mutex
mlock
,
clock
sync
.
Mutex
sentReqs
map
[
uint64
]
*
sentReq
sentReqs
map
[
uint64
]
*
sentReq
serverPool
odrPeerSelector
serverPool
odrPeerSelector
lastReqID
uint64
}
}
func
NewLesOdr
(
db
ethdb
.
Database
)
*
LesOdr
{
func
NewLesOdr
(
db
ethdb
.
Database
)
*
LesOdr
{
...
@@ -167,7 +168,7 @@ func (self *LesOdr) networkRequest(ctx context.Context, lreq LesOdrRequest) erro
...
@@ -167,7 +168,7 @@ func (self *LesOdr) networkRequest(ctx context.Context, lreq LesOdrRequest) erro
sentTo
:
make
(
map
[
*
peer
]
chan
struct
{}),
sentTo
:
make
(
map
[
*
peer
]
chan
struct
{}),
answered
:
answered
,
// reply delivered by any peer
answered
:
answered
,
// reply delivered by any peer
}
}
reqID
:=
self
.
getNextReqID
()
reqID
:=
getNextReqID
()
self
.
mlock
.
Lock
()
self
.
mlock
.
Lock
()
self
.
sentReqs
[
reqID
]
=
req
self
.
sentReqs
[
reqID
]
=
req
self
.
mlock
.
Unlock
()
self
.
mlock
.
Unlock
()
...
@@ -236,10 +237,8 @@ func (self *LesOdr) Retrieve(ctx context.Context, req light.OdrRequest) (err err
...
@@ -236,10 +237,8 @@ func (self *LesOdr) Retrieve(ctx context.Context, req light.OdrRequest) (err err
return
return
}
}
func
(
self
*
LesOdr
)
getNextReqID
()
uint64
{
func
getNextReqID
()
uint64
{
self
.
clock
.
Lock
()
var
rnd
[
8
]
byte
defer
self
.
clock
.
Unlock
()
rand
.
Read
(
rnd
[
:
])
return
binary
.
BigEndian
.
Uint64
(
rnd
[
:
])
self
.
lastReqID
++
return
self
.
lastReqID
}
}
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment