les: lightFetcher comments

This commit is contained in:
Zsolt Felfoldi 2018-02-18 22:11:14 +01:00
parent 055eb26ae8
commit 651ee08512

View file

@ -36,24 +36,26 @@ const (
maxNodeCount = 20 // maximum number of fetcherTreeNode entries remembered for each peer maxNodeCount = 20 // maximum number of fetcherTreeNode entries remembered for each peer
) )
// lightFetcher // lightFetcher implements retrieval of newly announced headers. It also provides a peerHasBlock function for the
// ODR system to ensure that we only request data related to a certain block from peers who have already processed
// and announced that block.
type lightFetcher struct { type lightFetcher struct {
pm *ProtocolManager pm *ProtocolManager
odr *LesOdr odr *LesOdr
chain *light.LightChain chain *light.LightChain
lock sync.Mutex // lock protects access to the fetcher's internal state variables except sent requests
maxConfirmedTd *big.Int maxConfirmedTd *big.Int
peers map[*peer]*fetcherPeerInfo peers map[*peer]*fetcherPeerInfo
lastUpdateStats *updateStatsEntry lastUpdateStats *updateStatsEntry
syncing bool
syncDone chan *peer
lock sync.Mutex reqMu sync.RWMutex // reqMu protects access to sent header fetch requests
deliverChn chan fetchResponse
reqMu sync.RWMutex
requested map[uint64]fetchRequest requested map[uint64]fetchRequest
deliverChn chan fetchResponse
timeoutChn chan uint64 timeoutChn chan uint64
requestChn chan bool // true if initiated from outside requestChn chan bool // true if initiated from outside
syncing bool
syncDone chan *peer
} }
// fetcherPeerInfo holds fetcher-specific information about each active peer // fetcherPeerInfo holds fetcher-specific information about each active peer