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

Function readHello

pkg/crawler/handshake.go:124–145  ·  view source on GitHub ↗
(conn *Conn, info *common.ClientInfo)

Source from the content-addressed store, hash-verified

122}
123
124func readHello(conn *Conn, info *common.ClientInfo) error {
125 switch msg := conn.Read().(type) {
126 case *Hello:
127 // set snappy if version is at least 5
128 if msg.Version >= 5 {
129 conn.SetSnappy(true)
130 }
131 info.Capabilities = msg.Caps
132 info.SoftwareVersion = msg.Version
133 info.ClientType = msg.Name
134
135 conn.negotiateEthProtocol(info.Capabilities)
136
137 return nil
138 case *Disconnect:
139 return fmt.Errorf("bad hello handshake disconnect: %v", msg.Reason.Error())
140 case *Error:
141 return fmt.Errorf("bad hello handshake error: %v", msg.Error())
142 default:
143 return fmt.Errorf("bad hello handshake code: %v", msg.Code())
144 }
145}
146
147func getStatus(config *params.ChainConfig, version uint32, genesis *ethTypes.Block, network uint64, nodeURL string) *Status {
148 if _status == nil {

Callers 1

getClientInfoFunction · 0.85

Calls 4

ReadMethod · 0.80
negotiateEthProtocolMethod · 0.80
ErrorMethod · 0.80
CodeMethod · 0.65

Tested by

no test coverage detected