MCPcopy Index your code
hub / github.com/CovenantSQL/CovenantSQL / connectServer

Method connectServer

cmd/cql-eth-exchange/exchange.go:188–226  ·  view source on GitHub ↗
(ctx context.Context)

Source from the content-addressed store, hash-verified

186}
187
188func (e *Exchange) connectServer(ctx context.Context) (err error) {
189 e.stopPreviousSubscribe()
190
191 e.rawClient, err = rpc.DialContext(ctx, e.cfg.Endpoint)
192 if err != nil {
193 return
194 }
195
196 e.client = ethclient.NewClient(e.rawClient)
197
198 e.subClient, err = ethclient.DialContext(ctx, e.cfg.Endpoint)
199 if err != nil {
200 return
201 }
202
203 e.subscription, err = e.subClient.SubscribeNewHead(ctx, e.newBlockHeaderCh)
204 if err != nil {
205 return
206 }
207
208 e.chainID, err = e.getChainID()
209 if err != nil {
210 return
211 }
212 switch e.chainID {
213 case params.MainnetChainConfig.ChainID.Int64():
214 e.chainCfg = params.MainnetChainConfig
215 case params.TestnetChainConfig.ChainID.Int64():
216 e.chainCfg = params.TestnetChainConfig
217 case params.RinkebyChainConfig.ChainID.Int64():
218 e.chainCfg = params.RinkebyChainConfig
219 case params.GoerliChainConfig.ChainID.Int64():
220 e.chainCfg = params.GoerliChainConfig
221 default:
222 e.chainCfg = params.AllEthashProtocolChanges
223 }
224
225 return
226}
227
228func (e *Exchange) fetchOldBlocks(ctx context.Context) (err error) {
229 var blk *types.Block

Callers 1

StartMethod · 0.95

Calls 2

stopPreviousSubscribeMethod · 0.95
getChainIDMethod · 0.95

Tested by

no test coverage detected