@@ -201,15 +201,35 @@ class BlockImporter(
201
201
}
202
202
203
203
private def importMinedBlock (block : Block , state : ImporterState ): Unit =
204
- importBlock(block, new MinedBlockImportMessages (block), informFetcherOnFail = false )(state)
204
+ importBlock(
205
+ block,
206
+ new MinedBlockImportMessages (block),
207
+ informFetcherOnFail = false ,
208
+ informFetcherOnLastBlockChanged = true
209
+ )(state)
205
210
206
211
private def importCheckpointBlock (block : Block , state : ImporterState ): Unit =
207
- importBlock(block, new CheckpointBlockImportMessages (block), informFetcherOnFail = false )(state)
212
+ importBlock(
213
+ block,
214
+ new CheckpointBlockImportMessages (block),
215
+ informFetcherOnFail = false ,
216
+ informFetcherOnLastBlockChanged = true
217
+ )(state)
208
218
209
219
private def importNewBlock (block : Block , peerId : PeerId , state : ImporterState ): Unit =
210
- importBlock(block, new NewBlockImportMessages (block, peerId), informFetcherOnFail = true )(state)
211
-
212
- private def importBlock (block : Block , importMessages : ImportMessages , informFetcherOnFail : Boolean ): ImportFn = {
220
+ importBlock(
221
+ block,
222
+ new NewBlockImportMessages (block, peerId),
223
+ informFetcherOnFail = true ,
224
+ informFetcherOnLastBlockChanged = false
225
+ )(state)
226
+
227
+ private def importBlock (
228
+ block : Block ,
229
+ importMessages : ImportMessages ,
230
+ informFetcherOnFail : Boolean ,
231
+ informFetcherOnLastBlockChanged : Boolean
232
+ ): ImportFn = {
213
233
def doLog (entry : ImportMessages .LogEntry ): Unit = log.log(entry._1, entry._2)
214
234
215
235
importWith {
@@ -222,6 +242,9 @@ class BlockImporter(
222
242
val (blocks, tds) = importedBlocksData.map(data => (data.block, data.td)).unzip
223
243
broadcastBlocks(blocks, tds)
224
244
updateTxPool(importedBlocksData.map(_.block), Seq .empty)
245
+ if (informFetcherOnLastBlockChanged) {
246
+ fetcher ! BlockFetcher .LastBlockChanged (blocks.last.number)
247
+ }
225
248
226
249
case BlockEnqueued => ()
227
250
@@ -232,6 +255,9 @@ class BlockImporter(
232
255
case ChainReorganised (oldBranch, newBranch, totalDifficulties) =>
233
256
updateTxPool(newBranch, oldBranch)
234
257
broadcastBlocks(newBranch, totalDifficulties)
258
+ if (informFetcherOnLastBlockChanged) {
259
+ fetcher ! BlockFetcher .LastBlockChanged (newBranch.last.number)
260
+ }
235
261
236
262
case BlockImportFailed (error) =>
237
263
if (informFetcherOnFail) {
0 commit comments