Skip to content

newQueueWithHeaders

NEW-ETC — no upstream or core-geth original.

File queue_pow.go
Symbol newQueueWithHeaders
Ref etc/v1.17.3-full-node

NEW-ETC: factory for queueWithHeaders wrapper. Installs revokeHook on queue so that queue.Revoke (called from UnregisterPeer) also revokes pending header requests.

// newQueueWithHeaders creates a new queueWithHeaders wrapping the given queue.
// It installs a revokeHook so that queue.Revoke also revokes pending header requests.
func newQueueWithHeaders(q *queue) *queueWithHeaders {
    qwh := &queueWithHeaders{
        queue:        q,
        headerContCh: make(chan bool, 1),
    }
    q.revokeHook = func(peerID string) {
        if request, ok := qwh.headerPendPool[peerID]; ok {
            qwh.headerTaskQueue.Push(request.From, -int64(request.From))
            delete(qwh.headerPendPool, peerID)
        }
    }
    return qwh
}

← Sync & Downloader