Browse Source

server: Run the BackwardsSynchronizerTask after replacing a block by height (#30)

prometheus-integration
Alexis Hernandez 7 years ago
parent
commit
c410771ed4
  1. 4
      server/app/com/xsn/explorer/processors/BlockEventsProcessor.scala
  2. 3
      server/app/com/xsn/explorer/tasks/PollingSeederTask.scala
  3. 3
      server/app/com/xsn/explorer/tasks/SQSSeederTask.scala
  4. 2
      server/test/com/xsn/explorer/processors/BlockEventsProcessorSpec.scala

4
server/app/com/xsn/explorer/processors/BlockEventsProcessor.scala

@ -117,7 +117,7 @@ class BlockEventsProcessor @Inject() (
.createBlock(newBlock, newTransactions)
.map {
case Good(BlockOps.Result.BlockCreated) => Good(MissingBlockProcessed(newBlock))
case Good(BlockOps.Result.BlockReplacedByHeight) => Good(ReplacedByBlockHeight)
case Good(BlockOps.Result.BlockReplacedByHeight) => Good(ReplacedByBlockHeight(newBlock))
case Bad(errors) => Bad(errors)
}
@ -171,5 +171,5 @@ object BlockEventsProcessor {
case class NewBlockAppended(block: Block) extends Result
case class RechainDone(orphanBlock: Block, newBlock: Block) extends Result
case object MissingBlockIgnored extends Result
case object ReplacedByBlockHeight extends Result
case class ReplacedByBlockHeight(newBlock: Block) extends Result
}

3
server/app/com/xsn/explorer/tasks/PollingSeederTask.scala

@ -56,6 +56,9 @@ class PollingSeederTask @Inject() (
case BlockEventsProcessor.MissingBlockProcessed(block) =>
backwardsSynchronizerTask.sync(block)
case BlockEventsProcessor.ReplacedByBlockHeight(newBlock) =>
backwardsSynchronizerTask.sync(newBlock)
case _ => ()
}
}

3
server/app/com/xsn/explorer/tasks/SQSSeederTask.scala

@ -106,6 +106,7 @@ class SQSSeederTask @Inject() (
backwardsSynchronizerTask.sync(block)
case BlockEventsProcessor.MissingBlockIgnored => ()
case BlockEventsProcessor.ReplacedByBlockHeight => ()
case BlockEventsProcessor.ReplacedByBlockHeight(newBlock) =>
backwardsSynchronizerTask.sync(newBlock)
}
}

2
server/test/com/xsn/explorer/processors/BlockEventsProcessorSpec.scala

@ -261,7 +261,7 @@ class BlockEventsProcessorSpec extends PostgresDataHandlerSpec with ScalaFutures
.foreach { whenReady(_) { _.isGood mustEqual true } }
whenReady(processor.processBlock(block3.hash)) { result =>
result mustEqual Good(ReplacedByBlockHeight)
result mustEqual Good(ReplacedByBlockHeight(block3))
val blocks = List(block1.copy(nextBlockhash = Some(block3.hash)), block3)
verifyBlockchain(blocks)

Loading…
Cancel
Save