queueWithHeaders.ReserveHeaders¶
| Source (upstream pre-purge) | Current | |
|---|---|---|
| File | eth/downloader/queue.go |
queue_pow.go |
| Symbol | queue.ReserveHeaders |
queueWithHeaders.ReserveHeaders |
| Ref | 45baf2111~1 |
etc/v1.17.3-full-node |
3-way merge — purge → getc ← upstream¶
pre-purge≈ adapted (origin inferred by similarity)fork-only
↗// ReserveHeaders reserves a set of headers for the given peer, skipping any
// previously failed batches.
func (q *queueWithHeaders) ReserveHeaders(p *peerConnection, count int) *fetchRequest {
≈ q.queue.lock.Lock()
defer q.queue.lock.Unlock()
↗ // Short circuit if the peer's already downloading something (sanity check to
// not corrupt state)
if _, ok := q.headerPendPool[p.id]; ok {
return nil
}
// Retrieve a batch of hashes, skipping previously failed ones
send, skip := uint64(0), []uint64{}
for send == 0 && !q.headerTaskQueue.Empty() {
from, _ := q.headerTaskQueue.Pop()
if q.headerPeerMiss[p.id] != nil {
if _, ok := q.headerPeerMiss[p.id][from]; ok {
skip = append(skip, from)
continue
}
}
send = from
}
// Merge all the skipped batches back
for _, from := range skip {
q.headerTaskQueue.Push(from, -int64(from))
}
// Assemble and return the block download request
if send == 0 {
return nil
}
request := &fetchRequest{
Peer: p,
From: send,
Time: time.Now(),
}
q.headerPendPool[p.id] = request
return request
}
core-geth validation — +3 -3
| | | |---|---| | File | [`queue.go`](https://github.com/etclabscore/core-geth/blob/v1.12.20/eth/downloader/queue.go) | | Symbol | `queue.ReserveHeaders` | | Ref | `v1.12.20` |--- a/core-geth/eth/downloader/queue.go
+++ b/etc/eth/downloader/queue_pow.go
@@ -1,8 +1,8 @@
// ReserveHeaders reserves a set of headers for the given peer, skipping any
// previously failed batches.
-func (q *queue) ReserveHeaders(p *peerConnection, count int) *fetchRequest {
- q.lock.Lock()
- defer q.lock.Unlock()
+func (q *queueWithHeaders) ReserveHeaders(p *peerConnection, count int) *fetchRequest {
+ q.queue.lock.Lock()
+ defer q.queue.lock.Unlock()
// Short circuit if the peer's already downloading something (sanity check to
// not corrupt state)