MCPcopy Create free account
hub / github.com/dsg-titech/simblock / receiveBlock

Method receiveBlock

simulator/src/main/java/simblock/node/Node.java:365–384  ·  view source on GitHub ↗

Receive block. @param block the block

(Block block)

Source from the content-addressed store, hash-verified

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.

Callers 4

genesisBlockMethod · 0.95
receiveMessageMethod · 0.95
runMethod · 0.80
runMethod · 0.80

Calls 7

addOrphansMethod · 0.95
addToChainMethod · 0.95
mintingMethod · 0.95
sendInvMethod · 0.95
isOnSameChainAsMethod · 0.80
arriveBlockMethod · 0.80
isReceivedBlockValidMethod · 0.45

Tested by

no test coverage detected