|
|
|
@ -19,6 +19,7 @@ package les |
|
|
|
|
import ( |
|
|
|
|
"context" |
|
|
|
|
"math/big" |
|
|
|
|
"math/rand" |
|
|
|
|
"sync" |
|
|
|
|
"sync/atomic" |
|
|
|
|
"time" |
|
|
|
@ -388,7 +389,7 @@ func (pc *peerConnection) RequestHeadersByHash(origin common.Hash, amount int, s |
|
|
|
|
return dp.(*serverPeer) == pc.peer |
|
|
|
|
}, |
|
|
|
|
request: func(dp distPeer) func() { |
|
|
|
|
reqID := genReqID() |
|
|
|
|
reqID := rand.Uint64() |
|
|
|
|
peer := dp.(*serverPeer) |
|
|
|
|
cost := peer.getRequestCost(GetBlockHeadersMsg, amount) |
|
|
|
|
peer.fcServer.QueuedRequest(reqID, cost) |
|
|
|
@ -412,7 +413,7 @@ func (pc *peerConnection) RequestHeadersByNumber(origin uint64, amount int, skip |
|
|
|
|
return dp.(*serverPeer) == pc.peer |
|
|
|
|
}, |
|
|
|
|
request: func(dp distPeer) func() { |
|
|
|
|
reqID := genReqID() |
|
|
|
|
reqID := rand.Uint64() |
|
|
|
|
peer := dp.(*serverPeer) |
|
|
|
|
cost := peer.getRequestCost(GetBlockHeadersMsg, amount) |
|
|
|
|
peer.fcServer.QueuedRequest(reqID, cost) |
|
|
|
@ -429,7 +430,7 @@ func (pc *peerConnection) RequestHeadersByNumber(origin uint64, amount int, skip |
|
|
|
|
// RetrieveSingleHeaderByNumber requests a single header by the specified block
|
|
|
|
|
// number. This function will wait the response until it's timeout or delivered.
|
|
|
|
|
func (pc *peerConnection) RetrieveSingleHeaderByNumber(context context.Context, number uint64) (*types.Header, error) { |
|
|
|
|
reqID := genReqID() |
|
|
|
|
reqID := rand.Uint64() |
|
|
|
|
rq := &distReq{ |
|
|
|
|
getCost: func(dp distPeer) uint64 { |
|
|
|
|
peer := dp.(*serverPeer) |
|
|
|
|