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

Method fetchOldBlocks

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

Source from the content-addressed store, hash-verified

226}
227
228func (e *Exchange) fetchOldBlocks(ctx context.Context) (err error) {
229 var blk *types.Block
230
231 // fetch old block failed
232 if blk, err = e.client.BlockByNumber(ctx, nil); err != nil {
233 return
234 }
235
236 e.newBlockCh <- blk
237 targetBlkNumber := blk.NumberU64()
238
239 if e.currentBlock != 0 {
240 for i := e.currentBlock; i < targetBlkNumber; {
241 blk, err = e.client.BlockByNumber(ctx, new(big.Int).SetUint64(i))
242 if err != nil {
243 time.Sleep(time.Second)
244 continue
245 }
246
247 e.newBlockCh <- blk
248 i++
249 }
250 }
251
252 return
253}
254
255func (e *Exchange) process() {
256 if e.newBlockHeaderCh == nil || e.wg == nil {

Callers 1

StartMethod · 0.95

Calls

no outgoing calls

Tested by

no test coverage detected