Skip to content
Snippets Groups Projects
Commit 5b421ec1 authored by ROUSSET Noemie's avatar ROUSSET Noemie
Browse files

hardship function changes

parents d06e33ae 2d9a251b
No related branches found
No related tags found
No related merge requests found
Pipeline #3969 failed
......@@ -16,6 +16,7 @@ defmodule BMA.Blockchain.Hardship do
{:ok, :block} = :dets.open_file(:block, [{:file, db_block}, {:type, :set}])
case :dets.match(:block, {:"$1", %{issuer: search}}) do
[{_key,block_searched}] ->
#exclusion factor calculation
nbPreviousIssuers = last_block.issuersCount
nbBlocksSince = last_block.number - block_searched.number
......@@ -27,6 +28,10 @@ defmodule BMA.Blockchain.Hardship do
Poison.encode!(getHardship(exFact, last_block[:powMin], handicap, last_block))
_ ->
#last block of the blockchain
{:ok, :global_bindex} = :dets.open_file(:global_bindex, [{:file, 'data/global_bindex'}, {:type, :set}])
last_block = :ets.match(:global_bindex, {:last_block, :"$1"})
exFact = 1
powMin = last_block[:powMin]
handicap = getHandicap(last_block, search)
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment