Created
September 26, 2020 23:22
-
-
Save yatender-oktalk/3e0710a30212b911d40844531ad879be to your computer and use it in GitHub Desktop.
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
defmodule ExChain.Blockchain do | |
@moduledoc """ | |
This module contains the blockchain related functions | |
""" | |
alias __MODULE__ | |
alias ExChain.Blockchain.Block | |
defstruct ~w(chain)a | |
@type t :: %Blockchain{ | |
chain: [Block.t({})] | |
} | |
@spec new :: Blockchain.t() | |
def new() do | |
%__MODULE__{} | |
|> add_genesis() | |
end | |
defp add_genesis(blockchain = %__MODULE__{}) do | |
%{blockchain | chain: [Block.genesis()]} | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment