Skip to content

Commit

Permalink
[GH-776] Genesis block adjustments
Browse files Browse the repository at this point in the history
  • Loading branch information
d-velev committed Nov 12, 2018
1 parent 6de1c1a commit 9ab4247
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 14 deletions.
19 changes: 9 additions & 10 deletions apps/aecore/lib/aecore/chain/genesis.ex
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ defmodule Aecore.Chain.Genesis do
"""

alias Aecore.Account.{Account, AccountStateTree}
alias Aecore.Chain.{Block, Chainstate, Header}
alias Aecore.Chain.{KeyBlock, Chainstate, KeyHeader}
alias Aecore.Governance.GovernanceConstants, as: Governance
alias Aecore.Governance.GenesisConstants, as: GenesisConstants
alias Aeutil.Environment
Expand All @@ -13,13 +13,13 @@ defmodule Aecore.Chain.Genesis do

@spec hash() :: binary()
def hash do
Header.hash(header())
KeyHeader.hash(header())
end

@spec block() :: Block.t()
@spec block() :: KeyBlock.t()
def block do
header = header()
%Block{header: header, txs: []}
%KeyBlock{header: header}
end

@spec populated_trees() :: Chainstate.t()
Expand Down Expand Up @@ -71,21 +71,20 @@ defmodule Aecore.Chain.Genesis do
end
end

@spec header() :: Header.t()
defp header do
header = %{
@spec header() :: KeyHeader.t()
def header do
%KeyHeader{
height: GenesisConstants.height(),
prev_hash: GenesisConstants.prev_hash(),
txs_hash: GenesisConstants.txs_hash(),
prev_key_hash: GenesisConstants.prev_key_hash(),
root_hash: Chainstate.calculate_root_hash(populated_trees()),
time: GenesisConstants.time(),
nonce: GenesisConstants.nonce(),
miner: GenesisConstants.miner(),
beneficiary: GenesisConstants.beneficiary(),
pow_evidence: GenesisConstants.evidence(),
version: GenesisConstants.version(),
target: GenesisConstants.target()
}

struct(Header, header)
end
end
13 changes: 9 additions & 4 deletions apps/aecore/lib/aecore/governance/genesis_constants.ex
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ defmodule Aecore.Governance.GenesisConstants do

@prev_hash <<0::256>>

@txs_hash <<0::256>>
@prev_key_hash <<0::256>>

@time 0

Expand All @@ -15,7 +15,9 @@ defmodule Aecore.Governance.GenesisConstants do

@miner <<0::256>>

@version 15
@beneficiary <<0::256>>

@version 29

@target 0x2100FFFF

Expand All @@ -24,8 +26,8 @@ defmodule Aecore.Governance.GenesisConstants do
@spec prev_hash :: binary()
def prev_hash, do: @prev_hash

@spec txs_hash :: binary()
def txs_hash, do: @txs_hash
@spec prev_key_hash :: binary()
def prev_key_hash, do: @prev_key_hash

@spec time :: non_neg_integer()
def time, do: @time
Expand All @@ -39,6 +41,9 @@ defmodule Aecore.Governance.GenesisConstants do
@spec miner :: binary()
def miner, do: @miner

@spec beneficiary :: binary()
def beneficiary, do: @beneficiary

@spec version :: non_neg_integer()
def version, do: @version

Expand Down

0 comments on commit 9ab4247

Please sign in to comment.