-
Notifications
You must be signed in to change notification settings - Fork 75
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
27 changed files
with
634 additions
and
163 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
37 changes: 37 additions & 0 deletions
37
src/main/scala/io/iohk/ethereum/consensus/blocks/CheckpointBlockGenerator.scala
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
package io.iohk.ethereum.consensus.blocks | ||
|
||
import akka.util.ByteString | ||
import io.iohk.ethereum.domain.BlockHeader.HeaderExtraFields.HefPostEcip1097 | ||
import io.iohk.ethereum.domain._ | ||
import io.iohk.ethereum.ledger.BloomFilter | ||
|
||
class CheckpointBlockGenerator { | ||
|
||
def generate(parent: Block, checkpoint: Checkpoint): Block = { | ||
val blockNumber = parent.number + 1 | ||
// we are using a predictable value for timestamp so that each federation node generates identical block | ||
// see ETCM-173 | ||
val timestamp = parent.header.unixTimestamp + 1 | ||
|
||
val header = BlockHeader( | ||
parentHash = parent.hash, | ||
ommersHash = BlockHeader.EmptyOmmers, | ||
beneficiary = BlockHeader.EmptyBeneficiary, | ||
difficulty = parent.header.difficulty, | ||
number = blockNumber, | ||
gasLimit = parent.header.gasLimit, | ||
unixTimestamp = timestamp, | ||
extraData = ByteString.empty, | ||
stateRoot = parent.header.stateRoot, | ||
transactionsRoot = BlockHeader.EmptyMpt, | ||
receiptsRoot = BlockHeader.EmptyMpt, | ||
logsBloom = BloomFilter.EmptyBloomFilter, | ||
gasUsed = UInt256.Zero, | ||
mixHash = ByteString.empty, | ||
nonce = ByteString.empty, | ||
extraFields = HefPostEcip1097(false, Some(checkpoint)) | ||
) | ||
|
||
Block(header, BlockBody.empty) | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.