Receive block. @param block the block
(Block block)
| 363 | * @param block the block |
| 364 | */ |
| 365 | public void receiveBlock(Block block) { |
| 366 | if (this.consensusAlgo.isReceivedBlockValid(block, this.block)) { |
| 367 | if (this.block != null && !this.block.isOnSameChainAs(block)) { |
| 368 | // If orphan mark orphan |
| 369 | this.addOrphans(this.block, block); |
| 370 | } |
| 371 | // Else add to canonical chain |
| 372 | this.addToChain(block); |
| 373 | // Generates a new minting task |
| 374 | this.minting(); |
| 375 | // Advertise received block |
| 376 | this.sendInv(block); |
| 377 | } else if (!this.orphans.contains(block) && !block.isOnSameChainAs(this.block)) { |
| 378 | // TODO better understand - what if orphan is not valid? |
| 379 | // If the block was not valid but was an unknown orphan and is not on the same chain as the |
| 380 | // current block |
| 381 | this.addOrphans(block, this.block); |
| 382 | arriveBlock(block, this); |
| 383 | } |
| 384 | } |
| 385 | |
| 386 | /** |
| 387 | * Receive message. |
no test coverage detected