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

Function getStatus

pkg/crawler/handshake.go:147–177  ·  view source on GitHub ↗
(config *params.ChainConfig, version uint32, genesis *ethTypes.Block, network uint64, nodeURL string)

Source from the content-addressed store, hash-verified

145}
146
147func getStatus(config *params.ChainConfig, version uint32, genesis *ethTypes.Block, network uint64, nodeURL string) *Status {
148 if _status == nil {
149 _status = &Status{
150 ProtocolVersion: version,
151 NetworkID: network,
152 TD: big.NewInt(0),
153 Head: genesis.Hash(),
154 Genesis: genesis.Hash(),
155 ForkID: forkid.NewID(config, genesis, 0, 0),
156 }
157 }
158
159 if nodeURL != "" && time.Since(lastStatusUpdate) > 15*time.Second {
160 cl, err := ethclient.Dial(nodeURL)
161 if err != nil {
162 log.Error("ethclient.Dial", "err", err)
163 return _status
164 }
165
166 header, err := cl.HeaderByNumber(context.Background(), nil)
167 if err != nil {
168 log.Error("cannot get header by number", "err", err)
169 return _status
170 }
171
172 _status.Head = header.Hash()
173 _status.ForkID = forkid.NewID(config, genesis, header.Number.Uint64(), header.Time)
174 }
175
176 return _status
177}
178
179func readStatus(conn *Conn, info *common.ClientInfo) error {
180 switch msg := conn.Read().(type) {

Callers 1

getClientInfoFunction · 0.85

Calls 1

ErrorMethod · 0.80

Tested by

no test coverage detected