Skip to content

Instantly share code, notes, and snippets.

@yatender-oktalk
Created September 26, 2020 23:22
Show Gist options
  • Save yatender-oktalk/3e0710a30212b911d40844531ad879be to your computer and use it in GitHub Desktop.
Save yatender-oktalk/3e0710a30212b911d40844531ad879be to your computer and use it in GitHub Desktop.
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