MCPcopy Create free account
hub / github.com/ethereum/node-crawler / getClientInfoLoop

Method getClientInfoLoop

pkg/crawler/crawl.go:176–222  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

174}
175
176func (c *crawler) getClientInfoLoop() {
177 defer func() { c.Done() }()
178 for n := range c.reqCh {
179 if n == nil {
180 return
181 }
182
183 var tooManyPeers bool
184 var scoreInc int
185
186 info, err := getClientInfo(c.genesis, c.networkID, c.nodeURL, n)
187 if err != nil {
188 log.Warn("GetClientInfo failed", "error", err, "nodeID", n.ID())
189 if strings.Contains(err.Error(), "too many peers") {
190 tooManyPeers = true
191 }
192 } else {
193 scoreInc = 10
194 }
195
196 if info != nil {
197 log.Info(
198 "Updating node info",
199 "client_type", info.ClientType,
200 "version", info.SoftwareVersion,
201 "network_id", info.NetworkID,
202 "caps", info.Capabilities,
203 "fork_id", info.ForkID,
204 "height", info.Blockheight,
205 "td", info.TotalDifficulty,
206 "head", info.HeadHash,
207 )
208 }
209
210 c.Lock()
211 node := c.output[n.ID()]
212 node.N = n
213 node.Seq = n.Seq()
214 if info != nil {
215 node.Info = info
216 }
217 node.TooManyPeers = tooManyPeers
218 node.Score += scoreInc
219 c.output[n.ID()] = node
220 c.Unlock()
221 }
222}
223
224func (c *crawler) updateNode(n *enode.Node) {
225 c.Lock()

Callers 1

RunMethod · 0.95

Calls 2

getClientInfoFunction · 0.85
ErrorMethod · 0.80

Tested by

no test coverage detected