@@ -129,7 +129,6 @@ func (bl *blockListener) newHeadsSubListener() {
129
129
func (bl * blockListener ) establishBlockHeightWithRetry () error {
130
130
wsConnected := false
131
131
return bl .c .retry .Do (bl .ctx , "get initial block height" , func (_ int ) (retry bool , err error ) {
132
-
133
132
// If we have a WebSocket backend, then we connect it and switch over to using it
134
133
// (we accept an un-locked update here to backend, as the most important routine that's
135
134
// querying block state is the one we're called on)
@@ -197,11 +196,11 @@ func (bl *blockListener) listenLoop() {
197
196
// Sleep for the polling interval, or until we're shoulder tapped by the newHeads listener
198
197
if ! firstIteration {
199
198
select {
200
- case <- time .After (bl .blockPollingInterval ):
201
- case <- bl .newHeadsTap :
202
199
case <- bl .ctx .Done ():
203
200
log .L (bl .ctx ).Debugf ("Block listener loop stopping" )
204
201
return
202
+ case <- time .After (bl .blockPollingInterval ):
203
+ case <- bl .newHeadsTap :
205
204
}
206
205
} else {
207
206
firstIteration = false
@@ -296,7 +295,6 @@ func (bl *blockListener) listenLoop() {
296
295
// head of the canonical chain we have. If these blocks do not just fit onto the end of the chain, then we
297
296
// work backwards building a new view and notify about all blocks that are changed in that process.
298
297
func (bl * blockListener ) reconcileCanonicalChain (bi * blockInfoJSONRPC ) * list.Element {
299
-
300
298
mbi := & minimalBlockInfo {
301
299
number : bi .Number .BigInt ().Int64 (),
302
300
hash : bi .Hash .String (),
@@ -336,7 +334,6 @@ func (bl *blockListener) reconcileCanonicalChain(bi *blockInfoJSONRPC) *list.Ele
336
334
// handleNewBlock rebuilds the canonical chain around a new block, checking if we need to rebuild our
337
335
// view of the canonical chain behind it, or trimming anything after it that is invalidated by a new fork.
338
336
func (bl * blockListener ) handleNewBlock (mbi * minimalBlockInfo , addAfter * list.Element ) * list.Element {
339
-
340
337
// If we have an existing canonical chain before this point, then we need to check we've not
341
338
// invalidated that with this block. If we have, then we have to re-verify our whole canonical
342
339
// chain from the first block. Then notify from the earliest point where it has diverged.
@@ -374,7 +371,6 @@ func (bl *blockListener) handleNewBlock(mbi *minimalBlockInfo, addAfter *list.El
374
371
log .L (bl .ctx ).Debugf ("Added block %d / %s parent=%s to in-memory canonical chain (new length=%d)" , mbi .number , mbi .hash , mbi .parentHash , bl .canonicalChain .Len ())
375
372
376
373
return newElem
377
-
378
374
}
379
375
380
376
// rebuildCanonicalChain is called (only on non-empty case) when our current chain does not seem to line up with
0 commit comments